Skip to content

Instantly share code, notes, and snippets.

@JorgeMartinezG
Last active August 22, 2023 07:43
Show Gist options
  • Save JorgeMartinezG/34ae36c0f593158d6f0c391e8190669a to your computer and use it in GitHub Desktop.
Save JorgeMartinezG/34ae36c0f593158d6f0c391e8190669a to your computer and use it in GitHub Desktop.
#
# Configuration file for OSM import
#
# put here the name of keys for ways that are assumed to be polygons if they are closed
# see http://wiki.openstreetmap.org/wiki/Map_Features
closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism
# comment to avoid laundering of keys ( ':' turned into '_' )
attribute_name_laundering=yes
# uncomment to report all nodes, including the ones without any (significant) tag
#report_all_nodes=yes
# uncomment to report all ways, including the ones without any (significant) tag
#report_all_ways=yes
[points]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
#attributes=name,barrier,highway,ref,address,is_in,place,man_made,building,building:walls,building:use,building:structure,building:roof,building:levels
# keys that, alone, are not significant enough to report a node as a OGR point
unsignificant=created_by,converted_by,source,time,ele
# keys that should NOT be reported in the "other_tags" field
# ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
[lines]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
# attributes=name,highway,waterway,aerialway,barrier,man_made,building,building:walls,building:use,building:structure,building:roof,building:levels
# keys that should NOT be reported in the "other_tags" field
# ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
[multipolygons]
# common attributes
# note: for multipolygons, osm_id=yes instanciates a osm_id field for the id of relations
# and a osm_way_id field for the id of closed ways. Both fields are exclusively set.
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
# attributes=name,type,aeroway,amenity,admin_level,barrier,boundary,building,craft,geological,historic,land_area,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism,building:walls,building:use,building:structure,building:roof,building:levels
# keys that should NOT be reported in the "other_tags" field
#ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
[multilinestrings]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
# attributes=name,type,building,building:walls,building:use,building:structure,building:roof,building:levels
# keys that should NOT be reported in the "other_tags" field
#ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
[other_relations]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
# attributes=name,type,building,building:walls,building:use,building:structure,building:roof,building:levels
# keys that should NOT be reported in the "other_tags" field
#ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
import json
from csv import DictReader
file_path = "/Users/gis/OneDrive - World Food Programme/LKA_training/data/osm/multipolygons.csv"
with open(file_path, "r") as f:
reader = [r["other_tags"] for r in DictReader(f)]
items = []
for r in reader:
try:
item = json.loads(r)
except Exception as e:
pass
items.append(list(item.keys()))
items = [item for sublist in items for item in sublist]
counted_values = {v: len([i for i in items if i == v]) for v in set(items)}
sorted_count = dict(sorted(counted_values.items(), key=lambda x: x[1], reverse=True))
print(sorted_count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment