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

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Jul 7 20:04:28 CEST 2011

>  I suspect there's a better way by looking at more than one nearby
> contour line and doing some interpolation....

 I've got fairly good algorithm going now, but it requires a bit of
modification of some sp package code.

 Currently spsample can return random or regular  points on a line,
but doesn't tell you which line the point came from. Hence there's no
way to get the height of that line.

 But a bit of tweaking to the sampling code fixes that. My
modification returns a spatial points data frame of points and line
IDs. I'll not post that code here yet because Roger usually knows ways
of doing my hacky things without hacking. I know that overlay() won't
do it for you...

 Anyway, then I can get a set of (x,y,height) points on the contour
lines, and then use any standard interpolation function (interp from
akima for example) to get a grid. Looks pretty good, and also pretty
quick. A 500x500 grid from a contour set with 212 contour lines is
pretty instantaneous.


More information about the R-sig-Geo mailing list