Skip to content
Prev 10322 / 29559 Next

getting rasters to match

Advait,

When I do what you did with some example data, a clear error warning
message results, saying that your crs is not valid.
Loading required package: sp
raster version 1.7-12 (9-December-2010)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
Path to GDAL shared files: C:/soft/R/R-2.12.0/library/rgdal/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: C:/soft/R/R-2.12.0/library/rgdal/proj
Warning message:
In .newCRS(value) :
  +proj=lcc +datum=NAD83 +ellps=GRS80 +units=m, xmn=-2736000,
xmx=2334000, ymn=-1608000, ymx=1952000 is not a valid proj4 CRS string
This can be easily fixed:
class       : RasterLayer
filename    : C:/Documents and Settings/rhijmans/My
Documents/mask.regcm.2040-49.climatol.annsum.HDR.future.tif
dimensions  : 10, 10 (nrow, ncol)
ncell       : 100
min value   : 1
max value   : 1
projection  : +proj=lcc +lat_1=33 +lat_2=45 +lat_0=0 +lon_0=0 +x_0=0
+y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
resolution  : 36, 18  (x, y)


Do note that

projection(x) <-

_sets_ (defines) the crs (projection) of an object. It does _not_
change it from one projection to another. You need to use
projectRaster for that.


so perhaps you want something like:

r <- raster(vulcan.10k.dp.build.387.RES.ann1.vulcproj.img)
# if necessary
# projection(r) <- crs
res <- projectRaster(futurehdr, r)

Robert
On Sat, Dec 11, 2010 at 9:44 PM, Advait Godbole <advaitgodbole at gmail.com> wrote: