0

I'm trying to build a choropleth map, I cannot figure out why I get this error:

AttributeError: 'NoneType' object has no attribute 'get'

Here is my code:

station_nb is a dataframe with values grouped by c_ar

geop = r'arrondissements.geojson'    
map.choropleth(
    geo_data =geop,
    name='choropleth',
    data = station_nb,
    columns = ['c_ar','count'],
    key_on='features.properties.c_ar',
    fill_color='YlOrRd', 
    fill_opacity=0.7, 
    line_opacity=0.2
)

When I check the contents of GeoJSON file key looks ok and I get the 20 expected values:

json.load(open(geop))['features'][7]['properties']['c_ar']

geop is as follows:

{'type': 'FeatureCollection',
 'features': [{'type': 'Feature',
   'geometry': {'type': 'Polygon',
    'coordinates': [[[2.351518483670821, 48.8644258050741],
.........
  'l_aroff': 'Bourse',
    'c_arinsee': 75102,
    'c_ar': 2}},

Could you help me to understand this issue?

  • It doesn't seem like the code that generates that error is in the question. – Vince Jun 29 at 12:37
  • 1. Please include the entire error, not just the last line. 2. Your GeoJSON looks wrong, where is the "properties": { key?, please include an entire valid GeoJSON FeatureCollection with a single feature so we can test. – user2856 Jul 1 at 3:03
  • Thank yo for your answer, here the entire geojson file:github.com/sbenoist/Examples/blob/master/… – srmel Jul 2 at 5:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.