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

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


On Thu, Jul 7, 2011 at 5:25 PM, Sarah Papworth
<sarah.papworth06 at imperial.ac.uk> wrote:
> Dear all,
>
> I have a jpg map of altitudinal contours in my study area which I
> would like to map and use in R to calculate the altitude and slope of
> GPS coordinates.
> So far, I have painstakingly traced these contours in ArcMap to create
> a shapefile (of polylines) with altitude. I have now imported this
> file shapefile into R.
>
>  What I would like to do is turn it into a raster of slope and
> altitude, but I can't seem to find any method of doing this in the
> online R help archives. Does anyone have any idea which package I
> should be using, or perhaps if it is even possible to turn this type
> of shapefile into a raster?

 There's definitely tools for doing this in GRASS-GIS:

http://linfiniti.com/2010/12/3d-visualisation-and-dem-creation-in-qgis-with-the-grass-plugin/

 but not sure about R. One approach might be:

 load shapefile into R as a SpatialLinesDataFrame, so that each line
has its height attribute.

 consider a grid of points over the space, and use rgeos functions to
find the nearest contour line and its height. Assign height to that
grid point.

 That will give you a grid that will look a bit like terraces between
the contours, which you could possibly then smooth, although there may
be systematic errors with this method...

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

Actually the GRASS algorithms are discussed here:

http://grass.osgeo.org/wiki/Contour_lines_to_DEM

Barry



More information about the R-sig-Geo mailing list