README.md 5.02 KB
Newer Older
Tristan Klempka's avatar
Tristan Klempka committed
1
# CES NeigeOA
2
3
## Synopsis

Simon Gascoin's avatar
Simon Gascoin committed
4
5
This code is a Python/OTB version of the demonstrator of the snow detection algorithm for Sentinel-2 images. 

6
To read more about this product (in French):
Manuel Grizonnet's avatar
Manuel Grizonnet committed
7

8
* [Bulletin THEIA](https://www.theia-land.fr/sites/default/files/imce/BulletinTHEIA3_light.pdf#page=10)
Manuel Grizonnet's avatar
Manuel Grizonnet committed
9

10
* [Slides Séminaire GEOSUD](http://www.equipex-geosud.fr/documents/10180/233868/7_GascoinHagolle2015-THEIA+CES+surface+enneigee_S%C3%A9minaire+Theia+Geosud+2015.pdf)
Manuel Grizonnet's avatar
Manuel Grizonnet committed
11

12
The input files are SPOT  or Landsat-8 Level-2A images from Theia Land and the SRTM digital elevation model.
13
14
15

## Code Example

16
17
18
To build DEM data. Download VRT files corresponding to the data and build the .vrt using gdalbuildvrt. Edit config.json file to activate preprocessing : Set "preprocessing" to true and set vrt path. It will project and resample the SRTM DEM over the Landsat/SPOT area (30m:Landsat8 or 20m:Take5). It uses gdalwarp with the cubicspline option.

The snow detection is performed in the Python script app/run_snow_detector.py. 
19
20

```
Simon Gascoin's avatar
Simon Gascoin committed
21
Configure PYTHONPATH environnement
22
export PYTHONPATH=${lis-build-dir}/app/:$PYTHONPATH
23
```
Simon Gascoin's avatar
Simon Gascoin committed
24
25
Run the main python script:

26
```
27
python run_snow_detector param.json
28
```
29

30
31
There is a Bash script in app directory which allows to set the env variable and run the script:

32
```
33
runLis.sh param.json
34
```
Tristan Klempka's avatar
Tristan Klempka committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## Products format

* COMPO: RGB composition with snow mask 
* SNOW_ALL: Binary mask of snow and clouds.
  * 1st bit: Snow detected from pass1
  * 2nd bit: Snow detected from pass2
  * 3rd bit: Clouds detected from pass1 
  * 4th bit: Clouds refined  from pass2

For example if you want to get the snow from pass1 and clouds detected from pass1 you need to do: 
````
pixel_value & 00000101  
````
* SEB: Raster image of the snow mask and cloud mask. 
  * 0: No-snow
  * 100: Snow
  * 205: Cloud including cloud shadow
  * 254: No data
* SEB_VEC: Vector image of the snow mask and cloud mask. Two fields of information are embbeded in this product. DN (for Data Neige) and type.
  * DN field :
     * 0: No-snow
     * 100: Snow
     * 205: Cloud including cloud shadow
     * 254: No data
  * Type field:
     * no-snow
     * snow
     * cloud
     * no-data
64

65
66
## Motivation

Simon Gascoin's avatar
Simon Gascoin committed
67
Code to generate CES Neige products on Theia platforms
68
69
70

## Installation

Manuel Grizonnet's avatar
Manuel Grizonnet committed
71
72
73
74
75
76
77
78
79
80
81
82
### Dependencies

lis dependencies: 

GDAL >=1.9
OTB >= 5.0 
Boost-Python
Python interpreter >= 2.7
Python libs >= 2.7

GDAL itself depends on a number of other libraries provided by most major operating systems and also depends on the non standard GEOS and PROJ4 libraries. GDAl- Python bindings are also required

Simon Gascoin's avatar
Simon Gascoin committed
83
Python package dependencies: sys, subprocess, glob, os, json, gdal
Manuel Grizonnet's avatar
Manuel Grizonnet committed
84

85
### Installing from the source distribution
Manuel Grizonnet's avatar
Manuel Grizonnet committed
86

87
#### General
88

89
In your build directory, use cmake to configure your build.
90
```` 
91
92
93
94
95
cmake -C config.cmake source/lis/
````
In your config.cmake you need to set :
````
LIS_DATA_ROOT
96
97
98
99
100
101
102
103
````
For OTB superbuild users these cmake variables need to be set:
````
OTB_DIR
ITK_DIR
GDAL_INCLUDE_DIR
GDAL_LIBRARY
````
Tristan Klempka's avatar
Tristan Klempka committed
104
Run make in your build folder.
105
````
Tristan Klempka's avatar
Tristan Klempka committed
106
make
107
108
109
110
111
112
113
114
115
116
117
````
To install s2snow python module. 
In your build folder:
````
cd python
python setup.py install
```` 
or
````
python setup.py install --user
````
Tristan Klempka's avatar
Tristan Klempka committed
118
Update environment variables for LIS. Make sure that OTB and other dependencies directories are set in your environment variables:
Tristan Klempka's avatar
Tristan Klempka committed
119
````
Tristan Klempka's avatar
Tristan Klempka committed
120
121
export PYTHONPATH=/your/build/directory/bin/:$PYTHONPATH
export PATH=/your/build/directory/bin:$PATH
Tristan Klempka's avatar
Tristan Klempka committed
122
````
123
let-it-snow is now installed.
Manuel Grizonnet's avatar
Manuel Grizonnet committed
124

125
#### On venuscalc
126

127
To configure OTB :
128
129
130
````
source /mnt/data/home/otbtest/config_otb.sh
````
131
Then build the lis project using cmake
132
133
134
````
cd $build_dir
cmake -DCMAKE_CXX_FLAGS:STRING=-std=c++11 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-4.8 -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-4.8 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DGDAL_INCLUDE_DIR=/mnt/data/home/otbtest/OTB/SuperBuild/include -DGDAL_LIBRARY=/mnt/data/home/otbtest/OTB/SuperBuild/lib/libgdal.so $source_dir
135
make
136
````
137
138
139
140
141
142
143
144
145
146
To install s2snow python module. 
In your build folder:
````
cd python
python setup.py install
```` 
or
````
python setup.py install --user
````
Tristan Klempka's avatar
Tristan Klempka committed
147
Update environment variables for LIS. Make sure that OTB and other dependencies directories are set in your environment variables:
148
````
Tristan Klempka's avatar
Tristan Klempka committed
149
150
export PYTHONPATH=/your/build/directory/bin/:$PYTHONPATH
export PATH=/your/build/directory/bin:$PATH
151
152
153
````
let-it-snow is now installed.

154
155
## Tests

Tristan Klempka's avatar
Tristan Klempka committed
156
Enable tests with BUILD_TESTING cmake option. Use ctest to run tests. Do not forget to clean your output test directory when you run a new set of tests.
157

Tristan Klempka's avatar
Tristan Klempka committed
158
159
160
161
162
Download LIS-Data folder. It contains all the data needed to run tests. Set Data-LIS path var in cmake configuration files. 
Baseline : Baseline data folder. It contains output files of S2Snow that have been reviewed and validated. 
Data-Test : Test data folder needed to run tests. It contains Landsat, Take5 and SRTM data.
Output-Test : Temporary output tests folder.
Do not modify these folders.
Manuel Grizonnet's avatar
Manuel Grizonnet committed
163

164
165
## Contributors

Tristan Klempka's avatar
Tristan Klempka committed
166
Manuel Grizonnet (CNES), Simon Gascoin (CNRS/CESBIO), Tristan Klempka (Stagiaire CNES)
Manuel Grizonnet's avatar
Manuel Grizonnet committed
167

168
169
## License

Manuel Grizonnet's avatar
Manuel Grizonnet committed
170
This is free software under the GPL v3 licence. See
171
http://www.gnu.org/licenses/gpl-3.0.html for details.