[R-sig-Geo] resampling grids
Tomislav Hengl
T.Hengl at uva.nl
Thu Dec 11 10:00:23 CET 2008
A quick way to rescale a set of maps is to use the grid tools of SAGA GIS (see
rsaga.get.usage("grid_tools", 0)). First, download all ASCII file maps to a working directory, then
obtain the list of maps in the folder, and then automate:
> ascmaps <- list.files(getwd(), pattern="\\.asc$", full=F)
> levels(ascmaps) <- list.files(getwd(), pattern="\\.asc$", full=F)
> ascmaps500 <- ascmaps
> levels(ascmaps500) <- paste("500m",levels(ascmaps),sep="")
> library(RSAGA)
> rsaga.esri.to.sgrd(in.grids=levels(ascmaps),
out.sgrds=set.file.extension(levels(ascmaps),".sgrd"), in.path=getwd())
> rsaga.get.usage("grid_tools", 0)
> for (i in 1:length(ascmaps)) {
rsaga.geoprocessor(lib="grid_tools", module=0,
param=list(INPUT=set.file.extension(levels(ascmaps)[i],".sgrd"),
GRID=set.file.extension(levels(ascmaps500)[i],".sgrd"), METHOD=0, DIMENSIONS_CELLSIZE=500,
SCALE_UP_METHOD=1))
}
> rsaga.sgrd.to.esri(in.sgrds=set.file.extension(levels(ascmaps500),".sgrd"),
out.grids=set.file.extension(levels(ascmaps500),".asc"), out.path=getwd(), prec=1)
> unlink("*.hgrd") # delete the temporary files (SAGA)
> unlink("*.sgrd")
> unlink("*.sdat")
Note that you only need to set the resolution of the output maps and/or the rescaling method:
-SCALE_UP_METHOD:<num> Interpolation Method
Choice
Available Choices:
[0] Nearest Neighbor
[1] Bilinear Interpolation
[2] Inverse Distance Interpolation
[3] Bicubic Spline Interpolation
[4] B-Spline Interpolation
[5] Mean Value
-SCALE_DOWN_METHOD:<num> Interpolation Method
Choice
Available Choices:
[0] Nearest Neighbor
[1] Bilinear Interpolation
[2] Inverse Distance Interpolation
[3] Bicubic Spline Interpolation
[4] B-Spline Interpolation
Mechanical down-scaling from 20 to 10 m is certainly doable but you will be 'cheating' right?
More stuff on this topic (downscaling) in e.g.:
Marc F. P. Bierkens, Peter A. Finke, P. de Willigen, 2000. Upscaling and Downscaling Methods for
Environmental Research. Springer, ISBN 0792363396, 9780792363392, 190 pages.
http://www.amazon.com/gp/reader/0792363396/
Tom Hengl
http://spatial-analyst.net/wiki/index.php?title=Software
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of
Jason Gasper
Sent: Wednesday, December 10, 2008 7:23 PM
To: Dave Depew
Cc: r-sig-geo at stat.math.ethz.ch
Subject: Re: [R-sig-Geo] resampling grids
Hello David,
I am not sure I completly understand what you want to do, but Hawths
tools (a free add in for arcMAP) has a resampling function that may be
of use: http://www.spatialecology.com/htools/rndselss.php. Spatial
analyst also has some resampling functions. If you have access to ESRI
you could read the data into R using the maptools. package.
Dave Depew wrote:
> Hi all,
> I apologize in advance, I haven't the time today to comb the help list
> for tips and hints, but does anyone know how to resample a 20 by 20m
> grid so the operational spacing is down to a 10 by 10m grid?
> Any assistance is MUCH appreciated!
>
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list