topojson / topojson-client

Manipulate TopoJSON, such as to merge shapes, and convert it back to GeoJSON.
ISC License
213 stars 63 forks source link

topomerge can't deduplicate geometries #16

Open jstcki opened 7 years ago

jstcki commented 7 years ago

I expected topomerge to be able to deduplicate geometries but it didn't work:

topomerge -k 'd.id' < foo.json

Geometries come out like this:

{"type":"MultiPolygon","arcs":[[]],"id":"1"}
// etc.

As a workaround I used ndjson-reduce 'p[d.id] = d, p' '{}' | ndjson-split 'Object.values(d)' on the GeoJSON features first.

mbostock commented 7 years ago

Right—that’s not how topojson.merge (topomerge) works. It expects the input to be topologically-consistent and non-overlapping. Could probably be documented better, though.

aubergene commented 6 years ago

I might have been having a different issue, but it sounds similar it's quite nuanced describing the differences. I had two shapefiles which shared a border, but when I merged them into the same topojson file the borders didn't match up despite them being very similar. The fix was that I was doing the quantization after conversion to topojson, when you need to do at the point you load both files. I hope this is correct and helpful to other people.

geo2topo -q 1e5 -n nuts=raw/ndjson/nuts.ndjson