Aim
For an assignment I need to put some building information (geometries and their properties) into a GeoJSON data structure.
Approach
My general approach is as follows:
create an empty dictionary with the necessary GeoJSON data structure and .append
the data to this structure
(see: below)
output_buildings = {
'type': "FeatureCollection",
'features': [
{
'type': "Feature",
'geometry': {
'type': ,
'coordinates':
},
'properties': {
'building_id': ,
'building_year': ,
'building_status': ,
'building_occurance':
}
}
]
}
Issue
I know how to create a simple empty dictionary, but my problem is that I don't know how to create a key structure without values (as I want to append those values later on). I receive an error at type
(the second one within features
) at the ,
.
Previous efforts
- I found this topic on StackOverflow: Method for Creating a Nested Dictionary from a List of Keys; but it doesn't fit my purpose.
- I searched in the python docs with terms like "create empty nested dictionary", "create dictionary with empty values", but didn't find what I was looking for.
- I tried to use placeholders (%s / %d), but they are not suitable for this purpose
- Finally I tried to use
pass
(didn't work).
Question
I haven't found a solution yet. Can you please provide me with some suggestions?
Thanks in advance!