EDIT: I have reworded the title question slightly, and adjusted the text to respond to the comment by @DWin.
Combining geographic layers that are projected and not projected can be challenging. Often, it seems, some transformation is necessary, as geographic layers come from different products and publishers.
I am aware that R has several tools to perform geographic transformations. For example:
- For objects of class
Spatial*in thesppackage, thespTransform()function in thergdalpackage can be used; and, - For objects of class
Raster*in therasterpackage, theprojectRaster()function can be used.
Here is a specific task that I would like to accomplish in R: Transform to UTM grid Zone 15N (Datum: NAD83) a polygons layer describing lakes in a UTM grid Zone 15N (Datum: NAD27) projection (this is in an ESRI shapefile format).
The useful thing here is the epsg database included in rgdal.
Those codes are what you need in spTransform. If your lakes are in a shapefile with that NAD27 projection, then:
should give you the lakes as supplied (note I dont think readShapeSpatial will read a .prj file with a shapefile set, so I’ve set it here explicitly)
Now to convert to NAD83 datum version of UTM zone 15N:
Rasters are a bit trickier since they generally involve a warp so that you end up with a regular grid in your projected coordinate system – you can’t just transform the coordinates of the corners…