I think that by using readOGR to import a shapefile renders worthless to put proj4string to the script since if any coords are available in the shapefile, it will be transported through the readOGR.
Therefore, proj4string is expedient only if we use another import function for example readShapeSpatial
(for polygons, lines or points) or by using readOGR, but in the case that the shapefile does not contain the coordinates/projection:
When checking if the shapefile has projection information and if it has not, should I add proj4string although I have put readOGR?
Answer
As JeffreyEvans states, readOGR
from the rgdal
library imports a CRS if there is one embedded in the shapefile. You can check by (example using a shp I've been playing with):
proj4string(india) # from the sp package
# [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
If this returns NA
you can specify a CRS with:
proj4string(india) <- CRS("+init=epsg:24383")
You can obtain the EPSG CRS strings from http://spatialreference.org/
To answer your specific question, yes, you should define a projection if one is not specified.
If one is not certain which CRS to assign/define, refer to the following post:
And if one wants to reproject a spatial object in R, i.e., change its projection, then refer to:
No comments:
Post a Comment