topojson / topojson

An extension of GeoJSON that encodes topology! 🌐
Other
4.69k stars 670 forks source link

--simplify-proportion destroys countries #275

Closed lucaspiller closed 8 years ago

lucaspiller commented 8 years ago

I'm using the NaturalEarth dataset to generate TopoJSON for use with Datamaps. I'd like to keep the file small so that the load on the browser isn't too high, but also keep enough detail so it's possibly to identify small countries.

Here is how I'm generating the data:

$ topojson --simplify-proportion 0.1 --id-property=ISO_A3 -p name=NAME -o world.topo.json world=ne_10m_admin_0_countries.shp

Here is what the Maldives looks like at the various proportions:

0.5:

screen shot 2016-02-10 at 16 00 47

0.3:

screen shot 2016-02-10 at 16 01 19

0.1:

screen shot 2016-02-10 at 16 01 40

At 0.1 it's completely gone - it doesn't even exist in the file, it's not just empty.

Is it possible to simplify more complicated arcs further (e.g. Canada), before deciding to remove small countries?

mbostock commented 8 years ago

From the command line reference:

Normally topojson does not include null and empty objects in the output topology. These can arise either because they were present in the input, or as a result of quantization or simplification. Use the --filter=none argument to retain empty and null features. (Null geometry objects in TopoJSON have an undefined type, as described in the specification.) Use --filter=small if you want small rings that are attached to other rings to be removed; the default filter behavior, --filter=small-detached, only removes small rings that are not attached to other polygons, such as islands.

So, use --filter=none to prevent the islands from being removed.

Simplification treats everything equally based on the simplification metric (Visvalingam’s). So, if these islands were removed before a point in a Canadian arc, it’s because they are smaller than the corresponding triangle in the Canadian arc. However, note that if the topology is messy, then sometimes the simplification is not allowed to remove points because it would change the topology. You may be able to fix this problem by changing quantization settings, or by finding cleaner source data.