eoa-team / eodal_notebooks Goto Github PK
View Code? Open in Web Editor NEWSample Jupyter notebooks for EOdal
License: GNU General Public License v3.0
Sample Jupyter notebooks for EOdal
License: GNU General Public License v3.0
Notebook requires slight modification to work.
Also requires docker changes to install gdal.
collection: str = 'sentinel2'
# set up mapping configs
mapper_configs = MapperConfigs(
#collection='sentinel2-msi',
collection=collection,
time_start=time_start,
time_end=time_end,
feature=feature,
metadata_filters=metadata_filters
)
#get a new mapper instance. Set sensor to `sentinel2`
# mapper = Mapper(mapper_configs, sensor='sentinel2')
mapper = Mapper(mapper_configs)
Make sure the notebooks are kept up-to-date with the latest developments in EOdal. Thus, for each EOdal release, there should be an according release of the notebooks!
In notebook sentinel2_field_parcel_extraction.ipynb
, at very end there is an error
gdf_rapeseed_pixels = handler.to_dataframe()
gdf_rapeseed_pixels.info()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py:3802, in Index.get_loc(self, key, method, tolerance)
3801 try:
-> 3802 return self._engine.get_loc(casted_key)
3803 except KeyError as err:
File /usr/local/lib/python3.10/dist-packages/pandas/_libs/index.pyx:138, in pandas._libs.index.IndexEngine.get_loc()
File /usr/local/lib/python3.10/dist-packages/pandas/_libs/index.pyx:165, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/hashtable_class_helper.pxi:5745, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas/_libs/hashtable_class_helper.pxi:5753, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: ('B03', 'geometry')
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Cell In[19], line 1
----> 1 gdf_rapeseed_pixels = handler.to_dataframe()
2 gdf_rapeseed_pixels.info()
File /usr/local/lib/python3.10/dist-packages/eodal/utils/decorators.py:101, in check_band_names.<locals>.wrapper(self, *args, **kwargs)
99 band_names = None
100 if len(args) == 0 and len(kwargs) == 0:
--> 101 return f(self, *args, **kwargs)
103 if len(args) > 0:
104 # band name(s) are always provided as first argument
105 band_names = args[0]
File /usr/local/lib/python3.10/dist-packages/eodal/core/raster.py:1576, in RasterCollection.to_dataframe(self, band_selection)
1572 gdf[band_name] = gdf_band[band_name]
1573 # otherwise we can try to merge the pixels passed on
1574 # their geometries
1575 else:
-> 1576 gdf = gdf.join(gdf_band[band_name, "geometry"], on="geometry")
1577 return gdf
File /usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py:1415, in GeoDataFrame.__getitem__(self, key)
1409 def __getitem__(self, key):
1410 """
1411 If the result is a column containing only 'geometry', return a
1412 GeoSeries. If it's a DataFrame with any columns of GeometryDtype,
1413 return a GeoDataFrame.
1414 """
-> 1415 result = super().__getitem__(key)
1416 geo_col = self._geometry_column_name
1417 if isinstance(result, Series) and isinstance(result.dtype, GeometryDtype):
File /usr/local/lib/python3.10/dist-packages/pandas/core/frame.py:3807, in DataFrame.__getitem__(self, key)
3805 if self.columns.nlevels > 1:
3806 return self._getitem_multilevel(key)
-> 3807 indexer = self.columns.get_loc(key)
3808 if is_integer(indexer):
3809 indexer = [indexer]
File /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py:3804, in Index.get_loc(self, key, method, tolerance)
3802 return self._engine.get_loc(casted_key)
3803 except KeyError as err:
-> 3804 raise KeyError(key) from err
3805 except TypeError:
3806 # If we have a listlike key, _check_indexing_error will raise
3807 # InvalidIndexError. Otherwise we fall through and re-raise
3808 # the TypeError.
3809 self._check_indexing_error(key)
KeyError: ('B03', 'geometry')
On one band the method works without errors.
I tried to create a workaround as
px_list = [handler[b].to_dataframe() for b in handler.band_names]
gdf_rapeseed_pixels = reduce(lambda left, right:
pd.merge(left , right,
on = ["geometry"]
),
px_list)
however I get way more rows than in example (using same example data) and when I try to plot it there is ablue square.
Update the notebooks to EOdal version 0.2.2 (release August 2023)
I tried first to run one of your examples using a Jupyter notebook without luck (sentinel2_data_download_to_array), unfortunately. I modified the modules path and eodal path as indicated, and this first cell seems to run without errors. Also, the following cells defining functions, eodal query parameters and so on are working. But when we get to dowload/load the images, I get an error. Apparently is finding the scenes but an exception arises because it "can not initialize new Band instance: Must pass either crs or epsg" (I add screenshot).
I tried also to run it using the container provided, but the same error appears. Thus, the Python and modules versions are the ones specified in the dockerfile. My OS is Windows 10 Enterprise.
Error when trying to import a module from eodal
, notebook notebooks/Sentinel-2/sentinel2_data_handling.ipynb
. I looked in eodal
repo, there indeed isn't such module.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[3], line 3
1 # download test data (if not done yet)
2 import requests
----> 3 from eodal.downloader.sentinel2.utils import unzip_datasets
5 # URL to the public dataset
6 url = 'https://data.mendeley.com/public-files/datasets/ckcxh6jskz/files/e97b9543-b8d8-436e-b967-7e64fe7be62c/file_downloaded'
ModuleNotFoundError: No module named 'eodal.downloader.sentinel2.utils'
In notebook "Sentinel-2 Field Parcel Extraction"
from eodal.downloader.sentinel2.utils import unzip_datasets
needs to be changed to
from eodal.downloader.utils import unzip_datasets
Clean-up the repository and provide a good README file.
There are some open points:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.