a simple question: how can I automatically import a huge bunch of rasters (Geotiffs) to R? With a for loop? I didn't find how to do that in the docs.. Each variable name should be the original raster name, but that's not important. greets, Martin
mass importing rasters
6 messages · Robert J. Hijmans, Nikhil Kaza, Thomas Adams +1 more
haven't tried this. but some variant of this should work
for (f in dir()){
assign(f, readGDAL(f))
}
Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina
nikhil.list at gmail.com
On Sep 12, 2010, at 4:29 PM, Martin Brandt wrote:
a simple question: how can I automatically import a huge bunch of rasters (Geotiffs) to R? With a for loop? I didn't find how to do that in the docs.. Each variable name should be the original raster name, but that's not important. greets, Martin
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
You have not said what type of objects you want, but here's one option: library(raster) s <- stack(list.files(pattern='*.tif')) Robert
On Sun, Sep 12, 2010 at 10:29 PM, Martin Brandt <martin_brandt at gmx.net> wrote:
a simple question: how can I automatically import a huge bunch of rasters (Geotiffs) to R? With a for loop? I didn't find how to do that in the docs.. Each variable name should be the original raster name, but that's not important. greets, Martin
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
This is neat!
On Sep 12, 2010, at 5:18 PM, Robert J. Hijmans wrote:
You have not said what type of objects you want, but here's one option: library(raster) s <- stack(list.files(pattern='*.tif')) Robert On Sun, Sep 12, 2010 at 10:29 PM, Martin Brandt <martin_brandt at gmx.net> wrote:
a simple question: how can I automatically import a huge bunch of rasters (Geotiffs) to R? With a for loop? I didn't find how to do that in the docs.. Each variable name should be the original raster name, but that's not important. greets, Martin
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Martin, Depending on what you are doing, you may want to consider the use of GRASS GIS (http://grass.osgeo.org/) in combination with R. This has been a successful strategy for me in the past, not using Geotiffs, however. The advantage is that the Geotiffs can be imported into GRASS GIS format in batch form and then using r.mapcalc within GRASS, nearly any map algebra calculations are possible without running into memory issues that you may encounter with R alone. Regards, Tom
On 9/12/10 4:29 PM, Martin Brandt wrote:
a simple question: how can I automatically import a huge bunch of rasters (Geotiffs) to R? With a for loop? I didn't find how to do that in the docs.. Each variable name should be the original raster name, but that's not important. greets, Martin
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: thomas.adams at noaa.gov VOICE: 937-383-0528 FAX: 937-383-0033
This is a great solution, thanks everyone! -----Urspr?ngliche Nachricht----- Von: Robert J. Hijmans [mailto:r.hijmans at gmail.com] Gesendet: Sonntag, 12. September 2010 23:18 An: Martin Brandt Cc: r-sig-geo at stat.math.ethz.ch Betreff: Re: [R-sig-Geo] mass importing rasters You have not said what type of objects you want, but here's one option: library(raster) s <- stack(list.files(pattern='*.tif')) Robert On Sun, Sep 12, 2010 at 10:29 PM, Martin Brandt <martin_brandt at gmx.net> wrote:
a simple question: how can I automatically import a huge bunch of rasters (Geotiffs) to R? With a for loop? I didn't find how to do that in the docs.. Each variable name should be the original raster name, but that's not important. greets, Martin
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo