1

I am trying to save a geopandas.geodataframe in geojson format. but i have an error and i don't know where it comes from and how to solve it. here is the code and the error :

Thanks in advance for your help.

  batiments = ox.geometries_from_place(saint_denis, tags={'building':['office', 
  'university', 'stadium', 
                                                      'civic']})
  routes = ox.geometries_from_place(saint_denis, tags={'highway':['primary', 
 'secondary']})
  #export to geojson 
  batiments.to_file('dataframe.geojson', driver='GeoJSON')

enter image description here

amaranaitsaidi
  • 101
  • 1
  • 9

1 Answers1

2

Instead of .to_file() You can either create a new geojson file and fill the .to_json() object inside it , it's a json dict in (str) format.

with open('dataframe.geojson' , 'w') as file:
    file.write(batiments.to_json())
lackti
  • 146
  • 7