Skip to content
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

Add Map.layer_to_image method #1815

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Add Map.layer_to_image method #1815

merged 1 commit into from
Nov 3, 2023

Conversation

giswqs
Copy link
Member

@giswqs giswqs commented Nov 3, 2023

This PR adds the Map.layer_to_image() method, making it easier to export an Earth Engine layer with custom visualization parameters as an image to a local computer. This is a much better solution than taking a screenshot of a layer because it allows specifying the resolution of the image to export. You get what you see.

The tif format retains the crs of the layer, which can be overlaid on other data layers using dekstop GIS.

Other supported formats include jpg, png, etc.

The layer on the map:
image

The downloaded image:
image

Copy link

github-actions bot commented Nov 3, 2023

@github-actions github-actions bot temporarily deployed to pull request November 3, 2023 04:18 Inactive
@giswqs giswqs merged commit c77bb40 into master Nov 3, 2023
14 checks passed
@giswqs giswqs deleted the export branch November 3, 2023 04:19
from PIL import Image

# Open the GeoTIFF file
with rasterio.open(image) as dataset:
Copy link
Collaborator

Choose a reason for hiding this comment

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

PIL can read a tiff. It might be simpler to just open the tif with PIL, do any transformations that are necessary, and then image.save(output). I haven't tried that, so I don't know if there are any surprises

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. Let me look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants