-
Notifications
You must be signed in to change notification settings - Fork 69
Add explore() function and GISDocument.sidecar() method
#340
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
Merged
Changes from 40 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
96628ab
Create GISDocuments as untitled when no path provided
mfisher87 b1ee829
Remove `save_as()` method from GISDocument API, re-add `export_to_qgi…
mfisher87 c275e6e
Prefer `const`
mfisher87 691a60b
Fix unit test
mfisher87 287c742
Test untitled document numbering
mfisher87 6c400a5
Update docstring
mfisher87 31cd634
Stub out geo_debug function with jupyterlab-sidecar
mfisher87 d392901
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8c6b937
WIP
mfisher87 dec08a6
Add ESPM-157 notebook as example user of geo-debug workflow WIP
mfisher87 e6a0570
Use correct .jGIS extension
mfisher87 2e56f0c
Dunno, rebase me later
mfisher87 9f3b6b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ea3f08e
Open JGIS in sidecar
mfisher87 71b5540
Create an anonymous project
mfisher87 6faedf4
Open in a new JupyterLab window/tab!
mfisher87 d26280a
Update TODO comments
mfisher87 27285fd
Rename geo_debug -> explore
mfisher87 3816508
Explore explore function at jupytergis package
mfisher87 cb82c6f
Update docstring and parameter type
mfisher87 41662ae
Open JGIS Document as a full window, not widget
mfisher87 3fdee4f
Hack around document opening but not displaying layers as expected
mfisher87 c00844e
Switch back to sidecar approach, use CSS to handle filling space
mfisher87 eba50f1
Add dedicated explore example
mfisher87 a565ff4
Cleanup OBE comment
mfisher87 41f0a5e
Remove OBE test
mfisher87 d531178
Extract sidecar-opening to GISDocument API
mfisher87 b649e44
Dynamically determine type of object passed to explore()
mfisher87 e8d054f
Update example notebook to explore a geodataframe
mfisher87 d4d0de0
Remove debugging print statement
mfisher87 e621cd8
Move "smart" layer add into GISDocument method
mfisher87 a29b0c2
Add basemap parameter to `explore()`
mfisher87 a083bdf
Autodoc `explore()`
mfisher87 a17339f
Bugfix: don't pass name=None to methods that don't support it
mfisher87 d8a2355
Fix incorrect docstring raises directive
mfisher87 c32623a
Install jupytergis metapackage in docs environment
mfisher87 761e94a
Fix CSS to properly use vertical space in linked output & sidecar views
mfisher87 baba817
Fix autodoc typo
mfisher87 b47a01e
Fix layer panel not updating in sidecar view
mfisher87 ddf3d48
Copy docstring raises entries from underlying method docstring
mfisher87 0b2eab4
Attempt to fix lite integration tests
mfisher87 1503af3
Add note about CSS eventually added in JupyterLab
mfisher87 595dfa3
Move explore module into notebook subpackage
mfisher87 119c281
Make generic add_layer method a private internal function
mfisher87 9994796
Merge branch 'main' into sidecar-experiment
mfisher87 56bc8bd
Missing sidecar and export
martinRenou dff4346
Merge branch 'main' into sidecar-experiment
martinRenou 9a909e4
Missing sidecar in docs
martinRenou 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "c3f4096f-cbd3-43e8-a986-520681f03581", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# ESPM 157 - Intro to Spatial Data\n", | ||
| "\n", | ||
| "<https://espm-157.carlboettiger.info/spatial-1>\n", | ||
| "\n", | ||
| "Install dependencies:\n", | ||
| "\n", | ||
| "```bash\n", | ||
| "micromamba install geopandas ibis-duckdb\n", | ||
| "```" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "b76ae1f0-334e-41c0-9533-407c879b4ad6", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import ibis\n", | ||
| "\n", | ||
| "con = ibis.duckdb.connect()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "837aa4e0-5eeb-48c1-97ce-3f8706503911", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "redlines = con.read_geo(\n", | ||
| " \"/vsicurl/https://dsl.richmond.edu/panorama/redlining/static/mappinginequality.gpkg\"\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "4d3319fa-b3b4-4931-b073-98b649e41b65", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "city = redlines.filter(redlines.city == \"New Haven\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "34f7f4d6-28d6-4716-8e03-ac32c6ae3bb7", | ||
| "metadata": { | ||
| "scrolled": true | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "city_gdf = city.head().execute()\n", | ||
| "city_gdf.plot()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "d37a610a-1444-43a3-900f-dfe16a890ab9", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## OK, but what about spatial context?\n", | ||
| "\n", | ||
| "I want to explore this data more interactively." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "6e68aaac-dfc0-42d8-a3b9-05fce59524b2", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from jupytergis import explore\n", | ||
| "\n", | ||
| "# Open a new exploration window\n", | ||
| "explore(city_gdf, layer_name=\"New Haven\", basemap=\"dark\")" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3 (ipykernel)", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.12.9" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| __version__ = "0.4.4" | ||
|
|
||
| from jupytergis_lab import GISDocument # noqa | ||
| from jupytergis_lab import GISDocument, explore # noqa |
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
mfisher87 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,75 @@ | ||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
| from typing import Any, Literal, Optional | ||
|
|
||
| from jupytergis_lab import GISDocument | ||
martinRenou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @dataclass | ||
| class Basemap: | ||
| name: str | ||
| url: str | ||
|
|
||
|
|
||
| BasemapChoice = Literal["light", "dark", "topo"] | ||
| _basemaps: dict[BasemapChoice, list[Basemap]] = { | ||
| "light": [ | ||
| Basemap( | ||
| name="ArcGIS dark basemap", | ||
| url="https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}.pbf", | ||
| ), | ||
| Basemap( | ||
| name="ArcGIS dark basemap reference", | ||
| url="https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}.pbf", | ||
| ), | ||
| ], | ||
| "dark": [ | ||
| Basemap( | ||
| name="ArcGIS light basemap", | ||
| url="https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}.pbf", | ||
| ), | ||
| Basemap( | ||
| name="ArcGIS light basemap reference", | ||
| url="https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}.pbf", | ||
| ), | ||
| ], | ||
| "topo": [ | ||
| Basemap( | ||
| name="USGS topographic basemap", | ||
| url="https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}", | ||
| ), | ||
| ], | ||
| } | ||
|
|
||
|
|
||
| def explore( | ||
| data: str | Path | Any, | ||
| *, | ||
| layer_name: Optional[str] = "Exploration layer", | ||
| basemap: BasemapChoice = "topo", | ||
| ) -> GISDocument: | ||
| """Run a JupyterGIS data interaction interface alongside a Notebook. | ||
|
|
||
| :param data: A GeoDataFrame or path to a GeoJSON file. | ||
|
|
||
| :raises FileNotFoundError: Received a file path that doesn't exist. | ||
| :raises NotImplementedError: Received an input value that isn't supported yet. | ||
| :raises TypeError: Received an object type that isn't supported. | ||
| :raises ValueError: Received an input value that isn't supported. | ||
| """ | ||
| doc = GISDocument() | ||
|
|
||
| for basemap_obj in _basemaps[basemap]: | ||
| doc.add_raster_layer(basemap_obj.url, name=basemap_obj.name) | ||
|
|
||
| doc.add_layer(data, name=layer_name) | ||
|
|
||
| # TODO: Zoom to layer. Currently not exposed in Python API. | ||
|
|
||
| doc.sidecar(title="JupyterGIS explorer") | ||
|
|
||
| # TODO: should we return `doc`? It enables the exploration environment more usable, | ||
| # but by default, `explore(...)` would display a widget in the notebook _and_ open a | ||
| # sidecar for the same widget. The user would need to append a semicolon to disable | ||
| # that behavior. We can't disable that behavior from within this function to the | ||
| # best of my knowlwedge. | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is the culprit for the failure in the docs. We can't have
jupytergisinstalled in the lite deployment of the docs.It needs to be
jupytergis_liteor nothing.