-
Notifications
You must be signed in to change notification settings - Fork 27
[FEATURE] Add Ibis example page #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
John McCall (lowlydba)
merged 1 commit into
main
from
104-add-getting-data-section-with-ibis
May 6, 2026
+131
−36
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| --- | ||
| description: query and visualize Overture data with Ibis and DuckDB | ||
| title: Ibis | ||
| --- | ||
|
|
||
| [Ibis](https://ibis-project.org/) is a Python dataframe library that provides a unified interface to many query backends. With its default [DuckDB](https://duckdb.org/) backend, you can query Overture's GeoParquet files directly from S3 — with filter and projection pushdown so you only download the data you need. | ||
|
|
||
| :::info | ||
| This example requires `duckdb>=1.1.1` for GeoParquet support. See the [Ibis blog post](https://ibis-project.org/posts/ibis-overturemaps/index.html) for an extended walkthrough including visualization with Lonboard. | ||
| ::: | ||
|
|
||
| <details> | ||
|
|
||
| <summary> | ||
| **Installation requirements** | ||
|
|
||
| </summary> | ||
|
|
||
| ```bash | ||
| pip install 'duckdb>=1.1.1' | ||
| pip install 'ibis-framework[duckdb,geospatial]' | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| ## Query Overture data with Ibis | ||
|
|
||
| ### Read and filter data | ||
|
|
||
| Use `ibis.read_parquet()` to point Ibis at an Overture release on S3. Ibis spins up a DuckDB connection automatically. Here we query the `base/infrastructure` type and filter to power infrastructure within a bounding box around Washington, D.C.: | ||
|
|
||
| ```python | ||
| import ibis | ||
| from ibis import _ | ||
|
|
||
| t = ibis.read_parquet( | ||
| "s3://overturemaps-us-west-2/release/2024-09-18.0/theme=base/type=infrastructure/*", | ||
| table_name="infra", | ||
| ) | ||
|
|
||
| # Filter and project — DuckDB pushes these down to S3, so only matching data is downloaded | ||
| expr = t.filter( | ||
| _.bbox.xmin > -77.119795, | ||
| _.bbox.xmax < -76.909366, | ||
| _.bbox.ymin > 38.791631, | ||
| _.bbox.ymax < 38.995968, | ||
| _.subtype == "power", | ||
| ).select(["names", "geometry", "sources", "class"]) | ||
| ``` | ||
|
|
||
| :::tip | ||
| Ibis uses lazy evaluation — `expr` is just an expression tree and no data is fetched until you execute it. DuckDB pushes the filters and column projections down to the parquet reader, minimizing data transfer. | ||
| ::: | ||
|
|
||
| ### Save results locally | ||
|
|
||
| ```python | ||
| expr.get_backend().to_parquet(expr, "infra-power-dc.geoparquet") | ||
| ``` | ||
|
|
||
| ### Explore interactively | ||
|
|
||
| Load the saved file and turn on interactive mode to preview results inline: | ||
|
|
||
| ```python | ||
| ibis.options.interactive = True | ||
|
|
||
| power_dc = ibis.read_parquet("infra-power-dc.geoparquet") | ||
|
|
||
| # Rename 'class' — reserved word that causes issues with the deferred operator | ||
| power_dc = power_dc.rename(infra_class="class") | ||
|
|
||
| # Count by infrastructure class | ||
| power_dc.infra_class.value_counts().order_by(ibis.desc("infra_class_count")) | ||
| ``` | ||
|
|
||
| Filter to a specific class: | ||
|
|
||
| ```python | ||
| power_lines = power_dc.filter(_.infra_class == "power_line") | ||
| power_lines["names", "geometry", "infra_class"] | ||
| ``` | ||
|
|
||
| ### Visualize with Lonboard | ||
|
|
||
| Convert to a GeoDataFrame to visualize with [Lonboard](https://developmentseed.org/lonboard/latest/): | ||
|
|
||
| ```python | ||
| import geopandas as gpd | ||
| import lonboard | ||
| from lonboard.basemap import CartoBasemap | ||
|
|
||
| gdf = gpd.GeoDataFrame(power_lines.to_pandas(), geometry="geometry", crs="EPSG:4326") | ||
|
|
||
| lonboard.viz( | ||
| gdf, | ||
| map_kwargs={ | ||
| "basemap_style": CartoBasemap.Positron, | ||
| "view_state": {"longitude": -77.01, "latitude": 38.9, "zoom": 10}, | ||
| }, | ||
| ) | ||
| ``` | ||
|
|
||
| ## Next steps | ||
|
|
||
| - Full walkthrough with maps: [Ibis blog — Exploring GeoParquet Overture Maps with Ibis, DuckDB, and Lonboard](https://ibis-project.org/posts/ibis-overturemaps/index.html) | ||
| - Reading parquet files with Ibis: [Ibis how-to guide](https://ibis-project.org/how-to/input-output/duckdb-parquet) | ||
| - Lonboard visualization: [Lonboard + Overture example](https://developmentseed.org/lonboard/latest/examples/overture-maps/) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.