Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

100% Newbie. I've been following Mike's d3 Map Tutorial and I've come up against a challenge. I guess my question essentially boils down to: how does one generate the proper GeoJSON/TopoJSON files which allow one to combine the Natural Earth data from ne_110m_land along with Admin 0 – Boundary Lines and Admin 1 – States, Provinces?

I think there's some sort of trick I'm missing for thematic maps. (I guess that's also why Mike may have not covered that in the intro article).?

Thanks!

Seemant

share|improve this question
    
you should turn your last comment on James' comment answer into an answer of its own. It's perfectly ok (and expected) to post your own answer if it is still "the best answer" for you. –  RyanDalton Jan 28 '13 at 5:00
add comment

3 Answers

up vote 2 down vote accepted

The short answer to your question is:

topojson \
    -o world-110m.json \
    -- \
    land=ne_110m_land.shp \
    states=ne_110m_admin_1_states_provinces.shp

This will produce a topology with "land" and "states" objects. You can omit the land= and states= if you'd prefer the objects to have the file names instead.

However, a couple gotchas to be aware of:

  • The Natural Earth 1:110M dataset for only includes the United States in the Admin 1 — States, Provinces download. The 1:50M resolution download adds Canada to this set, and the highest-resolution 1:10M download includes the entire world. So, if you want to make a world map, you’ll currently need the 1:10M dataset, which you can then simplify as desired. (Though the automatic simplification provided by topojson won’t be as good as the hand-tweaked simplification done by Kelso et al. at Natural Earth.)

  • Only the 1:10M Natural Earth dataset is currently topologically-consistent. This means that there will be some cases where the borders won’t match up exactly between adjacent features in the 1:50M and 1:110M datasets. In practice, this usually isn’t a big problem, but it can prevent some topological algorithms from working perfectly, such as simplification and map coloring. So again, you may need to start with the 1:10M dataset and simplify.

Use additional options to topojson to customize the generated TopoJSON file, such as including properties, increasing the quantization factor to improve accuracy, and enable simplification. There are many examples of converting Natural Earth data to TopoJSON in the world-atlas repository. See the Makefile for details if you want to customize how the TopoJSON is generated (e.g., combine different files, modify properties, change simplification thresholds). And lastly see the topojson command-line reference for an overview of all the available options.

share|improve this answer
add comment

Taking @RyanDalton's advice I'll answer my own question here: use topojson's -s (or -q flag). In my case, the shape and topography got nicely simplified when I issued topojson with `-s 0.00005'

share|improve this answer
add comment

Did you see the precooked geojson natty earth here? https://github.com/jsongeo

share|improve this answer
    
Thanks for your response, James. I did, indeed, use that precooked one for a PoC, however, it's at 10m, so way too detailed/big for my use case. My end goal is to have a much less detailed coastline, but along the way I also want to learn how to cook those kinds of files. –  Seemant Kulleen Jan 28 '13 at 0:16
    
I used FME to create them. I could creat some 50m or 100m versions as well. You could also use OGR to convert. –  James Fee Jan 28 '13 at 3:31
1  
As it happens, I just discovered topojson's -q and -s flag. -s 0.00005 did exactly what I needed. –  Seemant Kulleen Jan 28 '13 at 4:21
add comment

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.