Skip to content

Comments

Add wms_to_geotiff function#1278

Merged
giswqs merged 6 commits intomasterfrom
wms
Dec 21, 2025
Merged

Add wms_to_geotiff function#1278
giswqs merged 6 commits intomasterfrom
wms

Conversation

@giswqs
Copy link
Member

@giswqs giswqs commented Dec 21, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 21, 2025 05:40
@github-actions
Copy link

github-actions bot commented Dec 21, 2025

@github-actions github-actions bot temporarily deployed to pull request December 21, 2025 05:46 Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_geotiff function in leafmap/common.py that 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.

Comment on lines +2887 to +2891
if scale is not None:
if width is None:
width = int(bbox_width / scale)
if height is None:
height = int(bbox_height / scale)
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +2772 to +2788
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:
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +2958 to +2959
except Exception:
pass # Fall through to manual georeferencing
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot temporarily deployed to pull request December 21, 2025 14:30 Inactive
giswqs and others added 3 commits December 21, 2025 10:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@giswqs giswqs merged commit 53b25b3 into master Dec 21, 2025
15 checks passed
@giswqs giswqs deleted the wms branch December 21, 2025 15:28
@github-actions github-actions bot temporarily deployed to pull request December 21, 2025 15:31 Inactive
@mergify
Copy link

mergify bot commented Dec 21, 2025

Thanks for the contribution @giswqs 🤩

giswqs added a commit that referenced this pull request Jan 27, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant