[R-sig-Geo] Spatial Resampling
Tomislav Hengl
T.Hengl at uva.nl
Mon Jul 28 18:38:14 CEST 2008
You can also try RSAGA. It is very fast and handy to up-scale large grids (it is perfect to automate
processing), and you only need to define the new grid cell size and the up/down-scaling method:
> library(RSAGA)
# Download SAGA GIS from www.saga-gis.org and unzip the binaries to:
rsaga.env(path="C:/Program Files/saga_vc")
# first, convert to the SAGA format:
> rsaga.esri.to.sgrd(in.grids="image12m.asc", out.sgrds="image12m.sgrd", in.path=getwd())
# now resample to 18 m grid resolution using the bilinear resampling:
> rsaga.get.usage(lib="grid_tools", module=0)
> rsaga.geoprocessor(lib="grid_tools", module=0, param=list(INPUT="image12m.sgrd",
GRID="image18m.sgrd", METHOD=1, DIMENSIONS_CELLSIZE=18, SCALE_UP_METHOD=1))
# convert back to ESRI format:
> rsaga.sgrd.to.esri(in.sgrds="image18m.sgrd", out.grids="image18m.asc", out.path=getwd(), prec=1)
The resampling methods implemented in SAGA (see GRID > Tools > Construction > Resampling) are
available using the "rsaga.get.usage(lib="grid_tools", module=0)":
-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
Tom Hengl
http://spatial-analyst.net
-----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
adrian at maths.uwa.edu.au
Sent: vrijdag 25 juli 2008 4:00
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] Spatial Resampling
Pujan Raj Regmi <regmi_pujan at hotmail.com> writes:
> I have a satellite image of 12m spatial resolution (4 bands). I want to
> resample to coarser level. i.e. to 18m, 24m,30m,36m and so on.
> The result I got from ENVI are not realistic so I want to do it in R
> using weighted average from neighboring pixels.
In package 'spatstat' the function 'blur' will perform spatial averaging
of a pixel image, using Gaussian weights. The function 'as.im' can be used
to change the dimensions of a pixel image.
So for example if Z is a pixel image (object of class "im") then
old.pixelsize <- Z$xstep
blurZ <- blur(Z, 1.5 * old.pixelsize)
old.dim <- Z$dim
new.dim <- floor(old.dim/2)
Y <- as.im(blurZ, dimyx=new.dim)
computes a Gaussian kernel-weighted average of pixel values, then
subsamples the image.
Adrian Baddeley
_______________________________________________
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