2/21/2024 0 Comments The map of the points and polygons of a model laid out in a 2 dimensial shape is brainlyI transformed the points object to polygon's default projection before doing the intersection. Also, I used the great package mapview for interactive visualization in R. I use the sf package because is much faster than rgdal to open Shapefiles. Try the commented and reproducible example below! (C) Overlay Population with BGRI subsections <- CRS.new # Assure same CRS (WGS <- CRS.new # Assure same CRS (WGS 84)Ī <- over(Population, Portugal_subsections_clean) WriteOGR(obj=Population, dsn = ".", "Population", driver="ESRI Shapefile") (B2) Saving Population as point shape <- c("Index","Zip", "lon", "lat", "Population") WriteOGR(obj=Portugal_subsections_clean, dsn = ".", Portugal_subsections_clean", driver="ESRI Shapefile") (B) Saving files (B1) Portugals subsections <- CRS.new Report2 <- clgeo_CollectionReport(Portugal_subsections_clean) # Check again Portugal_subsections_clean <- clgeo_Clean(Portugal_subsections) # Clean topology errors (A3) Fix polygons with cleangeo report <- clgeo_CollectionReport(Portugal_subsections) # Check topology error (A3) Read polygons from BGRI dataset Portugal_subsections <- <- CRS.new Population <- SpatialPointsDataFrame(coords = Points_coords, data = Points,proj4string = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")) (A2) Read points from csv and build SpatialPointDataFrame Points <- read.csv("Points.csv", header = TRUE, sep = " ") (A) Load points and polygons (A1) Define common CRS CRS.new <- CRS("+init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0") I set a common coordinate reference system for polygons and points (WGS 1984) and repaired the polgyon with cleangeo. There should be a corruption of the coordinate system at one point, but I cannot find it! However they should spread over Portugal,(even beyond the polygon outcrop which is Lisbon) When I plotted both files in QGIS for visual checking, I found that all most all points are aggregated in one polygon. The point coordinates come from the Google API and are transformed to WGS 1984.īut when I try to overlay both, an dataframe is returned filled with NAs. The assciated prj file from the polygons shows their coordinate reference system: "DATUM]". I am trying to overlay point data with polygons in R in order to find the polygons which intersect with the points provided.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |