gee-community / geemap

A Python package for interactive geospatial analysis and visualization with Google Earth Engine.
https://geemap.org
MIT License
3.45k stars 1.08k forks source link

getZoom from Map #1605

Closed bw4sz closed 1 year ago

bw4sz commented 1 year ago

Description

In the js viewer, you can do

https://developers.google.com/earth-engine/apidocs/map-getzoom

Source code

>>> import geemap
>>> Map = geemap.Map()
>>> Map.getZoom()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Map' object has no attribute 'getZoom'

This would be useful if you are trying to create a visualization which add layers based on current zoom. This is a common approach in leaflet type applications.

Use Case

I am plotting millions of polygons for individual tree crowns (see https://elifesciences.org/articles/62922). This is very slow, which makes sense. You really only need to see the polygons at fine zoom levels. I was guessing that plotting the centroids at coarser zoom levels will be faster, since there are less vertices. Feel free to close and open discussion if there is a better path forward.

Not reproducible yet, but you can see generate flow here:

https://github.com/bw4sz/NeonTreeSpeciesApp/blob/main/apps/NEON.py

Screenshot 2023-07-03 at 3 01 19 PM

Thanks for your work on this package. I am a python package maintainer (https://deepforest.readthedocs.io/en/latest/) and I know how much effort it takes.

giswqs commented 1 year ago

@bw4sz Thank you for report. I know deepforest. I was planning on integrating it into segment-geospatial.

Streamlit does not support ipyleaflet. Folium is very limited. It is a one way street. You can't pass back information from the map back to the program. I have stopped using streamlit for mapping applications.

Solara is so much better. It has native support for ipywidgets and ipyleaflet, hence leafmap and geemap. Give it a try.

Web app: https://huggingface.co/spaces/giswqs/solara-geospatial GitHub: https://github.com/opengeos/solara-geospatial Video: https://youtu.be/_VK10mjwpWI

bw4sz commented 1 year ago

Okay, i'm on it. If you have any tips for trying to make this scale, let me know. Give me 2 or 3 days to get solara going. We have 80 million tree polygons from 25 NEON sites. I'm uploading each site as a ~5 million row csv asset to earth engine.

Let me know if you need any deepforest help, hoping to retrain the model to make it scale. Its very sensitive to patch size and image resolution right now.

On Wed, Jul 5, 2023 at 11:03 AM Qiusheng Wu @.***> wrote:

@bw4sz https://github.com/bw4sz Thank you for report. I know deepforest. I was planning on integrating it into segment-geospatial https://github.com/opengeos/segment-geospatial.

Streamlit does not support ipyleaflet. Folium is very limited. It is a one way street. You can't pass back information from the map back to the program. I have stopped using streamlit for mapping applications.

Solara is so much better. It has native support for ipywidgets and ipyleaflet, hence leafmap and geemap. Give it a try.

Web app: https://huggingface.co/spaces/giswqs/solara-geospatial GitHub: https://github.com/opengeos/solara-geospatial Video: https://youtu.be/_VK10mjwpWI

— Reply to this email directly, view it on GitHub https://github.com/gee-community/geemap/issues/1605#issuecomment-1622232466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJHBLEMDPVPTWMEUAHKPKLXOWT6BANCNFSM6AAAAAAZ7JELMY . You are receiving this because you were mentioned.Message ID: @.***>

-- Ben Weinstein, Ph.D. Research Scientist University of Florida http://benweinstein.weebly.com/

giswqs commented 1 year ago

It should be pretty easy once the datasets are available on Earth Engine. See this sample web app on how to add data to the web app. You can also add interactive widgets using ipywidgets. https://github.com/opengeos/solara-geospatial/blob/main/pages/02_geemap.py

giswqs commented 1 year ago

I have created a new web app template that makes it easier for others to duplicate and deploy. See https://huggingface.co/spaces/giswqs/solara-geemap