I am having a shapefile of polygons and another CSV file which contains a list of points as (Lat, Lng) pairs..
I want to check for each (lat, lng) pair from the CSV file which polygon does it fall inside..
The shapefile is projected and the proj file reads like this:
PROJCS["Transverse_Mercator",GEOGCS["GCS_OSGB 1936",
DATUM["D_OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],UNIT["Meter",1]]
My plan is as follows:
- Read the shapefile using the
readShapePoly
function in the RMapTools
package. - Read the points coordinates from the CSV file into a dataframe and convert it to SpatialPointsDataFrame
- Use
over
function to determine which polygon it falls inside.
In order to do so, I need to specify the proj4string
while loading the shapefile in step 1 and also transform the coordinates from the CSV file into the same projection system using spTransform
function before applying the over
function in step 3 as it requires that the points and polygons must be under the same projection system.
Any idea about what should the correct value for the proj file content shown above ?
readOGR
function I a always get Cannot open file errorsummary
function for theSpatialPolygonDataFrame
object gave me the correct value for theproj4string