gee-community / qgis-earthengine-plugin

Integrates Google Earth Engine and QGIS using Python API
http://qgis-ee-plugin.appspot.com
MIT License
454 stars 116 forks source link

Add Map.onChangeCenter() to QGIS plugin #83

Open vieiramesquita opened 3 years ago

gena commented 3 years ago

Let's elaborate a bit:

Can you provide a few scenarios on how this will be used?

In Code Editor, when the user hits run, all event handlers defined in that script are subscribed, and when the user re-runs that script - event handlers are re-subscribed from scratch. This feature can be probably implemented in QGIS in a similar way if I manage to find how to handle the Run Script button signal. And then unsubscribe all Map.on* events when the user hits Run. Would that be acceptable?

gena commented 3 years ago

Here how a prototype looks like, a bit slow with EE calls on every center change:

https://user-images.githubusercontent.com/169821/103962342-0ef6ec00-5157-11eb-99dc-382825035121.mp4

vieiramesquita commented 3 years ago

The example I have is: I need to navigate through many points (9k) and I don't want to load images (Sentinel 2) for a large area (an entire country, i.e. Brazil) or click on the Run button for each point. Map.onChangeCenter() seems to be the best way to do this in QGIS.

gena commented 3 years ago

Hmm, I still don't see how Map.onChangeCenter() would help here, if you plan to re-run EE processing every time you change map center - it could be slow.

It might be better to have some more explicit way to trigger processing for a given point (or points), e.g. select a point in a layer to trigger EE update or something using QGIS Python API, like run a script that will iterate over points in the current view (or over selected points only) and run some EE processing for all of them, putting results into a single resulting layer. For QGIS API see for example https://docs.qgis.org/3.4/pdf/en/QGIS-3.4-PyQGISDeveloperCookbook-en.pdf

vieiramesquita commented 3 years ago

I will try to iterate over the selected feature. It seems to be the best way to do what I want 😅