Im trying to create a features array using python and python-geojson. I appended some features such as Polygon with working coordinates. However when I dump, there is no indentation in the geoJson file. It is all on one line and mapbox does not accept the data.
f
features = []
poly = Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]])
features.append(Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]]))
features.append(Feature(geometry=poly, properties={"country": "Spain"}))
feature_collection = FeatureCollection(features)
with open('myfile.geojson', 'w') as f:
dump(feature_collection,f)
f.close()
Thats how the output looks. It should be indented instead of clustered like that.
{"type": "FeatureCollection", "features": [{"type": "Polygon", "coordinates": [[[2.38, 57.322], [23.194, -20.28], [-120.43, 19.15], [2.38, 57.322]]]}, {"geometry": {"type": "Polygon", "coordinates": [[[2.38, 57.322], [23.194, -20.28], [-120.43, 19.15], [2.38, 57.322]]]}, "type": "Feature", "properties": {"country": "Spain"}}]}