[R] spTransform longlat to utm

Alexander Belousov mynewsmailbox at gmx.de
Thu Oct 18 17:32:18 CEST 2012

Dear all,

I am trying to project my LongLat-maps to a plane. 
The ultimate purpose is to do a search of points in vicinity of other points using overlay-commands (sp) with radius in km.

I am applying spTransform (package rgdal) and it gives my some curious results.

An example.
Let's take a point lying somewhere in Germany, zone=32U

x <- 8.968735
y <- 49.454735

After conversion I sould get something like

Easting:  426858 (km)
Northing: 5427937 (km)

sp1 <- SpatialPoints(matrix(c(x,y), ncol=2), proj4string = CRS("+proj=longlat +datum=WGS84"))

sp1Transformed <-  spTransform(sp1, CRS("+proj=merc +zone=32u +datum=WGS84"))

       coords.x1   coords.x2
[1,] 998395.0133 6319888.068

The result is an obvious nonsense.

Well, after some deliberation I swapped the original coordinate columns:

x <- 49.454735
y <- 8.968735

sp2 <- SpatialPoints(matrix(c(x,y), ncol=2), proj4string = CRS("+proj=longlat +datum=WGS84"))

sp2Transformed <-  spTransform(sp2, CRS("+proj=merc +zone=32u +datum=WGS84"))

      coords.x1  coords.x2
[1,] 5505275.918 995840.692

Now the northing (which comes first after swapping) looks better, at least it falls within Germany, which is however not to say about the easting.

Apparently I am missing an important point by the transformation. 
Any help will be greatly appreciated!



More information about the R-help mailing list