[R-sig-Geo] interp from Akima and smooth
Tomislav Hengl
T.Hengl at uva.nl
Mon Oct 13 17:17:52 CEST 2008
Funnily enough the most flexible surface generator that I know is the kernel gaussian smoother, as
implemented in spatstat package:
> library(spatstat)
> library(maptools)
> data(meuse)
> str(meuse$lead)
> bubble(meuse, "lead")
> coordinates(meuse) = ~x+y
> lead.ppp <- as(meuse["lead"], "ppp")
> lead.dens <- density.ppp(lead.ppp, sigma=120, weights=meuse$lead)
> image(lead.dens)
> plot(meuse, pch="+", add=T)
This gives you a weighted density of sampled values, hence the values will change depending on the
sigma parameter and grid topology. Note that you can also detect the smoothing parameter
objectively, which means that you could automate the whole procedure. The author of stapstat makes
it clear (http://www.csiro.au/resources/pf16h.html), however, that the such (meuse) data should not
be treated as a point process (lead in soil is obviously not a point process but an underlying
continuous field) but instead analyzed using geostatistical techniques e.g. gstat:
> data(meuse.grid)
> gridded(meuse.grid) = ~x+y
> lead.smooth <- krige(lead~x+y+x^2+y^2, meuse, meuse.grid, nmax=10)
> spplot(lead.smooth[1])
You could also try running the Thin Plate Splines as implemented in SAGA GIS:
> library(rgdal)
> library(RSAGA)
> rsaga.get.usage("grid_spline", 1)
> writeOGR(meuse["lead"], "lead.shp", "lead", "ESRI Shapefile")
> rsaga.geoprocessor(lib="grid_spline", module=1, param=list(GRID="lead.sgrd", SHAPES="lead.shp",
FIELD=0, RADIUS=sqrt(areaSpatialGrid(meuse.grid))/3, SELECT=1, MAXPOINTS=20, TARGET=0,
USER_CELL_SIZE=meuse.grid at grid@cellsize[[1]], USER_X_EXTENT_MIN=meuse.grid at bbox[1, 1],
USER_X_EXTENT_MAX=meuse.grid at bbox[1,2], USER_Y_EXTENT_MIN=meuse.grid at bbox[2,1],
USER_Y_EXTENT_MAX=meuse.grid at bbox[2,2]))
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
Mikael Carlsson
Sent: Monday, October 13, 2008 2:54 PM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] interp from Akima and smooth
Hi,
Been testing interp from akima package but I wish more possibility to
influence
smoothness and also how many surrounding points that are considered in
each interpolated point.
Someone who has a tip on a good function?
/Mikael
[[alternative HTML version deleted]]
_______________________________________________
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