Skip to content

Commit

Permalink
added geocoding function
Browse files Browse the repository at this point in the history
  • Loading branch information
mtravis committed Oct 16, 2023
1 parent b6f8930 commit dc07743
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion open_buildings/download_buildings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import click
from math import tan, cos, log, pi
from shapely.geometry import shape
from shapely.geometry import shape, box
from typing import Dict, Any, Union
import mercantile
import duckdb
Expand All @@ -15,6 +15,7 @@
import subprocess
from shapely import wkb
import shutil
import osmnx

from open_buildings.settings import Source, Format, settings

Expand Down Expand Up @@ -43,6 +44,11 @@ def geojson_to_wkt(data: dict) -> str:
geometry = shape(data['geometry'])
return geometry.wkt

def geocode_to_wkt(data: str):
location = ox.geocode_to_gdf(data)
wkt = box(*location.total_bounds)
return wkt

def quadkey_to_geojson(quadkey: str) -> dict:
# Convert the quadkey to tile coordinates
tile = mercantile.quadkey_to_tile(quadkey)
Expand Down

0 comments on commit dc07743

Please sign in to comment.