Search code examples
pythonjsonpandasdataframegeojson

Opening too big geojson file on jupyter notebook


I am using open dataset, basically I download data, unzip it (about 250 MB after unzip) and using code below.

The data consist of 83322 villages across Indonesia, basically I'm OK to open the data partially, for example first 5000, etc.

import ast
with open('indonesia_villages_border.geojson') as myfile:
    data = ast.literal_eval(myfile.read())

The kernel appears to have died. It will restart automatically. It's probably because the data is too big.

Is there's any ways to open, I'm fine with querying etc.


Solution

  • import json
    import pandas as pd
    with open('indonesia_villages_border.geojson') as fo:
        data_str = fo.read()
    data = json.loads(data_str) 
    df = pd.DataFrame(data)