[R-sig-Geo] Modifying the coordinates of a Spatial* object

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sun Nov 27 22:46:03 CET 2011


You can't replace them, indeed. But you can do:

Spatial = as(Spatial, "data.frame")
coordinates(Spatial) = ~ newx + newy

On 11/27/2011 10:07 PM, Jonathan Greenberg wrote:
> R-sig-geo'ers:
> 
> I assume this is probably something really obvious I'm missing, but how do
> I replace existing coordinates of a Spatial* object with new ones?
>  coordinates(myspatial) = ~newx+newy is giving me an error like:
> 
>> class(Spatial)
> 
> [1] "SpatialPointsDataFrame"
> 
> attr(,"package")
> 
> [1] "sp"
> 
>> coordinates(Spatial)=~(mean(new_bbox[1,]))+(mean(new_bbox[2,]))
> 
> Error in `coordinates<-`(`*tmp*`, value = ~(mean(new_bbox[1, ])) +
> (mean(new_bbox[2,  :
> 
>   setting coordinates cannot be done on Spatial objects, where they have
> already been set
> 
> 
> --j
> 
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list