How can I parse GeoJSON with Python

走远了吗. 提交于 2019-12-01 20:48:28

You can read it like any json:

import json
data = json.loads(datastring)
data['features'][0]['geometry'] #Your first point
import geojson
with open(path_to_file) as f:
    gj = geojson.load(f)
features = gj['features'][0]

You can also use geopandas:

import geopandas as gpd
earthquake = gpd.read_file('earthquake.geojson')
print(earthquake.head())

You can read it with json import, and file open:

import json
with open(path) as f:
    data = json.load(f)
for feature in data['features']:
    print(feature['properties'])

You can use pandas library directly

import pandas as pd
data = pd.read_json('File.geojson')

The important this is to understand the structure of this json file and manipulate the dictionaries in there

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!