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

refactor SEPAL map #463

Merged
merged 45 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
15ae232
fix: drop usage of geemap + cleaning
12rambau May 4, 2022
e2d5be0
fix: set the basemaps as basemaps
12rambau May 4, 2022
00d94df
fix: find layer by name and by index
12rambau May 4, 2022
7bd77b6
refactor: clean the import of ipyleaflet widgets
12rambau May 4, 2022
e299af9
fix: overwrite remove_layer to use index, name or layer
12rambau May 4, 2022
aedbc3b
fix: remove_all method to remove all layers but the basemaps
12rambau May 4, 2022
fafe1da
refactor: move theDrawControl to its own file
12rambau May 4, 2022
f2c66e6
build: drop support for python 3.6
12rambau May 4, 2022
3aa674c
fix: geemap was still called in aoi_model
12rambau May 4, 2022
2cfc24d
fix: avoid circular reference
12rambau May 5, 2022
1ae3c9e
refactor: split the gee command override from the rest of SepalMap
12rambau May 22, 2022
f91d909
refactor: cleaning
12rambau May 22, 2022
3501f69
refactor: move the v_inspector away from SepalMap
12rambau May 23, 2022
7b80e1e
fix: remove background for btns on maps
12rambau May 23, 2022
b98bb9c
fix: inspect ee_objects
12rambau May 23, 2022
b834b67
fix: read GeoJSON data
12rambau May 23, 2022
47f945c
fix: inspect rasters
12rambau May 23, 2022
3a79cec
feat: add a MapBtn
12rambau May 23, 2022
aadaa81
fix: remove legacy dot on the map
12rambau May 23, 2022
4a152e9
fix: avoid the v_inspector to move down the map
12rambau May 23, 2022
e983268
refactor: reorder the coordinates
12rambau May 23, 2022
7233853
Merge branch 'master' into sepalmap
dfguerrerom May 24, 2022
a78f7ec
refactor: some line breaks and removed a pair of condionals
dfguerrerom May 24, 2022
a1b2bd1
test: geojson_to_ee
12rambau May 25, 2022
c145ba4
test: basemaps
12rambau May 25, 2022
6c42f82
test: DrawControl
12rambau May 25, 2022
5208cb8
test: FullScreenControl
12rambau May 25, 2022
e720ace
test: EELayer
12rambau May 25, 2022
f805686
test: MapBtn
12rambau May 25, 2022
53843c3
build: add python-box to requirements
dfguerrerom May 26, 2022
cc2c423
feat: make wheel scroll default param
dfguerrerom May 26, 2022
1cc32c1
feat: return basemap box as default object from basemaps module
dfguerrerom May 26, 2022
487f062
refactor: rename value inspector module and add a closing icon
dfguerrerom May 26, 2022
465249b
fix: prepare refactoring of ValueInspector
12rambau May 26, 2022
35fe7be
Merge branch 'sepalmap' of github.com:12rambau/sepal_ui into sepalmap
12rambau May 26, 2022
eb9002e
test: valueInspector
12rambau May 27, 2022
5863f87
fix: include a base filter to sepal_map search and delete methods
12rambau May 30, 2022
c56a0ea
test: SepalMap
12rambau May 30, 2022
dcb66b5
build: duplicate dependency
12rambau May 30, 2022
baafa31
docs: typo in function prototype
12rambau May 30, 2022
f2fcf27
docs: avoid bug in the documentation display
12rambau May 30, 2022
1553217
build: add dask to requirements
12rambau May 30, 2022
015aa57
refactor: use keys for vinspector messages
12rambau May 30, 2022
dc74419
fix: typo
12rambau May 30, 2022
6ed17a2
fix: add the none_ok parameter to find_layer
12rambau May 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
22 changes: 22 additions & 0 deletions docs/source/modules/sepal_ui.mapping.DrawControl.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sepal\_ui.mapping.DrawControl
=============================

