Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm following Mike Bostock's tutorial, let's make a map, but for a map of Mexico. I want to display state boundaries.

I was able to get the map of Mexico from Natural Earth Data's world maps. My source for the state boundaries is here:

NOTE: this should be the same file as here, but INEGI's server seems to be down for days. I was able to convert it from ogr2ogr into geojson. When you convert from geojson into topojson, this notice comes up:

duopixel$ topojson -s 5 -o estados_simp.json -- estados.json
quantization: maximum error 78.607km (0.707°)
simplification: retained 1130 / 454450 points (0%)

It still seems to generate the file and it looks like it's correct. This is the file it generates. This is my javascript code:

d3.json("estados.json", function(error, mex) {

  var estados = mex.objects.estados.geometries

    .attr("class", "estado")
    .attr("d", path)

However, I get an error when running this code...

Uncaught TypeError: Cannot read property 'length' of undefined 

Now, since I'm not even sure what I'm doing, I have no idea where the failure point is. I'm stuck at this point and any help is appreciated.

share|improve this question
Careful with the -s argument; it takes an area threshold in steradians. A value of 5 steradians is about 40% of the surface of the sphere, which is why it only retained 0% (1130 / 454450) of the input points. For a map of Mexico, you probably want something closer to 1e-8. Alternatively, use --simplify-proportion and specify a value between 0 and 1. See the command line reference for details. – mbostock Mar 10 '13 at 15:49

It was a mistake on my javascript code, I wasn't unpacking the data with the clientside topojson...

d3.json("estados.json", function(error, mex) {
  var estados = topojson.object(mex, mex.objects.estados);

    .attr("class", "estado")
    .attr("d", path);
share|improve this answer

Your Answer


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.