Help with GIS
This is a dummy example - especially in terms of made up coordinate
system details, but shows how you can reproject with the raster
package:
library(rgdal)
## create a grid, with dummy coordinates / projection
im <- image2Grid(list(x = 1e5 * (1:nrow(volcano)), y = 1e5 *
(1:ncol(volcano)), z = volcano), p4 = "+proj=laea")
writeGDAL(im, "dummy.tif")
## now the process, using raster package
library(raster)
r0 <- raster("dummy.tif")
# proj.4 projection description
newproj <- "+proj=longlat +ellps=WGS84"
pr <- projectExtent(r0, newproj)
## (optionally) Adjust the cell size
## res(pr) <- res(pr)/2
# project the values of RasterLayer 'r' to the new RasterLayer 'projras'
projras <- projectRaster(r0, pr)
## now go back to sp and extract matrix
spprojras <- as(projras, "SpatialGridDataFrame")
m <- as.image.SpatialGridDataFrame(spprojras)$z
image(m)
I'm not sure if the coercion to SpatialGridDataFrame will
automatically give you all of the detail in the source by default for
large grids, but there would be a way.
Cheers, MIke.
On Wed, Oct 27, 2010 at 7:03 PM, <fsantos at ujaen.es> wrote:
Dear R community, I'm sorry, but I am newbie with GIS. I have to import a tiff using a geotiff tool, and convert it into a data matrix. The initial projection is Lambert Azimuthal Equal Area, and I would like to get the final matrix in a regular lat/lon grid. It is possible to do it with R? Thanks in advance.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsumner at gmail.com