r - match spatial projections of spatial objects and overlay plots -


i trying overlay 2 spatial objects using plot() function. understand projections of 2 objects (of class spatiallinesdataframe , spatialpolygonsdataframe) need same in order have them visualized in same plot. i've found similar questions here , here, none of these can me want achieve.

here's coding spatialpolygonsdataframe. (v.map list of .kml files , loccoor object stores location , corresponding x , y coordinates):

map.l<-list()  (i in 1:length(v.map)){   ll<-ogrlistlayers(paste(loccoor,"/",v.map[i],".kml",sep=""))   shp<-readogr(paste(loccoor,"/",v.map[i],".kml",sep=""),layer=ll)   map<-sptransform(shp, crs("+proj=longlat +datum=wgs84"))   map.l[[i]]<-map } plot(map.l[[1]],xlim=c(min(coor[,3]),max(coor[,3])),      ylim=c(min(coor[,2]),max(coor[,2]))) (i in 2:length(v.map)){ plot(map.l[[i]],xlim=c(min(coor[,3]),max(coor[,3])),      ylim=c(min(coor[,2]),max(coor[,2])),add=t) } 

projection spatialpolygonsdataframe "map": "+proj=longlat +datum=wgs84 +ellps=wgs84 +towgs84=0,0,0"

projection spatiallinesdataframe "contours": "+proj=aeqd +ellps=wgs84 +lon_0=-xx.xxxxx +lat_0=xx.xxxxx".

i want transform projection of "map" object match of "contours". replacing "crs("+proj=longlat +datum=wgs84")" of "map" object projection of "contours" object doesn't seem work, because polygons no longer plotted (visible).

any thoughts appreciated!

here's not great metaphor: coordinates directions, , crs tells language directions in. so, if change crs, leave coordinates are, trying read german directions spanish dictionary.

we can translate directions 1 crs using sp::sptransform(). function takes 2 arguments: spatial object, , crs.

we can use raster::crs() crs spatial object. so, transform map's coordinates (and crs) crs of contours:

map <- sptransform(map, crs(contours)) 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -