[R-sig-Geo] is it possible to resample a raster image?

Vladimir Eremeev wl at eimb.ru
Thu Apr 19 11:50:55 CEST 2007

Dear all,

I am studying new knowledge areas now.

I am curious, if it is possible to transform a projected raster image
to another geographic projection using R packages.

For example, I have a matrix (representing an image)
It has 304 columns by 448 rows.
Initially it is stored in a file, having 2 bytes per pixel.
Lots of such images can be found here

I import one of them in R:


Then I create the SpatialGridDataFrame:


proj4string(egrid)<-CRS("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +ellps=clrk66")

I have worked with these data using other tools for a long time
already, therefore, I know about their projection and dimensions.
These are documented in the web and also in `readme` files.

Now I would like to *use R-spatial packages* to transform egrid to another projection,
and export the result into an external flat binary file, similar to
the one, I have imported with readBin.

I can easily do it using other tool sets, however, now I am exploring
Is it possible?

I tried the following, however, got errors.
> egtr<-spTransform(egrid,CRS("+proj=latlong"))
> gridded(egtr)<-TRUE

Error in if (any(outside)) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: grid has empty column/rows in dimension 1 in: points2grid(points, tolerance) 
2: NAs introduced by coercion 
3: grid has empty column/rows in dimension 2 in: points2grid(points, tolerance) 
4: NAs introduced by coercion 

> fullgrid(egtr)<-TRUE
Error in `fullgrid<-`(`*tmp*`, value = TRUE) : 
        fullgrid<- only works on objects of class or extending SpatialPixels

Thank you!

Best regards,
Vladimir                mailto:wl at eimb.ru


More information about the R-sig-Geo mailing list