Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom committed May 29, 2024
2 parents 48e78db + 3e1f977 commit 9dc2bb8
Show file tree
Hide file tree
Showing 26 changed files with 1,582 additions and 685 deletions.
41 changes: 33 additions & 8 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,45 @@ on:
- push
- workflow_dispatch

env:
EARTHENGINE_TOKEN: ${{ secrets.EARTHENGINE_TOKEN }}
PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: pre-commit/[email protected].0
- name: install dependencies
python-version: "3.10"
- uses: pre-commit/[email protected].1
- name: Install module venv
run: |
python -m pip install --find-links=https://girder.github.io/large_image_wheels GDAL
python -m pip install earthengine-api
python -m pip install -r requirements.txt
python -m pip install pytest nbmake
python -m pip install "git+https://github.com/12rambau/sepal_ui.git@sepal_pre_release"
module_venv --venv_prefix venv
- name: Activate venv
run: source ~/module-venv/clip-time-series/bin/activate
- name: install nbmake
run: python -m pip install pytest nbmake
- name: build the application
run: pytest --nbmake ui.ipynb
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install module venv
run: |
python -m pip install "git+https://github.com/12rambau/sepal_ui.git@sepal_pre_release"
python -m pip install pytest
module_venv --venv_prefix venv
- name: Activate venv and run tests
run: |
source ~/module-venv/clip-time-series/bin/activate
python -m pip install pytest
python -m pytest test/
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@ Each mosaic will be represented in a square of custom size from 500x500m to 1000

The input can be a table file discribing points or a shapefile using geometries.

