Conversation
|
🚀 Deployed on https://694812bdb9540a8e21bb9efa--opengeos.netlify.app |
There was a problem hiding this comment.
Pull request overview
This PR adds a new wms_to_geotiff function that enables users to export GeoTIFF images from Web Map Service (WMS) endpoints within a specified bounding box and scale.
Key Changes
- New
wms_to_geotifffunction inleafmap/common.pythat fetches WMS imagery and converts it to georeferenced GeoTIFF format - Comprehensive documentation notebook demonstrating various usage patterns including scale-based export, explicit dimensions, and coordinate system transformations
- Integration into the documentation navigation structure
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| leafmap/common.py | Adds the core wms_to_geotiff function with support for CRS transformation, multiple image formats, and automatic georeferencing |
| docs/maplibre/wms_to_geotiff.ipynb | Provides usage examples including WMS layer exploration, various export methods, and visualization of exported GeoTIFFs |
| mkdocs.yml | Adds the new notebook to the documentation navigation under the maplibre section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if scale is not None: | ||
| if width is None: | ||
| width = int(bbox_width / scale) | ||
| if height is None: | ||
| height = int(bbox_height / scale) |
There was a problem hiding this comment.
When both scale and width/height are provided, the scale parameter is used to override the explicitly provided width and height values. This behavior may be unexpected for users who provide both parameters. Consider either raising an error when both are provided, or clearly documenting this precedence, or only using scale to calculate missing dimensions (width or height) rather than overriding already-provided values.
| def wms_to_geotiff( | ||
| url: str, | ||
| layers: str, | ||
| bbox: List[float], | ||
| output: str, | ||
| width: Optional[int] = None, | ||
| height: Optional[int] = None, | ||
| scale: Optional[float] = None, | ||
| bbox_crs: str = "EPSG:4326", | ||
| output_crs: Optional[str] = None, | ||
| format: str = "image/tiff", | ||
| version: str = "1.1.1", | ||
| styles: str = "", | ||
| transparent: bool = True, | ||
| quiet: bool = False, | ||
| **kwargs: Any, | ||
| ) -> str: |
There was a problem hiding this comment.
The new wms_to_geotiff function lacks test coverage. Since the test_common.py file includes tests for other conversion and export functions in the common module, this function should have corresponding tests to verify its functionality, error handling, and edge cases.
| except Exception: | ||
| pass # Fall through to manual georeferencing |
There was a problem hiding this comment.
The exception handling here silently catches all exceptions and falls through to manual georeferencing. While this provides a fallback mechanism, it may hide legitimate errors (e.g., corrupted data, out of memory issues). Consider logging the exception or at least catching more specific exceptions to distinguish between "not a valid GeoTIFF" and other error conditions.
for more information, see https://pre-commit.ci
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks for the contribution @giswqs 🤩 |
* Add wms_to_geotiff function * Convert to COG * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix cog issue * Update leafmap/common.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update leafmap/common.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.