clarisma / geodesk-py

Fast and storage-efficient spatial database engine for OpenStreetMap data
https://docs.geodesk.com/python
GNU Lesser General Public License v3.0
36 stars 0 forks source link
database geodesk geospatial openstreetmap

GeoDesk is a fast and storage-efficient geospatial database for OpenStreetMap data. Also available for Java.

Why GeoDesk?

Get Started

Requirements

Download

pip install geodesk

Create a GOL

Create a Geographic Object Library based on any .osm.pbf file, using the GOL Tool (Requires Java 16+).

For example:

gol build switzerland switzerland-latest.osm.pbf

Example Application

Find all the pubs in Zurich (Switzerland) and print their names:

from geodesk import *

# Open switzerland.gol
features = Features("switzerland")      

# Get the feature that represents the area of the city of Zurich
zurich = features("a[boundary=adminstrative][admin_level=8][name:en=Zurich]").one

# Define a set that contains nodes and areas that are pubs
pubs = features("na[amenity=pub]")

# Iterate through the pubs that are contained in the area of Zurich
# and print their names
for pub in pubs.within(zurich):
    print(pub.name)        

More Examples

Find all movie theaters within 500 meters from a given point:

movieTheaters = features("na[amenity=cinema]").around(
    meters=500, lat=47.37, lon=8.54)

Remember, OSM uses British English for its terminology.

Discover the bus routes that traverse a given street:

for route in street.parents("[route=bus]")):
    print(f"- {route.ref} from {route.from} to {route.to}")

Count the number of entrances of a building:

number_of_entrances = building.nodes("[entrance]").count

Documentation

GeoDesk Developer's Guide

Related Repositories