.. autoclass:: sepal_ui.mapping.DrawControl

.. rubric:: Attributes

.. autosummary::

~DrawControl.m

.. rubric:: Methods

.. autosummary::
:nosignatures:

~DrawControl.show
~DrawControl.hide

.. automethod:: sepal_ui.mapping.DrawControl.show

.. automethod:: sepal_ui.mapping.DrawControl.hide
49 changes: 10 additions & 39 deletions docs/source/modules/sepal_ui.mapping.FullScreenControl.rst
Original file line number Diff line number Diff line change
@@ -1,52 +1,23 @@
sepal\_ui.mapping.SepalMap
==========================
sepal\_ui.mapping.FullScreenControl
===================================

.. autoclass:: sepal_ui.mapping.SepalMap
.. autoclass:: sepal_ui.mapping.FullScreenControl

.. rubric:: Attributes

.. autosummary::

~SepalMap.ee
~SepalMap.vinspector
~SepalMap.loaded_rasters
~SepalMap.dc
~FullScreenControl.ICONS
~FullScreenControl.METHODS
~FullScreenControl.zoomed
~FullScreenControl.w_btn
~FullScreenControl.template

.. rubric:: Methods

.. autosummary::
:nosignatures:

~SepalMap.set_drawing_controls
~SepalMap.remove_last_layer
~SepalMap.zoom_ee_object
~SepalMap.zoom_bounds
~SepalMap.add_raster
~SepalMap.show_dc
~SepalMap.hide_dc
~SepalMap.add_colorbar
~SepalMap.addLayer
~SepalMap.get_basemap_list
~SepalMap.get_viz_params
~FullScreenControl.toggle_fullscreen

.. automethod:: sepal_ui.mapping.SepalMap.set_drawing_controls

.. automethod:: sepal_ui.mapping.SepalMap.remove_last_layer

.. automethod:: sepal_ui.mapping.SepalMap.zoom_ee_object

.. automethod:: sepal_ui.mapping.SepalMap.zoom_bounds

.. automethod:: sepal_ui.mapping.SepalMap.add_raster

.. automethod:: sepal_ui.mapping.SepalMap.show_dc

.. automethod:: sepal_ui.mapping.SepalMap.hide_dc

.. automethod:: sepal_ui.mapping.SepalMap.add_colorbar

.. automethod:: sepal_ui.mapping.SepalMap.addLayer

.. automethod:: sepal_ui.mapping.SepalMap.get_basemap_list

.. automethod:: sepal_ui.mapping.SepalMap.get_viz_params
.. automethod:: sepal_ui.mapping.FullScreenControl.toggle_fullscreen
10 changes: 10 additions & 0 deletions docs/source/modules/sepal_ui.mapping.Layer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sepal\_ui.mapping.Layer
=======================

.. autoclass:: sepal_ui.mapping.Layer

.. rubric:: Attributes

.. autosummary::

~Layer.ee_object
11 changes: 11 additions & 0 deletions docs/source/modules/sepal_ui.mapping.MapBtn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sepal\_ui.mapping.MapBtn
========================

.. autoclass:: sepal_ui.mapping.MapBtn

.. rubric:: Attributes

.. autosummary::

~MapBtn.logo

77 changes: 67 additions & 10 deletions docs/source/modules/sepal_ui.mapping.SepalMap.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,80 @@
sepal\_ui.mapping.FullScreenControl
===================================
sepal\_ui.mapping.SepalMap
==========================

.. autoclass:: sepal_ui.mapping.FullScreenControl
.. autoclass:: sepal_ui.mapping.SepalMap

.. rubric:: Attributes

.. autosummary::

~FullScreenControl.ICONS
~FullScreenControl.METHODS
~FullScreenControl.zoomed
~FullScreenControl.w_btn
~FullScreenControl.template
~SepalMap.ee
~SepalMap.dc
~SepalMap.v_inspector

.. rubric:: Methods

