Folium Choropleth + GeoJSON raises AttributeError: 'NoneType'

后端 未结 2 1477
我在风中等你
我在风中等你 2020-12-18 06:47

I\'m trying to do a choropleth using folium which offers a great link between GeoJSON, Pandas and leaflet.

GeoJSON format is like below :

{
  \"type         


        
2条回答
  •  别那么骄傲
    2020-12-18 07:50

    There were 2 problems :

    1 - The correct access to 'insee' parameters is : key_on='feature.properties.insee'

    The best way to find the right key_on is to play with the geoJSON dict to make sure you are calling the right properties.

    2- Once you have the right key_on parameters, you need to make sure that all the available keys in the geoJSON are contained in your Pandas DataFrame (otherwise it will raise a KeyError)

    In this case, I used the following command line to get all the insee keys contained by my geoJSON:

    ogrinfo -ro -al communes-20150101-100m.shp -geom=NO | grep insee > list_code_insee.txt
    

    If you are experiencing the same issue, this should solve your problem.

提交回复
热议问题