If your geocoding task requires only US county and state level information, you can avoid a third party web service dependency using open data and postgis.
Natural Earth counties, US only.
| import io | |
| from fastapi import FastAPI, Response | |
| from PIL import Image, ImageDraw, ImageFont | |
| app = FastAPI() | |
| @app.get("/tiles/{z}/{x}/{y}.png") | |
| async def get_debug_tile(z: int, x: int, y: int): |
| from flytekit import ContainerTask, kwtypes, task, workflow | |
| @task | |
| def say_hello(name: str, area: float) -> str: | |
| return f"Hey {name}! You have an ellipse of area {area}" | |
| calculate_ellipse_area_python = ContainerTask( | |
| command=[ |
| # Using osm.pbf extracts from https://download.geofabrik.de/index.html | |
| # Requires GDAL 3.7+ with the TileDB driver | |
| ogr2ogr -f TileDB ./dc-lines district-of-columbia-latest.osm.pbf lines | |
| ogr2ogr -f TileDB ./dc-points district-of-columbia-latest.osm.pbf points | |
| ogr2ogr -f TileDB ./dc-polygons district-of-columbia-latest.osm.pbf multipolygons |
| DROP TABLE if EXISTS boundaries; | |
| CREATE TABLE boundaries ( | |
| id BIGSERIAL primary key, | |
| geometry geometry(multipolygon, 4326) NOT null | |
| ); | |
| CREATE INDEX idx_boundaries_geometry | |
| ON boundaries | |
| USING gist (geometry); |
If your geocoding task requires only US county and state level information, you can avoid a third party web service dependency using open data and postgis.
Natural Earth counties, US only.
| 💲 git clone https://github.com/clojerl/example-web-app | |
| Cloning into 'example-web-app'... | |
| remote: Enumerating objects: 78, done. | |
| remote: Total 78 (delta 0), reused 0 (delta 0), pack-reused 78 | |
| Unpacking objects: 100% (78/78), 7.94 KiB | 507.00 KiB/s, done. | |
| mperry@t14-dev:/tmp | |
| 💲 cd example-web-app/ |
| extern crate byteorder; | |
| extern crate itertools; | |
| extern crate rustfft; | |
| use byteorder::{LittleEndian, ReadBytesExt}; | |
| use num_complex::Complex; | |
| use rustfft::num_traits::Zero; | |
| use rustfft::FFTplanner; | |
| use std::fs::File; | |
| use std::io::Seek; |
| from h3 import h3 | |
| import json | |
| from rasterstats import gen_zonal_stats | |
| def hexbin_features(bounding_polygon, zoom=8): | |
| """Takes a GeoJSON-like geometry dictionary with type Polygon | |
| and yields GeoJSON-like Features representing the hexbins | |
| that cover the polygon at a given zoom level |
| #!/usr/bin/env python | |
| from fiona.transform import transform_geom | |
| from rasterstats import point_query | |
| import mercantile | |
| def make_dem_url(lon: float, lat: float, z: int = 14) -> str: | |
| """Returns a URL referencing the GeoTiff Digitial Elevation Model (DEM) | |
| for the given point at a zoom level (default, max is 14). |