Hello,
We’ve recently changed the PointSamplingTask
and we are working on changing the examples.
The erosion operation is now a separate task, geometry.ErosionTask
.
The erosion has to be explicitly executed now, while no disk radius is accepted anymore by the sampling task.
The following code should fix the example:
# cell 14
# add erosion task
from eolearn.geometry import ErosionTask
# TASK FOR EROSION
disk_radius = 1 # size of erosion disk, applied before sampling
erosion = ErosionTask((FeatureType.MASK_TIMELESS, 'LULC'), disk_radius=disk_radius)
# remove disk_radius from sampling task
# TASK FOR SPATIAL SAMPLING
# Uniformly sample about 100k pixels from patches
n_samples = int(4e4) if use_smaller_patches else int(1e5) # no. of pixels to sample
ref_labels = =0,1,2,3,4,5,6,7,8,9,1973] # reference labels to take into account when sampling
spatial_sampling = PointSamplingTask(
n_samples=n_samples,
ref_mask_feature='LULC',
ref_labels=ref_labels,
sample_features=s # tag fields to sample
(FeatureType.DATA, 'FEATURES'),
(FeatureType.MASK, 'IS_VALID'),
(FeatureType.MASK_TIMELESS, 'LULC')
])
# cell 15
# add erosion to workflow
workflow = EOWorkflow(dependencies=s
Dependency(transform=load, inputs=s]),
Dependency(transform=concatenate, inputs=sload]),
Dependency(transform=filter_task, inputs=sconcatenate]),
Dependency(transform=linear_interp, inputs=sfilter_task]),
Dependency(transform=move_features, inputs=slinear_interp, filter_task]),
Dependency(transform=erosion, inputs=smove_features]),
Dependency(transform=spatial_sampling, inputs=serosion]),
*save_dependency
])
Let us know if this works. We will update the examples as soon as possible.
It apparently works but since this point the results are different than expected.
In cell 21 I get a different accuracy:
the figure in cell 27 is the following:
And the most important difference is in the image displayed in cell 29:
I’ve re-run the example with the suggested changes and got the same results as in the original notebook. Can you delete the previously generated eopatches and re-run the modified notebook again? Don’t forget to add erosion to the workflow.
From the image in cell 29, the issue seems to be in the input features, likely from the interpolation task.
Which versions of eo-learn
, sentinelhub-py
and s2cloudless
are you using?
Thanks for your fast answers. I deleted the eopatches and re-ran the code obtaining the same figure in cell 29. Erosion was added to the code.
sentinelhub version is 2.4.7
s2cloudless version is 1.2.2
what about the version of eo-learn
?
I used the same versions for sentinelhub
and s2cloudless
and the version for eo-learn
was 0.4.0
In file PKG-INFO is written version 0.3.3
Could you please uninstall the current version and pip install --upgrade eolearn
and re-run the notebook with the added erosion. This would help pin-point the issue.
Thank you
Sorry Devis, when uninstalling eo-learn I realized that version 0.4.0 was in fact installed. Anyway, I installed again version 0.4.0 and same results are obtained.I cannot upload the my jupyter notebook file here but I can send it by email (in that case I need your email address)
The jupyter notebook I’m using may be downloaded from here
Thanks. Your updated notebook is correct, I’ve run it in my environment and it produces the expected results.
You are using the python-template
configuration for sentinel-hub, correct?
I would suggest if possible to create a clean Python environment with latest eo-learn to rule out environment conflicts, and to make sure the atmospheric correction in you SH configuration layers is set to None.
Let us know if this works. We’ll try to update the example in the meanwhile
The example has been updated here in the develop
branch, and has been tested on that branch as well.
Thanks a lot for your help!
I created a new configuration and set the configuration to be based on Python scripts template to be sure on that point. After that I configured it (sentinelhub.config --instance_id <the_nerw_instance id>). I deleted the EO-patches and again the same results are obtained.
The notebook is correct, and the set up of SH seems to be correct as well (double-check that atmospheric correction in BANDS-S2CLOUDLESS
is set to None).
Have you perhaps tried creating a new clean Python environment? I would create one, pip install --upgrade eo-learn
, copy the examples
and example_data
folders from the master branch somewhere outside the eo-learn repo, and try running the notebook again. Shouldn’t be necessary, but might be easier for debugging.
Atmospheric correction in BANDS-S2CLOUDLESS
is set to None.
I uninstalled anaconda3 and installed again ANACONDA3-5.2.0 (with python 3.6.5).
After that I installed:
- Pyproj 1.9.5.1
- numpy 1.14.6
- sentinelhub 2.4.7
- s2cloudless 1.2.2
- GDAL 2.3.2
- rasterio 1.0.10
- Fiona 1.7.13
- tqdm 4.28.1
- eo-learn 0.4.0
I copied the examples and example_data folder in a different folder (even a different disc).
Image in cell 29 is still wrong.
Perhaps you can write me an e-mail at sinergise.com and we can try find the issue by comparing eopatches.
Here is what I did:
$ mkdir eo-learn; cd eo-learn
$ git clone https://github.com/sentinel-hub/eo-learn.git .
$ git checkout develop
$ cd examples/land-cover-map
$ conda create --name eo-learn-env python=3.6
$ source activate eo-learn-env
$ pip install --upgrade eo-learn
$ pip install tqdm jupyterlab
$ conda install -c conda-forge ipywidgets
$ sentinelhub.config --instance_id <your_instance_id>
These operations lead to an environment with:
- eo-learn=0.4.0
- Fiona=1.8.4
- jupyterlab=0.35.4
- lightgbm=2.2.2
- numpy=1.15.4
- rasterio=1.0.13
- s2cloudless=1.2.2
- scipy=1.2.0
- sentinelhub=2.4.7
Running $ jupyter-lab SI_LULC_pipeline.ipynb
and all cells of example gave correct result.
Hard to understand but with the new environment and performing the steps you mentioned I obtain again the undesired result.
The installation of eo-learn initially failed requiring the pre-installation of some packages:
- pyproj (pyproj-1.9.5.1-cp36-cp36m-win_amd64.whl)
- GDAL (GDAL-2.3.2-cp36-cp36m-win_amd64.whl)
- rasterio (rasterio-1.0.12-cp36-cp36m-win_amd64.whl)
- fiona (Fiona-1.8.4-cp36-cp36m-win_amd64.whl)
You may download the eopatches from:
The eopatches_small
are equal, while the issue is in the interpolated values FEATURES
(see figures below).
Are scipy
and numpy
installed from wheels as well? That might explain the different behaviour.
numpy was installed this way: pip3 install --upgrade numpy
scipy was not explicitly installed
I tried the complete process in a different computer, obtaining same results. Both are windows, the first is windows 10 and the other one is windows 7.
scipy is installed during s2cloudless installation
We reproduced your issue on Windows 10. On Linux Ubuntu and MacOS the notebook runs fine. We’d need some time to look into why this is happening. Thank you for reporting this.