Dear Listers,
I am trying to convert a Gtiff object from a coordinate system to
another... I have tried the following:
# read the Gtiff file (European Lambert azimuthal equal area)
fcE<-readGDAL("fclambert.tif")
proj4string(fcE) # CRS OK
# read a shapefile to get the projection system (Lambert II etendu - a
French projection Lambert
# conformal conic based on NTF)
fccoms<-readOGR("U:/Documents and Settings/giraudoux/Mes documents/Map
tools/Shapefiles checked prj","FC_communes")
proj4string(fccoms) # CRS OK
# transform
fcLIIe<-spTransform(fcE, CRS(proj4string(fccoms))) # looks OK
# try writing
writeGDAL(fcLIIe,"fcLIIe.tif")
Error: gridded(dataset) is not TRUE
# try to promote to a grid...
gridded(fcLIIe)<-TRUE
suggested tolerance minimum: 0.5Error in points2grid(points, tolerance)
: dimension 1 : coordinate intervals are not constant
I suspect that pixel centers may have been distorted with the
transformation but may naively I wonder if there is a way to turn this
problem eg increasing the tolerance...
Any hint appreciated...
Patrick
spTransform, gridded
3 messages · Patrick Giraudoux, Edzer Pebesma, Roger Bivand
Patrick, the problem is that if you reproject points on a grid, the result is not on a grid anymore, so I think it is correct that spTransform does return a SpatialPointsDataFrame rather than a SpatialGridDataFrame. You would have to shift points to centers on the new grid. The creator functions SpatialPixels() or SpatialPixelsDataFrame have a tolerance, which may be used to define to which extent you allow points to be off the points on a true grid. I would use that instead of gridded(x)=TRUE. Note that you do move points, then. -- Edzer
Patrick Giraudoux wrote:
Dear Listers,
I am trying to convert a Gtiff object from a coordinate system to
another... I have tried the following:
# read the Gtiff file (European Lambert azimuthal equal area)
fcE<-readGDAL("fclambert.tif")
proj4string(fcE) # CRS OK
# read a shapefile to get the projection system (Lambert II etendu - a
French projection Lambert
# conformal conic based on NTF)
fccoms<-readOGR("U:/Documents and Settings/giraudoux/Mes documents/Map
tools/Shapefiles checked prj","FC_communes")
proj4string(fccoms) # CRS OK
# transform
fcLIIe<-spTransform(fcE, CRS(proj4string(fccoms))) # looks OK
# try writing
writeGDAL(fcLIIe,"fcLIIe.tif")
Error: gridded(dataset) is not TRUE
# try to promote to a grid...
gridded(fcLIIe)<-TRUE
suggested tolerance minimum: 0.5Error in points2grid(points, tolerance)
: dimension 1 : coordinate intervals are not constant
I suspect that pixel centers may have been distorted with the
transformation but may naively I wonder if there is a way to turn this
problem eg increasing the tolerance...
Any hint appreciated...
Patrick
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
On Sat, 24 Mar 2007, Patrick Giraudoux wrote:
Dear Listers, I am trying to convert a Gtiff object from a coordinate system to another... I have tried the following:
This is warping, so in general the output will not be a regular grid. If you need a grid, try interpolating to an empty grid in the target projection (IDW in gstat ought to be OK if the resolutions are similar, with a small number of neighbours). My guess is that fcLIIe is a SpatialPoints* object, not on a regular grid. You could use gdalwarp externally to do this, if you prefer. Roger
# read the Gtiff file (European Lambert azimuthal equal area)
fcE<-readGDAL("fclambert.tif")
proj4string(fcE) # CRS OK
# read a shapefile to get the projection system (Lambert II etendu - a
French projection Lambert
# conformal conic based on NTF)
fccoms<-readOGR("U:/Documents and Settings/giraudoux/Mes documents/Map
tools/Shapefiles checked prj","FC_communes")
proj4string(fccoms) # CRS OK
# transform
fcLIIe<-spTransform(fcE, CRS(proj4string(fccoms))) # looks OK
# try writing
writeGDAL(fcLIIe,"fcLIIe.tif")
Error: gridded(dataset) is not TRUE
# try to promote to a grid...
gridded(fcLIIe)<-TRUE
suggested tolerance minimum: 0.5Error in points2grid(points, tolerance)
: dimension 1 : coordinate intervals are not constant
I suspect that pixel centers may have been distorted with the
transformation but may naively I wonder if there is a way to turn this
problem eg increasing the tolerance...
Any hint appreciated...
Patrick
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no