|
This post was updated on .
I have nc files for global soil moisture,here is one file https://echange-fichiers.inra.fr/get?k=f9DDllPKdUKs5ZNQwfq
from the metadata ,the projection is cylindrical and the resolution is 25 km(it is based on authalic sphere based on International 1924 ellipsoid).As I want to compare with other data, I have to make them identical. - my other data are in WGS84 with 0.25*0.25 degree resolution and extent -180, 180, -90, 90. So I want to re-project the data I have here from EASE grid, cylindrical,25 km ,1383 pixel 586 lines to WGS84,0.25*0.25 degree,1440 pixel 720 lines: I tried this: d <-raster("C:\\Users\\aalyaari\\Desktop\\SM_RE01_MIR_CLF31D_20100812T000000_20100812T235959_246_001_7.DBL", 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"’ |
|
On Fri, Jan 18, 2013 at 5:11 PM, Jonsson <[hidden email]> 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 ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
|
In fact,it is netcdf file(even if the extension is DBL). I am new to prjections and i just tried that spTransform,I did not know projectraster. Could you please tell me what is the command using project raster.I wonder if you have tried to re-project the file?
|
| Powered by Nabble | Edit this page |
