Shifting x coordinates by 180
Hello Leigh, the error message clearly states the problem. A workaround would maybe to extract the coordinates (Try to use function lapply due to the polygons slot is a list.). Then change the coordinates as desired and create a new SpatialPolygons object. In the end create a new SpatialPolygonsDataFrame out of the new SpatialPolygons and the original data. It is just an idea and not tested ; ) . See also ?SpatialPolygonsDataFrame ?SpatialPolygons etc. With best regards Roland Leigh Kroeger schrieb am 2014-10-15:
Hello,
I have the following shapefile imported into R:
summary(grid)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
x -165.73220 -123.23912
y 29.55567 46.44211
Is projected: FALSE
proj4string : [+proj=longlat +ellps=WGS84]
I need to shift 'x' by adding 180 to the data column. I think the 'elide' function in maptools can accomplish this but the following error comes up when I start the code:
coordinates(grid) <- c("x", "y")
Error in `coordinates<-`(`*tmp*`, value = c("x", "y")) : setting
coordinates cannot be done on Spatial objects, where they have
already been
set
My intended outcome is to be able to plot occurrence data from GBIF onto the polygon shapefile.
Regards,
-- *Leigh A. Kroeger* <*)))><
*PhD Candidate - Marine Ecology* ?????? ????? ????? ?????????? ?? ???? Dept. of Zoology Tel Aviv University Tel Aviv, 69978 Israel Tel: +03 640-7830
http://belmaker.weebly.com/members.html http://www.linkedin.com/profile/view?id=144722403&trk=nav_responsive_tab_profile_pic
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo