0

I am working to resize the json file that I have automatically after reading json file. But I am getting errors.

$.getJSON("data/cities.json", function (data) {
        getData = topojson.feature(data, data.features);
        console.log( getData)
    });

Cities.json look like

{
 "type": "FeatureCollection",
 "features": [{
     "geometry": {
         "type": "MultiPolygon",
         "coordinates": [
             [
                 [
                     [-73.8283219965448, 40.8446061654002],
                     [-73.828397789942, 40.844583182304],
                     [-73.8285477331865, 40.8448132168025],
                     [-73.8284744943625, 40.8448401137412],
                     [-73.8283219965448, 40.8446061654002]
                 ]
             ]
         ]
     },
     "type": "Feature",
 , {
     "geometry": {
         "type": "MultiPolygon",
         "coordinates": [
             [
                 [
                     [-73.832361912256, 40.8488019205992],
                     [-73.832369554769, 40.8487286684528],
                     [-73.8327312374341, 40.8487518102579],
                     [-73.8327304815978, 40.8487590590352],
                     [-73.8327235953166, 40.8488250624279],
                     [-73.832361912256, 40.8488019205992]
                 ]
             ]
         ]
     },
     "type": "Feature"
 } 


}

How can I load json data using getJSON then pass it to topojson

olly_uk
  • 11,559
  • 3
  • 39
  • 45
user3378649
  • 5,154
  • 14
  • 52
  • 76

1 Answers1

2

GeoJSON and TopoJSON are two different formats. You cannot use TopoJSON functions to process GeoJSON. You need to convert the GeoJSON you have to TopoJSON (see the commandline reference) and then load that.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
  • Can I convert GeoJSON to TopoJSON automatically inside code, I am updating the geojson every 12 hours. That's why I need to automate this process. The reason I want to convert to TopJSON is to reduce the size of this file (>300 mb) – user3378649 Mar 31 '14 at 15:09
  • There's no point in converting to TopoJSON in Javascript once you have transferred the data already. – Lars Kotthoff Mar 31 '14 at 15:16