Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove a line from the 110m TopoJson world map?

I have created a map using D3 with the 110m world map and the mercator projection. I rotated the map by -10 degrees to get it lined up how I want then set the stroke and fill. After doing this I noticed that there is a line through the Chukchi Peninsula (the bit that is often found to the left of Alaska).

Chukchi Peninsula

Reviewing the rendering on GitHub and also another map made with this projection, it seems like this line is actually in the data.

Rendering from GitHubAnother example

Is there any way to get rid of it (editing the TopoJSON, re-generating it the shape, or some other means)?

like image 805
Luke Francl Avatar asked Sep 27 '13 01:09

Luke Francl


1 Answers

For now, you need to fix your data by hand, say by editing the TopoJSON directly, or by converting the Shapefile to GeoJSON and then doing a similar edit, or by using a Shapefile editor.

In the future, the topojson command-line tool should be able to fix this for you by stitching together polygons that cross the antimeridian (±180° longitude), removing antimeridian cuts that are often present in currently-available geometry.

It’s already the case that topojson removes antimeridian cuts. However, currently it can only remove antimeridian cuts within a single ring, and here the Russia polygon has been split into two (or more) rings where it crosses the antimeridian; topojson is not yet smart enough to stitch multiples rings cut at the antimeridian back into a single ring. (You might be able to use topojson.mesh to do this, however.)

As for why the antimeridian cuts are there in the first place: many geo tools don’t fully support spherical coordinates, so it’s common to find data that cuts polygons along the antimeridian to prevent visual artifacts from appearing when projecting. (You can read about antimeridian cuts in my For Example talk.) D3 and topojson use true spherical coordinates with great-arc interpolation between points, so that you can represent polygons that surround poles or cross the antimeridian without cuts. However, because most existing data is precut at the antimeridian, topojson must remove the cuts to restore the true spherical geometry.

like image 141
mbostock Avatar answered Oct 28 '22 20:10

mbostock