Install
To install from pypi
pip install osmstats
To install from this source code
pip install .
To install into a specific path
pip install -t <path> .
Where to Download OSM Data?
- Visit this link.
- Manually select your area.
- Export!
Exporting OSM data options
- Overpass API - Download this bounding box from a mirror of the OpenStreetMap database
- Planet OSM - Regularly updated copies of the complete OpenStreetMap database Geofabrik Downloads
- Regularly - updated extracts of continents, countries, and selected cities
- Other Sources - Additional sources listed on the OpenStreetMap wiki
Usage
from osmstats import OSMStats
location = OSMStats('/path/to/map.osm')
# get lat, lon of this map data
location.bounds
# collection of all contributors with count
location.get_contributors()
# total count of a feature
location.get_count('amenity')
# total count of a specific sub-feature
location.get_count('amenity', 'pharmacy')
# collection of all sub-feature of this feature with count
location.get_feature('shop')
# result of all get_feature() so far
location.details
# list of supported features
from osmstats import OSM_FEATURES
print(OSM_FEATURES.keys())
# dump the data as json
import json
json.dumps(location.details)