0

Trying to convert my geoJSON file into topoJSON so

However, I got an error message:

> topojson -o prTopo.json prCounties.json
quantization: bounds NaN NaN NaN NaN (spherical)
quantization: maximum error 0.00m (0.00°)
prune: retained 0 / 0 arcs (NaN%)

The original output I have is all the municipalities of Puerto Rico which I collected on GitHub (Municipios). Here is an abridged version:

{"type": "FeatureCollection", 
"properties": {"kind": "state", "state": "PR"}, 
"features": [[
    {"geometry": { 
        "type": "MultiPolygon", 
        "coordinates": [[[[-65.4406, 18.1541], [-65.2763, 18.1322], [-65.4515, 18.0884], [-65.5775, 18.1048]]]]}, 
        "type": "Feature", "properties": {"kind": "county", "name": "Vieques", "state": "PR"}}]]
}

The output I got was

{"type":"Topology",
"transform":{"scale":[null,null],"translate":[null,null]},
"objects":{"prCounties":{"type":null,"properties":{"kind":"state","state":"PR"}}},
"arcs":[]}

I don't really understand the geoJSON or topoJSON specs, but it looks like the transform data comes out null and the arc data is null is empty.

4

Your input GeoJSON is invalid. Your feature collection has a doubly-nested features array:

{
  "type": "FeatureCollection",
  "properties": {
    "kind": "state",
    "state": "PR"
  },
  "features": [
    [
      {
        "type": "Feature",
        "properties": {
          "kind": "county",
          "name": "Vieques",
          "state": "PR"
        },
        "geometry": {
          "type": "MultiPolygon",
          "coordinates": [[[[-65.4406,18.1541],[-65.2763,18.1322],[-65.4515,18.0884],[-65.5775,18.1048]]]]
        }
      }
    ]
  ]
}

What you need is a singly-nested features array:

{
  "type": "FeatureCollection",
  "properties": {
    "kind": "state",
    "state": "PR"
  },
  "features": [
    {
      "type": "Feature",
      "properties": {
        "kind": "county",
        "name": "Vieques",
        "state": "PR"
      },
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [[[[-65.4406,18.1541],[-65.2763,18.1322],[-65.4515,18.0884],[-65.5775,18.1048]]]]
      }
    }
  ]
}

Which produces the following valid TopoJSON with default settings:

{
  "type": "Topology",
  "transform": {
    "scale": [0.000030123012301229557,0.000006570657065706536],
    "translate": [-65.5775,18.0884]
  },
  "objects": {
    "test": {
      "type": "GeometryCollection",
      "properties": {
        "kind": "state",
        "state": "PR"
      },
      "geometries": [{"type":"MultiPolygon","arcs":[[[0]]]}]
    }
  },
  "arcs": [[[4545,9999],[5454,-3333],[-5816,-6666],[362,9999]]]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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