Skip to content

Exporting Multipolygon geojson with rgdal::writeOGR

3 messages · Roger Bivand, Andy Teucher

#
Hi Roger,

Sorry I haven't been much help here - it's not for lack of trying,
just lack of skills. I've been poring through OGR_write.cpp and trying
to figure out language and the flow of things... a few thoughts
occurred to me (which are probably obvious to you):

1) Is this bug because holes are standalone polygons in sp objects,
while they are members of polygon objects in geojson, wkt, etc?

2) On a related note, I notice that a single polygon with a hole is
identified as a multipolygon containing a single polygon with a hole,
when using writeOGR and one of the affected drivers.  Practically I
don't think this matters too much, but it's not quite right.

3) In lines 116-160 the polygon/multipolygon and line/multiline
determination is made for the entire layer. Can/should this be made
for each feature in the layer, as you could have a layer with a
mixture of single polygons and multipolygons?

4) I feel like there ought to be one more layer of looping through the
polyons. e.g.:

loop over each feature;
     determine whether each feature is a single polygon (length 1 or
all rings but one are holes), or a multipolygon:
        if a polygon loop over and add ring(s);
        if a multipolygon loop over polygons:
            for each polygon add ring(s) and somehow assign holes to
parent polygons

Again, apologies if I'm being totally obvious (or way off base).
Thanks for all your work on these packages, and on this issue.

Andy
On Thu, Oct 22, 2015 at 11:07 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
#
On Mon, 26 Oct 2015, Andy Teucher wrote:

            
Thanks, Andy.

We're making some progress but are not yet there. I'm uncertain about 
whether a layer can have Polygon and MultiPolygon features, but we've 
found an OGR function that aims to organise rings for which their 
exterior/interior status is not well known. This passes back the 
appropriate class, bur we then force it to MultiPolygon if any object is a 
MultiPolygon. When we have something to test, we'll get back to you.

Best wishes,

Roger

  
    
#
Fantastic, thanks Roger. I will follow along in the r-forge repository.

Andy
On Mon, Oct 26, 2015 at 3:59 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote: