How can one use R to
- split a shapefile in 200 meter squares/sub-polygons,
- plot this grid (incl. ID numbers for each square) over the original map below, and
- evaluate in which square specific geographic coordinates are located.
I am a beginner in GIS and this is perhaps a basic question, but I haven't found a tutorial on how to do this in R.
What I have done so far is loading a shapefile of NYC and plotting some exemplary geographic coordinates.
I appreciate any general advice, but I am looking for an example (R code) how to this with the data below.
# Load packages library(maptools) # Download shapefile for NYC # OLD URL (no longer working) # shpurl <- "http://www.nyc.gov/html/dcp/download/bytes/nybb_13a.zip" shpurl <- "https://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/nybb_13a.zip" tmp <- tempfile(fileext=".zip") download.file(shpurl, destfile=tmp) files <- unzip(tmp, exdir=getwd()) # Load & plot shapefile shp <- readShapePoly(files[grep(".shp$", files)]) plot(shp) # Define coordinates points_of_interest <- data.frame(y=c(919500, 959500, 1019500, 1049500, 1029500, 989500), x =c(130600, 150600, 180600, 198000, 248000, 218000), id =c("A"), stringsAsFactors=F) # Plot coordinates points(points_of_interest$y, points_of_interest$x, pch=19, col="red")