How to re-project ease( Equal Area Scalable Earth) grid with a ~25 km cylindrical projection to WGS84 0.25 degree?
On Fri, Jan 18, 2013 at 5:11 PM, Jonsson <amen.alyaari at bordeaux.inra.fr> wrote:
<-raster("C:\\Users\\aalyaari\\Desktop\\SM_RE01_MIR_CLF31D_20100812T000000_20100812T235959_246_001_7.nc",
varname = "Soil_Moisture")
d:
class : RasterLayer
dimensions : 586, 1383, 810438 (nrow, ncol, ncell)
resolution : 0.2603037, 0.2916659 (x, y)
extent : -180, 180, -85.4581, 85.4581 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84
names : Retrieved.soil.moisture.value
zvar : Soil_Moisture
a <- spTransform(d, CRS ("+proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs"))
but I got this error:
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function ?spTransform?
for signature ?"RasterLayer", "CRS"?
And what is the error telling you? That there's no method for
spTransform that applies to RasterLayers.
To transform a raster from one projection to another you need to use
projectRaster from the raster package. Note that generally this can
involve warping a raster and interpolating the new values to get a
grid of cells in the new coordinate system.
But... you were trying to do this:
a <- spTransform(d, CRS ("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))
where d was:
coord. ref. : +proj=longlat +datum=WGS84
- which is a no-op. The source and destination have the same
coordinate reference system. You need to tell raster what the
coordinate system of the source is. See ?projection - note this
doesn't change the raster or do any projection, its just to tell the
system what the coordinates in the data represent - lat,long or metres
or whatever..
I looked in the HDR file and saw nothing about the projection, so I
don't know how to specify what you've got.
Also, you didn't point us to the .nc file you used in your example.
Also also, you should probably be posting to R-sig-geo.
Barry