gedih3.sqlutils#
Functions#
|
|
|
Attach existing ducklake database |
|
Convert a region to a list of overlapping H3 cells at resolution. |
|
Convert a region to an H3 partition filter at the given resolution. |
|
Convert a DuckDB table to a GeoDataFrame. |
|
Load a GeoDataFrame into a DuckDB table. |
Module Contents#
- gedih3.sqlutils.init_duckdb(threads=None, memory_limit=None, temp_directory=None, max_temp_size=None, extension_directory=None)[source]#
- gedih3.sqlutils.attach_ducklake_db(con, name='gedi_dl', dir=None)[source]#
Attach existing ducklake database If dir is not specified, it will be located in GH3_DEFAULT_H3_DIR.
- Once this function is called, the gedi data can be queried using
SELECT … FROM {name}.data
- gedih3.sqlutils.geoseries_to_cells(shp, resolution: int = 3, expand_ring: int = 1)[source]#
Convert a region to a list of overlapping H3 cells at resolution.
Accepts every region form the loaders accept (vector-file path,
"W,S,E,N"string,[W, S, E, N]list, GeoDataFrame/GeoSeries in any CRS, shapely geometry) viaregion_to_geometry(), so the DuckDB pre-query selection cannot drift fromgh3_load’s — previously a GeoSeries in a projected CRS was fed to h3 as if it were lat/lng degrees.
- gedih3.sqlutils.geoseries_to_filter(shp, resolution: int = 3, expand_ring: int = 1)[source]#
Convert a region to an H3 partition filter at the given resolution.
'overlap'coverage is exact w.r.t. the cell polygons, but shots are stored under their hierarchy partition, which can overhang the polygon by ~0.18 x edge length (seeintersect_h3_geometries).expand_ringadds grid_disk neighbors so boundary shots stored in a non-overlapping neighbor partition are not silently filtered out; pass 0 to disable.The filter column follows resolution (
h3_03for the default partition level 3) — pass the database’sh3_partition_levelwhen it differs.
- gedih3.sqlutils.duck_to_gdf(table, geometry_columns=['geometry'], crs='EPSG:4326') geopandas.GeoDataFrame[source]#
Convert a DuckDB table to a GeoDataFrame. If multiple geometry columns are specified, the first will be set as the active geometry.
- gedih3.sqlutils.gdf_to_duck(con, gdf: geopandas.GeoDataFrame, geometry_columns: List[str] = ['geometry']) duckdb.DuckDBPyRelation[source]#
Load a GeoDataFrame into a DuckDB table.