Write GeoJson into a .geojson file with Python

المشرف العام

Administrator
طاقم الإدارة
I want to write a geosjon object with the type into a .geosjon file. Therefore I tried to use

with open(test.geosjon, 'w') as outfile: geojson.dump(geosjon_geometries, outfile)But i get the error TypeError: coercing to Unicode: need string or buffer, tuple foundI figured out that with this function a dict is needed to write it into a geosjon file. Is there another possibility to write a geojson feature in a file?

The function looks like:

def write_json(self, features): # feature is a shapely geometry feature geom_in_geojson = geojson.Feature(geometry=features, properties={}) tmp_file = tempfile.mkstemp(suffix='.geojson') with open(tmp_file, 'w') as outfile: geojson.dump(geom_in_geojson, outfile) return tmp_fileThe input is a shapely geometry, e.g. MultiLineString or LineString



أكثر...
 
أعلى