How to add geojson file for border in Folium in python?

571 views Asked by At

I am trying to draw borders in folium in python by using a geojson but I have an error. What is wrong?

import folium
from folium import plugins
  .
  .
bordersStyle={
color': 'black',
weight': 2,
fillColor': 'blue',
fillOpacity': 0.2
} 

folium.GeoJson(
           data=(open("all_geojson.json", 'r').read()),
           name="borders",
           style_function=lambda x:bordersStyle).add_to(base_map)

folium.LayerControl().add_to(base_map)

base_map.save('land3.html')

When I run, I have below error

if self.data['type'] == 'FeatureCollection':
TypeError: list indices must be integers or slices, not str

And an example from my geojson file:

geojson = {
      "type": 'FeatureCollection',
      "features": [
          {
              "type": "feature",
              "geometry": {
                  "type": "Polygon",
                  "coordinates": '%s' % coordinates #getting the coordinates from a code
              }
          }
          ],
      "properties": [
          {
              "landno": '%s' % no, #getting the number from a code
              "city": 'Paris',
              "area": '32x32'
          }
       ]
     }

 
0

There are 0 answers