[R-sig-Geo] Change coordinates of a shapefile

Ralf Schäfer senator at ecotoxicology.de
Tue Mar 27 14:14:24 CEST 2012


Too easy!
Thanks a lot, much appreciated
Ralf

Am 27.03.2012 um 14:05 schrieb Barry Rowlingson:

> On Tue, Mar 27, 2012 at 12:46 PM, Ralf Schäfer <senator at ecotoxicology.de> wrote:
>> Dear list,
>> 
>> I have a shapefile where the zone number of UTM has been placed as first digits of the x-values. So the bounding box is:
>>  min      max
>> x 33085892 33475738
>> y  5801128  6059362
>> 
>> I want to get rid of the 33 and thus extracted the coordinates from the SpatialLinesDataFrame and substracted the value:
>> coordinates(data) -> coords
>> length(coords) -> num_list
>> for(i in 1:num_list){coords[i][[1]][[1]][,1] -33000000 ->   coords[i][[1]][[1]][,1] }
>> coordinates(data) <- coords
>> Unfortunately, I get an error when trying to write back.
>> 
>> Any ideas how to accomplish this - may be there are also easier ways to change the coordinate system?!
> 
> The 'elide' function in package:maptools has a 'shift' argument that
> should let you subtract 33000000 from all coordinates...
> 
> Barry



More information about the R-sig-Geo mailing list