.. autosummary::
:nosignatures:

~FullScreenControl.toggle_fullscreen
~SepalMap.remove_last_layer
~SepalMap.set_center
~SepalMap.zoom_ee_object
~SepalMap.zoom_bounds
~SepalMap.add_raster
~SepalMap.show_dc
~SepalMap.hide_dc
~SepalMap.add_colorbar
~SepalMap.add_ee_Layer
~SepalMap.get_basemap_list
~SepalMap.get_viz_params
~SepalMap.remove_layer
~SepalMap.remove_all
~SepalMap.add_layer
~SepalMap.add_basemap
~SepalMap.get_scale
~SepalMap.setCenter
~SepalMap.getScale
~SepalMap.addLayer
~SepalMap.centerObject

.. automethod:: sepal_ui.mapping.FullScreenControl.toggle_fullscreen
.. automethod:: sepal_ui.mapping.SepalMap.remove_last_layer

.. automethod:: sepal_ui.mapping.SepalMap.set_center

.. automethod:: sepal_ui.mapping.SepalMap.zoom_ee_object

.. automethod:: sepal_ui.mapping.SepalMap.zoom_bounds

.. automethod:: sepal_ui.mapping.SepalMap.add_raster

.. automethod:: sepal_ui.mapping.SepalMap.show_dc

.. automethod:: sepal_ui.mapping.SepalMap.hide_dc

.. automethod:: sepal_ui.mapping.SepalMap.add_colorbar

.. automethod:: sepal_ui.mapping.SepalMap.add_ee_Layer

.. autofunction:: sepal_ui.mapping.SepalMap.get_basemap_list

.. automethod:: sepal_ui.mapping.SepalMap.get_viz_params

.. automethod:: sepal_ui.mapping.SepalMap.remove_layer

.. automethod:: sepal_ui.mapping.SepalMap.remove_all

.. automethod:: sepal_ui.mapping.SepalMap.add_layer

.. automethod:: sepal_ui.mapping.SepalMap.add_basemap

.. automethod:: sepal_ui.mapping.SepalMap.get_scale

.. automethod:: sepal_ui.mapping.SepalMap.find_layer

.. automethod:: sepal_ui.mapping.SepalMap.setCenter

.. automethod:: sepal_ui.mapping.SepalMap.addLayer

.. automethod:: sepal_ui.mapping.SepalMap.getScale

.. automethod:: sepal_ui.mapping.SepalMap.centerObject
25 changes: 25 additions & 0 deletions docs/source/modules/sepal_ui.mapping.ValueInspector.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sepal\_ui.mapping.ValueInspector
================================

.. autoclass:: sepal_ui.mapping.ValueInspector

.. rubric:: Attributes

.. autosummary::

~ValueInspector.m
~ValueInspector.w_loading
~ValueInspector.menu
~ValueInspector.text

.. rubric:: Methods

.. autosummary::
:nosignatures:

~ValueInspector.toggle_cursor
~ValueInspector.read_data

.. automethod:: sepal_ui.mapping.ValueInspector.toggle_cursor

.. automethod:: sepal_ui.mapping.ValueInspector.read_data
16 changes: 16 additions & 0 deletions docs/source/modules/sepal_ui.mapping.basemaps.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sepal\_ui.mapping.basemaps
==========================

.. automodule:: sepal_ui.mapping.basemaps

.. rubric:: Functions

.. autosummary::
:nosignatures:

get_xyz_dict
xyz_to_leaflet

.. autofunction:: sepal_ui.mapping.basemaps.get_xyz_dict

.. autofunction:: sepal_ui.mapping.basemaps.xyz_to_leaflet
14 changes: 13 additions & 1 deletion docs/source/modules/sepal_ui.mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ sepal\_ui.mapping

.. automodule:: sepal_ui.mapping

.. rubric:: Modules

.. autosummary::
:toctree:
:recursive:

sepal_ui.mapping.basemaps

