Saturday, 30 December 2017

mapshaper - How to -explode only one subfeature from only one feature?


I have a topojson which treats French Guiana as part of the "France" feature (therefore also, part of the Western Europe layer). To match my dataset, I want to split this out from France, while keeping Corsica as part of France:



enter image description here


On browsing the Mapshaper docs, -explode looks like my best bet. But there are a few problems:



  • It explodes out every multi-part feature in a layer, and there doesn't seem to be any way to limit it to just one feature or field value: target= is layers only. This isn't a huge problem for me in this particular example, as for this data the other features on this layer aren't multi part and I could temporarily move it onto a dummy layer, but I'll also need to do this with a variant where there are other multi-part features on the layer and the dummy layer workaround is rather clumsy (I'd like to preserve the order of the features in the layers if possible), so if there is a way to specify the target feature that would be useful.

  • It explodes all the parts of the feature, and there are two problems here:

    • The obvious way to recombine them, -dissolve or -dissolve2, in my experience seems to require the features to be touching or overlapping.

    • If I can get around that, another difficulty with -dissolve is that I would need to specify Corsica but not French Guiana using field data, but after exploding they get identical field data to the original feature (France). This technique using MapShaper's internal feature ID is a possibility here, not tried it in this context yet





So:



  • Is there a simpler, cleaner workflow for this general case than moving "France" to a dummy layer, exploding the dummy layer, then trying to dissolve Corsica back into France?

  • If no, how can I reliably dissolve Corsica back into France when they don't touch or overlap?




Please, no puns like "Can Mapshaper do this? Of Cors-i-can!"...




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...