[R-sig-Geo] Convert SpatialGridDataFrame to polygons...?

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Jul 15 13:28:14 CEST 2010

Dear list,

I have been given a set of ASCII grids which I read into R using
readAsciiGrid(). The grids represent an interpolated water depth data
set for a set of lakes; each grid represents a separate lake. For some
reason I have been asked to convert this gridded data into a set of
polygons. For example; given the gridded data, I want to generate a
polygon that covers the area of the lake (from the grid) that is 1-2m
deep say. I would then need to write out this polygon as an ESRI shape

Are there tools in R to do this sort of conversion?

It is a bit more complex that the simple example, as lakes can have
multiple basins (areas of deeper water). Say a lake has two deep areas
so a cross section through the lakes might look like a W, for such a
lake I would require an object that contained two polygons representing
the area of the lake between 4 and 5 meters say in *each* of the basins.
These would then be read out into a shape file. My GIS colleague
indicates that ArcGIS/ArcMAP has a function to polygonise a raster grid
in such a way. Is there something similar in the R spatial software

An alternative approach would be to contour (at appropriate depth
intervals) the interpolated grid and convert the set of contours into
polygons for individual lakes. Is there a function to do this?

As you can see, this is very much a look-see at the moment. We are
evaluating whether it would be quicker to work out how to do this in R
as opposed to doing it by hand in ArcGIS.

Any suggestions would be most gratefully received indeed!

All the best,

 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk

More information about the R-sig-Geo mailing list