Skip to content
Prev 9026 / 29559 Next

Convert SpatialGridDataFrame to polygons...?

On Thu, 2010-07-15 at 21:06 +0200, Roger Bivand wrote:
A little belatedly as I didn't get chance to work through the
suggestions from Andrew and Roger before I had to leave for an extended
fieldwork trip that I have just returned from...

Thanks Roger and Andrew for your suggestions. Roger asked me to let you
know how I got on, so here goes.

Roger's solution was what I had in mind when I was thinking how to do
things. And it worked nicely for some of the sites I needed to apply
this to. But for most sites it didn't work because many of the contour
lines produced from the grid were open lines, not closed lines. I view
this as a feature of the data I had to do this for (lake bathymetry data
where we don't have an accurate lake outline (0m depth) or indeed for
some sites even data over the entire lake).

I next tried Andrew's suggestion and this worked for all the sites I
needed to apply it to as it basically turns the grid into a series of
polygons and we then union the cell polygons that belong to same depth
interval. The only downside is that, as Roger mentioned, it produces
"jagged" sets of polygons, and these polygons are quite complex; some
depth classes are represented by numerous individual polygons
representing single pixels in the original grid. C'est la vie.

Finally, I've begun using the sp stack and related packages more and
more recently and I now have a reasonable working feel for what can be
done and how to achieve some fairly complex (for me, anyway) results. I
have been struck by how powerful and easy to use all this is. This is
due to the authors and maintainers of the various spatial R packages. As
it is easy to overlook this fact when deadlines loom etc; here's a BIG
thank you to you all, from me, for all the hard work!

G