Colors are stretched using [histogram equalization](https://en.wikipedia.org/wiki/Histogram_equalization).
The output can be adjusted using any of the following enhancement methods:

- Histogram Equalization
- Contrast Stretching
- Adaptive Equalization
- Standard Deviation
- Percent Clip
- Min-Max

To produce this image the software will use the most recent satellite with a cloudless mosaic using the following priority order :

- Sentinel 2
- Landsat 9
- Landsat 8
- landsat 5
- landsat 7

The user can manually swithc of the usage of sentinel or landsat data.

The user can replace these satellites wih PlanetLab NICFI mosaics if it has register to the NICFI programm (free). Please follow thins [link](https://docs.sepal.io/en/latest/setup/nicfi.html) for more information.
The user can replace these satellites wih PlanetLab NICFI mosaics if it has register to the NICFI programm (free). Please follow this [link](https://docs.sepal.io/en/latest/setup/nicfi.html) for more information.

![full_app](./doc/img/output_table_planet.png)

Expand All @@ -32,7 +40,7 @@ for more information about usage please read the [documentation](https://docs.se
to install the project on your SEPAL account

```
$ git clone https://github.com/openforis/clip-time-series.git
$ git clone https://github.com/sepal-contrib/clip-time-series.git
```

please retreive the develop branch where all our development live
Expand Down
4 changes: 3 additions & 1 deletion component/model/model_export.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from sepal_ui import model
from traitlets import Any
from traitlets import Any, Bool, Unicode


class ExportModel(model.Model):

vue = Any(None).tag(sync=True)
overwrite = Bool(True).tag(sync=True)
enhance_method = Unicode("min_max").tag(sync=True)
68 changes: 43 additions & 25 deletions component/parameter/gee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@
from collections import OrderedDict

import ee
from sepal_ui.scripts.utils import init_ee

ee.Initialize()
init_ee()

# data parameters
gee_min_landsat_year = 1985 # launch of landsat 5
gee_min_sentinel_year = 2015 # launch of sentinel 2
gee_max_end_year = datetime.datetime.now().year
sources = ["landsat", "sentinel"]


# functions to access parameters according to the used satellite
def getSatellites(sources, year):

satellites = OrderedDict()

# https://developers.google.com/earth-engine/landsat_c1_to_c2#oli
if "sentinel" in sources and year >= 2015:
# cannot use SR as they don't cover years before 2020
satellites["sentinel_2"] = "COPERNICUS/S2"
satellites["sentinel_2"] = "COPERNICUS/S2_HARMONIZED"
if "landsat" in sources:
if year >= 2022:
satellites["landsat_9"] = "LANDSAT/LC09/C02/T1_L2"
if year >= 2013:
satellites["landsat_8"] = "LANDSAT/LC08/C02/T1_L2"
if year <= 2013:
satellites["landsat_5"] = "LANDSAT/LT05/C01/T1_SR"
satellites["landsat_5"] = "LANDSAT/LT05/C02/T1_L2"
if year >= 1999:
satellites["landsat_7"] = "LANDSAT/LE07/C01/T1_SR"
satellites["landsat_7"] = "LANDSAT/LE07/C02/T1_L2"

return satellites

Expand All @@ -36,6 +39,7 @@ def getShortname(satellite):
"landsat_5": "L5",
"landsat_7": "L7",
"landsat_8": "L8",
"landsat_9": "L9",
}

# in parralel sometime the code doesn't manage to write the appropriate key.
Expand All @@ -47,7 +51,13 @@ def getShortname(satellite):

def getScale(satellite):

scale = {"sentinel_2": 10, "landsat_5": 30, "landsat_7": 30, "landsat_8": 30}
scale = {
"sentinel_2": 10,
"landsat_5": 30,
"landsat_7": 30,
"landsat_8": 30,
"landsat_9": 30,
}

return scale[satellite]

Expand All @@ -62,51 +72,59 @@ def getAvailableBands():
"""
bands = {
"Red, Green, Blue": {
"landsat_7": ["B3", "B2", "B1"],
"landsat_5": ["B3", "B2", "B1"],
"landsat_7": ["SR_B3", "SR_B2", "SR_B1"],
"landsat_5": ["SR_B3", "SR_B2", "SR_B1"],
"landsat_8": ["SR_B4", "SR_B3", "SR_B2"],
"landsat_9": ["SR_B4", "SR_B3", "SR_B2"],
"sentinel_2": ["B4", "B3", "B2"],
},
"Nir, Red, Green": {
"landsat_7": ["B4", "B3", "B2"],
"landsat_5": ["B4", "B3", "B2"],
"landsat_7": ["SR_B4", "SR_B3", "SR_B2"],
"landsat_5": ["SR_B4", "SR_B3", "SR_B2"],
"landsat_8": ["SR_B5", "SR_B4", "SR_B3"],
"landsat_9": ["SR_B5", "SR_B4", "SR_B3"],
"sentinel_2": ["B8", "B4", "B3"],
},
"Nir, Swir1, Red": {
"landsat_7": ["B4", "B5", "B3"],
"landsat_5": ["B4", "B5", "B3"],
"landsat_7": ["SR_B4", "SR_B5", "SR_B3"],
"landsat_5": ["SR_B4", "SR_B5", "SR_B3"],
"landsat_8": ["SR_B5", "SR_B6", "SR_B4"],
"landsat_9": ["SR_B5", "SR_B6", "SR_B4"],
"sentinel_2": ["B8", "B11", "B4"],
},
"Swir2, Nir, Red": {
"landsat_7": ["B7", "B4", "B3"],
"landsat_5": ["B7", "B4", "B3"],
"landsat_7": ["SR_B7", "SR_B4", "SR_B3"],
"landsat_5": ["SR_B7", "SR_B4", "SR_B3"],
"landsat_8": ["SR_B7", "SR_B5", "SR_B4"],
"landsat_9": ["SR_B7", "SR_B5", "SR_B4"],
"sentinel_2": ["B12", "B8", "B4"],
},
"Swir2, Swir1, Red": {
"landsat_7": ["B7", "B5", "B3"],
"landsat_5": ["B7", "B5", "B3"],
"landsat_7": ["SR_B7", "SR_B5", "SR_B3"],
"landsat_5": ["SR_B7", "SR_B5", "SR_B3"],
"landsat_8": ["SR_B7", "SR_B6", "SR_B4"],
"landsat_9": ["SR_B7", "SR_B6", "SR_B4"],
"sentinel_2": ["B12", "B11", "B4"],
},
"Swir2, Nir, Green": {
"landsat_7": ["B7", "B4", "B2"],
"landsat_5": ["B7", "B4", "B2"],
"landsat_7": ["SR_B7", "SR_B4", "SR_B2"],
"landsat_5": ["SR_B7", "SR_B4", "SR_B2"],
"landsat_8": ["SR_B7", "SR_B5", "SR_B3"],
"landsat_9": ["SR_B7", "SR_B5", "SR_B3"],
"sentinel_2": ["B12", "B8", "B3"],
},
"ndvi": { # 2 useful bands nir and red
"landsat_7": ["B4", "B3"],
"landsat_5": ["B4", "B3"],
"landsat_7": ["SR_B4", "SR_B3"],
"landsat_5": ["SR_B4", "SR_B3"],
"landsat_8": ["SR_B5", "SR_B4"],
"landsat_9": ["SR_B5", "SR_B4"],
"sentinel_2": ["B8", "B4"],
},
"ndwi": { # 2 useful bands nir and swir
"landsat_7": ["B4", "B5"],
"landsat_5": ["B4", "B5"],
"landsat_7": ["SR_B4", "SR_B5"],
"landsat_5": ["SR_B4", "SR_B5"],
"landsat_8": ["SR_B5", "SR_B6"],
"landsat_9": ["SR_B5", "SR_B6"],
"sentinel_2": ["B8", "B11"],
},
}
Expand All @@ -119,7 +137,7 @@ def getCloudMask(satelliteId):
if satelliteId in ["landsat_5", "landsat_7"]:

def cloudMask(image):
qa = image.select("pixel_qa")
qa = image.select("QA_PIXEL")
# If the cloud bit (5) is set and the cloud confidence (7) is high
# or the cloud shadow bit is set (3), then it's a bad pixel.
cloud = qa.bitwiseAnd(1 << 5).Or(qa.bitwiseAnd(1 << 3))
Expand All @@ -129,7 +147,7 @@ def cloudMask(image):

return image.updateMask(cloud.Not()).updateMask(mask2)

elif satelliteId == "landsat_8":
elif satelliteId in ["landsat_8", "landsat_9"]:

def cloudMask(image):
# Bits 3 and 5 are cloud shadow and cloud, respectively.
Expand Down
2 changes: 2 additions & 0 deletions component/parameter/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"Swir2, Nir, Green": "yellow",
"rgb": "blue",
"cir": "yellow",
"ndvi": "red",
"ndwi": "red",
}
polygon_width = 2

Expand Down
Loading

0 comments on commit 9dc2bb8

Please sign in to comment.