[R-sig-Geo] Export images from list of pixel images

Michael Sumner mdsumner at gmail.com
Sun Apr 15 06:10:11 CEST 2012


Here's one way:

library(spatstat)

data(lansing)
rrisklan <- relrisk(lansing))

names(rrisklan)
[1] "blackoak" "hickory"  "maple"    "misc"     "redoak"   "whiteoak"

library(maptools)
## set up first grid, with first attribute "blackoak"
g <- as(rrisklan[[1]], "SpatialGridDataFrame")

names(g) <- "blackoak"

if (length(rrisklan) > 1) {  ## safety check
   for (i in 2:length(rrisklan)) {
     g[[names(rrisklan)[i]]] <- as(rrisklan[[i]], "SpatialGridDataFrame")[[1]]
  }
}

Compare:

plot(rrisklan)
spplot(g)

With the rgdal package you can now writeGDAL(g, "myfile.tif") but
whether your target can handle multi-attribute GeoTIFF is another
matter (the last few releases of ArcGIS use GDAL anyway so presumably
it would be fine).

Cheers, Mike.


On Sun, Apr 15, 2012 at 1:41 PM, Jose Funes <jefunes at gmail.com> wrote:
> Dear all,
> I have a list of pixel images that I would like to export to in a raster
> format, i.e. GRID, tif, etc, to be able to visualize them in ArcGIS/QGIS
> but I am not sure how to convert them to SpatialGridDataFrame to be able to
> export them as tif using writeGGAL. For example:
>
> #########
> data(lansing)
> rrisklan <- relrisk(lansing))
> #####################
>
> The last yield a list of pixel images (rrisklan) with spatially varying
> risk for each specie, how could I convert them to a appropriate format to
> be able to export them as TIF.
>
> Thanks,
> Jose Funes
> JHU
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> 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



More information about the R-sig-Geo mailing list