.. rubric:: Classes

.. autosummary::
:toctree:

sepal_ui.mapping.SepalMap
sepal_ui.mapping.FullScreenControl
sepal_ui.mapping.FullScreenControl
sepal_ui.mapping.DrawControl
sepal_ui.mapping.EELayer
sepal_ui.mapping.MapBtn
sepal_ui.mapping.ValueInspector
17 changes: 2 additions & 15 deletions docs/source/modules/sepal_ui.scripts.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sepal\_ui.scripts.utils
set_config_locale
set_config_theme
set_type
geojson_to_ee

.. autofunction:: sepal_ui.scripts.utils.catch_errors

Expand Down Expand Up @@ -60,19 +61,5 @@ sepal\_ui.scripts.utils

.. autofunction:: sepal_ui.scripts.utils.set_type
















.. autofunction:: sepal_ui.scripts.utils.geojson_to_ee

22 changes: 8 additions & 14 deletions sepal_ui/aoi/aoi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pandas as pd
import geopandas as gpd
from ipyleaflet import GeoJSON
import geemap
import ee

from sepal_ui import color
Expand Down Expand Up @@ -260,6 +259,7 @@ def _from_asset(self, asset_name):
if asset_name["value"] is None:
raise Exception(ms.aoi_sel.exception.no_value)

# set the name
self.name = Path(asset_name["pathname"]).stem.replace(self.ASSET_SUFFIX, "")
ee_col = ee.FeatureCollection(asset_name["pathname"])

Expand All @@ -274,11 +274,8 @@ def _from_asset(self, asset_name):
self.feature_collection = ee_col

# create a gdf form te feature_collection
# cannot be used before geemap 0.8.17 (not released)
# self.gdf = geemap.ee_to_geopandas(self.feature_collection)
self.gdf = gpd.GeoDataFrame.from_features(
self.feature_collection.getInfo()["features"]
).set_crs(epsg=4326)
features = self.feature_collection.getInfo()["features"]
self.gdf = gpd.GeoDataFrame.from_features(features).set_crs(epsg=4326)

return self

Expand Down Expand Up @@ -311,7 +308,7 @@ def _from_points(self, point_json):

if self.ee:
# transform the gdf to ee.FeatureCollection
self.feature_collection = geemap.geojson_to_ee(self.gdf.__geo_interface__)
self.feature_collection = ee.FeatureCollection(self.gdf.__geo_interface__)

# export as a GEE asset
self.export_to_asset()
Expand Down Expand Up @@ -344,7 +341,7 @@ def _from_vector(self, vector_json):

if self.ee:
# transform the gdf to ee.FeatureCollection
self.feature_collection = geemap.geojson_to_ee(self.gdf.__geo_interface__)
self.feature_collection = su.geojson_to_ee(self.gdf.__geo_interface__)

# export as a GEE asset
self.export_to_asset()
Expand All @@ -370,7 +367,7 @@ def _from_geo_json(self, geo_json):

if self.ee:
# transform the gdf to ee.FeatureCollection
self.feature_collection = geemap.geojson_to_ee(self.gdf.__geo_interface__)
self.feature_collection = su.geojson_to_ee(self.gdf.__geo_interface__)

# export as a GEE asset
self.export_to_asset()
Expand Down Expand Up @@ -415,11 +412,8 @@ def _from_admin(self, admin):
).filter(ee.Filter.eq(f"ADM{level}_CODE", admin))

# transform it into gdf
# cannot be used before geemap 0.8.17 (not released)
# self.gdf = geemap.ee_to_geopandas(self.feature_collection)
self.gdf = gpd.GeoDataFrame.from_features(
self.feature_collection.getInfo()["features"]
).set_crs(epsg=4326)
features = self.feature_collection.getInfo()["features"]
self.gdf = gpd.GeoDataFrame.from_features(features).set_crs(epsg=4326)

else:
# save the country iso_code
Expand Down
Loading