Skip to content

different projection transformation R and gdal commandline

2 messages · Dominik Schneider

#
Hi Chris,
Thanks for confirming this. I'm not surprised that gdalUtils gives the same
answer as the gdal utilities - my understanding is that gdalUtils is
basically the equivalent to calling the commandline utilities via system().
I'm hoping that someone can shed light on spTransform since I use that a
lot for transforming points and polygons.
ds


On Mon, Feb 15, 2016 at 2:50 PM, Chris Reudenbach <reudenbach at uni-marburg.de

  
  
#
Oh, silly me. doing plot(spTransform(box,CRS(pstring))) and it's obvious
what's happening. The projection rotates the polygon such that for the
corners y1,x1 and y2,x2   y1 != y2. But ymin(spTransform(box,CRS(pstring)))
still gives you the smallest coordinate regardless of which corner it is.

Using spatial points its easier to see.

e=c(-112.25,-104.125,33,43.75)
box=as(extent(e),'SpatialPoints')
proj4string(box)='+proj=longlat +datum=WGS84'
pstring='+proj=lcc +lat_1=28 +lat_2=50 +lat_0=39.70001220694445 +lon_0=-98
+x_0=0 +y_0=0 +ellps=sphere +a=6370000 +b=6370000 +units=m +no_defs'
coordinates(spTransform(box,CRS(pstring)))
##             x         y
##[1,] -1306471.3 -629424.0
##[2,] -1122174.4  531025.6
##[3,]  -563451.2 -713442.3
##[4,]  -483968.2  458859.3




On Tue, Feb 16, 2016 at 9:27 AM, Dominik Schneider <
dominik.schneider at colorado.edu> wrote: