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

Crowe, Andrew a.crowe at lancaster.ac.uk
Thu Jul 15 17:08:34 CEST 2010


Gavin
 
Gavin
 
You can convert the raster grid to a polygon grid by coercing the SpatialGridDataFrame to a SpatialPixelsDataFrame then from that to a SpatialPolygonsDataFrame.
 
You should then be able to recode the polygon data for each particular depth class and union them using unionSpatialPolygons.  This then needs joining with a data frame created from the depth classes to create a SpatialPolygonsDataFrame for output to a shapefile using writePolyShape
 
Hope that helps
 
Andrew
 
Dr Andrew Crowe
 
Lancaster Environment Centre
Lancaster University
Lancaster    LA1 4YQ
UK
 
Tel: +44 (0)1524 595879

________________________________

From: r-sig-geo-bounces at stat.math.ethz.ch on behalf of Gavin Simpson
Sent: Thu 15/07/2010 12:28 PM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] Convert SpatialGridDataFrame to polygons...?



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
file.

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
stack?

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,

Gavin
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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 <http://www.freshwaters.org.uk/> 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

_______________________________________________
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