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.
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). |
# Dockerfile
ENV PGEXTWLIST_VERSION 1.7
RUN wget -q -O pgextwlist-${PGEXTWLIST_VERSION}.tar.gz https://github.com/dimitri/pgextwlist/archive/v${PGEXTWLIST_VERSION}.tar.gz
RUN tar -xzf pgextwlist-${PGEXTWLIST_VERSION}.tar.gz && \
cd pgextwlist-${PGEXTWLIST_VERSION} && \
make -j${CPUS} && make install && \
export pkg=$(pg_config --pkglibdir) && mkdir $pkg/plugins && cp $pkg/pgextwlist.so $pkg/plugins