1

Hi i been trying to reproject a raster image from Equirectangular to EPSG:4326 (Latlon), the issue is that every time i run my code on R, i get the wrong coordinates on the new image; i don´t know where is the error in the code, also i do the same process with Qgis, and i got the same result, it´s strange, i got the opportunity to do the same reprojection process in ENVI, and the result was succesful, help please!!!

a <- raster("C:/Users/<username>/Documents/imageexample.tif")
> a
class       : RasterLayer 
dimensions  : 1800, 1800, 3240000  (nrow, ncol, ncell)
resolution  : 1100, 1100  (x, y)
extent      : -988900, 991100, 1677577, 3657577  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=eqc +lat_ts=0 +lat_0=24 +lon_0=-112 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : C:/Users/<username>/Documents/imageexample.tif
names       : imageexample

g1 <- projectRaster(a, crs="+init=epsg:4326")
> g1
class       : RasterLayer 
dimensions  : 1810, 1810, 3276100  (nrow, ncol, ncell)
resolution  : 0.00988, 0.00988  (x, y)
extent      : -120.9328, -103.05, 39.02317, 56.90597  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 
data source : in memory
names       : imageexample.tif 
values      : -5.000117, 39.87529  (min, max)

The correct coordinates should be like this:

    class       : RasterLayer 
dimensions  : 1793, 1803, 3232779  (nrow, ncol, ncell)
resolution  : 0.0108098, 0.009931556  (x, y)
extent      : -121.735, -102.245, 15.08612, 32.8934  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : C:/Users/<username>/Documents/CORRECTimageexample.tif 
names       : CORRECTimageexample

Thanks!!!

2

1 Answer 1

1

This is a bit of a special case but generally there is not defined (by the data) extent and resolution for raster reprojection. You need to specify these. For example, you can do:

library(raster)
r <- raster(xmn=-121.735, xmx=-102.245, ymn=15.08612, ymx=32.8934, nrow=1793, ncol=1803, crs='+proj=longlat +ellps=WGS84')
g2 <- projectRaster(a, r)
1
  • Hi @RobertH, sorry for the late answer, i tried to reproject the raster image with projectraster but i got an image with only NA values, probably im dping something wrong, this is what i did a <- raster("C:/Users/<username>/Documents/imageexample.tif") r <- raster(xmn=-121.735, xmx=-102.245, ymn=15.08612, ymx=32.8934, nrow=1793, ncol=1803, crs='+proj=longlat +ellps=WGS84') g2<- projectRaster(a, r) rf <- writeRaster(l, filename="imageresult.tif", format="GTiff", overwrite=TRUE) I´ve discovered that +lat_ts=0 and +lat_0=24 were inverted on the file, gdal correct the problem, but R cant Oct 2, 2013 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.