I am a newbie to R and I want to divide a country map into grids so that I can come to a decision according to the latitude and longitude values which grid am I residing.
I am looking for an example (R code) how to this.
I am a newbie to R and I want to divide a country map into grids so that I can come to a decision according to the latitude and longitude values which grid am I residing.
I am looking for an example (R code) how to this.
If you want to draw gridlines on a map, have a look at https://edzer.github.io/sp/, and especially at the sp::gridlines function.
You can create a polygon fishnet offline using GIS tools and plot the data along with fishnet.Alternatively a complete R-base solution is provided in SE link here Overlay a spatial polygon with a grid and check in which grid element specific coordinates are located
The most easy way to make that is using the map.grid() function. Pls visit the page https://www.rdocumentation.org/packages/mapproj/versions/1.2-5/topics/map.grid. The documentation is very simple and obvious. Let me know if you have issues still/