[R-sig-Geo] Mapping contours from jpg map

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Jul 8 16:05:42 CEST 2011

On Fri, Jul 8, 2011 at 2:26 PM, Robert Hijmans <r.hijmans at gmail.com> wrote:

> # now there are many ways to interpolate. See, e.g., the 'gstat' and
> 'automap' packages. See raster::interpolate for an example with splines.
> # using gstat and inverse distrance weighted interpolation:
> library(gstat)
> g <- gstat(id="level", formula = level~1, data=p, nmax=7, set=list(idp =
> .5))
> x1 <- interpolate(r, g)

Statistical interpolation techniques may be right for this, but
thinking about it last night made me realise that contours are more
than just linear estimates of height at location. There's the
implication that between any two contour lines of height H1 and H2
there are no locations with height outside the bounds of (H1,H2).
Otherwise there would be a contour line there.

 And this may not be so uncommon in elevation models. Consider a steep
sided valley with a wide flood plain. You have close contours on
either side with a big gap between. Would a "statistical"
interpolation run down the valley side and plummet on down, then back
up the other side, turning the flood plain into a deep rounded valley
bottom? Sure it all depends on the parameters of the smoothing, but a
method that knew it was dealing with contours would constrain the
surface such that points between contour lines were always between the
contour line values.

 I think at least one of the algorithms in GRASS-GIS does this by
"drawing" the contour lines on the raster and then doing a 'flood
fill' operation between them.

 I'll have to dig out some GIS books...


More information about the R-sig-Geo mailing list