3

I have huge geojson file that I am working on:

[{
        "geometry": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [-122.317273801854, 47.6190539780876],
                        [-122.317274348118, 47.6190828843557],
                        [-122.317292412364, 47.6190827204113],
                        [-122.317293657623, 47.6191487985433],
                        [-122.317278082047, 47.6191489300374],
                        [-122.317278784338, 47.6191861453792],
                        [-122.317169984271, 47.6191870880631],
                        [-122.317169940562, 47.6191850459535],
                        [-122.317086827577, 47.6191857617427],
                        [-122.317085902845, 47.6191365192538],
                        [-122.317071510628, 47.6191366437151],
                        [-122.31707075927, 47.6190968289847],
                        [-122.317087362271, 47.6190966841237],
                        [-122.317086589249, 47.6190556005469],
                        [-122.317273801854, 47.6190539780876]
                    ]
                ]
            ]
        },
        "type": "Feature",
        "properties": {
            "shape_area": 2396.7925901799999
        }
    }, {
        "geometry": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [-122.317399793439, 47.6193250237895],
                        [-122.317268032808, 47.6193260666162],
                        [-122.317267907013, 47.6193188900984],
                        [-122.317235727754, 47.6193191468267],
                        [-122.317235835777, 47.6193252636292],
                        [-122.317202753366, 47.6193255237007],
                        [-122.317202683689, 47.6193211879516],
                        [-122.317165343647, 47.6193214866782],
                        [-122.31716542561, 47.6193262532654],
                        [-122.317106308653, 47.6193267179723],
                        [-122.317104513919, 47.6192236738067],
                        [-122.317170427418, 47.6192231555825],
                        [-122.317170486246, 47.6192266013983],
                        [-122.317202638424, 47.6192263436369],
                        [-122.317202504834, 47.6192183838426],
                        [-122.317232834592, 47.619218149834],
                        [-122.317232910156, 47.6192226918802],
                        [-122.317270835738, 47.619222395323],
                        [-122.317270712945, 47.6192148144418],
                        [-122.317306203271, 47.6192145313754],
                        [-122.317306260026, 47.6192179042152],
                        [-122.317397927553, 47.6192171763912],
                        [-122.317399793439, 47.6193250237895]
                    ]
                ]
            ]
        },
        "type": "Feature",
        "properties": {
            "shape_area": 2752.8221201699998
        }
    }, {
        "geometry": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [-122.317115538357, 47.6194422596203],
                        [-122.317113899889, 47.6193992260741],
                        [-122.317134286447, 47.61939887043],
                        [-122.317133036969, 47.6193658360276],
                        [-122.317300816098, 47.6193629282286],
                        [-122.317302336577, 47.6194031302355],
                        [-122.31732481124, 47.6194027473298],
                        [-122.317325542627, 47.6194218364951],
                        [-122.317305340514, 47.619422179941],
                        [-122.317305978981, 47.619438958089],
                        [-122.317115538357, 47.6194422596203]
                    ]
                ]
            ]
        },
        "type": "Feature",
        "properties": {
            "shape_area": 1269.9362947300001
        }
    }]

I am trying to plot this data; I tried many libraries/ways to plot it.

But every time I receive an error saying:

ValueError("No JSON object could be decoded")

Is there any way to plot geojson data? I have used D3/Leaflet before. I succeeded to plot this file.

3
  • 2
    You say you have plotted the data to D3/leaflet successfully. So what other type of format are you trying to "plot" the points to? A graphics file? A desktop GIS? Another GIS file format (ie- shapefile)? Mar 20, 2014 at 16:01
  • I wanna plot the file on desktop application using Python . Mar 21, 2014 at 2:09
  • 2
    You might give the Kartograph.py library a try. Mar 21, 2014 at 14:55

2 Answers 2

6

If you just want to plot the data in a desktop GIS software like QGIS, you need to make the data a "Feature Collection" as stated here:

Features in GeoJSON contain a geometry object and additional properties, and a feature collection represents a list of features.

Once I wrapped your GeoJSON code (above) with:

{"type":"FeatureCollection",
"features":

   <place your data as seen above here>

}

I had no problem loading the data into QGIS (tested).

2
  • Ryan's right. Your data wasn't valid.
    – sgillies
    Mar 22, 2014 at 20:38
  • 2
    Instead of QGIS you may also use geojson.io
    – linqu
    Jan 12, 2016 at 11:22
3

Welcome to GIS Stack Exchange!

You should try Shapely:

From the doc, Shapely can plot geoJson objects:

    import json
    from shapely.geometry import mapping, shape

    s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
    >>> s
    <shapely.geometry.point.Point object at 0x...>

    print(json.dumps(mapping(s)))
    {"type": "Point", "coordinates": [0.0, 0.0]}
2
  • 3
    But the result is not a map ?? Mar 20, 2014 at 13:23
  • the result is a grid Oct 3, 2017 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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