Home

Awesome

cm-vsm

A raster conversion and segmentation mask vectorization tool for KappaZeta cloudmask.

Dependencies

The following system dependencies are needed:

On Ubuntu, the following commands could be used to install the dependencies:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt-get install cmake gcc-9 g++-9 python3-pip libgdal-dev gdal-bin libexpat1-dev libgraphicsmagick++1-dev libcppunit-dev
pip3 install cget

On Fedora or CentOS, run

sudo yum install cmake gcc gcc-c++ python3-pip openjpeg2-devel libpng-devel gdal gdal-devel expat-devel GraphicsMagick-c++-devel netcdf-devel libjpeg-turbo-devel jbigkit-libs jbigkit-devel m4 cppunit-devel libtiff-devel

Make sure that your GDAL_DATA environment variable has been set, according to your GDAL version, which is indicated by the placeholder YOUR_GDAL_VERSION below:

GDAL_DATA=/usr/share/gdal/YOUR_GDAL_VERSION

Building

Ensure that there is no active Conda environment (except base) while building cm-vsm.

A release version of the tool can be built as follows:

cd vsm/build
cget install
cmake .. -DCMAKE_CXX_COMPILER=g++-9
make
sudo make install

Similarly, a debug version can be built as follows:

cd vsm/build
cget install
cmake .. -DCMAKE_CXX_COMPILER=g++-9 -DCMAKE_BUILD_TYPE=Debug
make
sudo make install

Once CMake has already been run in the build directory, the documentation can be built as follows:

cd vsm/build
make doc

Building in Visual Studio Code (Ubuntu Linux)

For the program to run additional packages from the "Extensions" tab are requred:

Using terminal navigate to ~/cm-vsm/vsm/build and run:

cget install

To configure the project press Ctrl + Shift + P in Visual Studio Code and run:

>CMake: Configure

If CMake cannot find CMakeLists.txt, navigate to it manually or reopen vsm folder as a project.

To build the project press Ctrl + Shift + P in Visual Studio Code and run:

>CMake: Build

To debug the project set a breakpoint, press Ctrl + Shift + P in Visual Studio Code and run:

>CMake: Debug

To avoid #include errors caused by IntelliSense, press Ctrl + Shift + P in Visual Studio Code and run:

C/C++: Edit configurations (UI)

In the configuration window specify an additional include path:

/usr/include/GraphicsMagick

and select C++17 as a C++ standard down to the bottom.

Usage

With the -d option, cm_vsm can be used to subtile a Sentinel-2 L2A raster image, for example:

./vsm/build/bin/cm_vsm -d /your/data/path/S2A_MSIL2A_20200529T094041_N0214_R036_T35VLF_20200529T120441.SAFE

The image will be processed band by band, and it might take about an hour to process the whole raster. In order to limit processing to specific bands, the -b comma,separated,list,of,band,names argument could be used. The results would be stored in another directory with a suffix .CVAT instead of the original .SAFE.

A CVAT annotations XML file could be rasterized with the -r option. This is to be performed after the successful subtiling of the raster image. Rasterization of a labelled subtile 2, 3, for example:

./vsm/build/bin/cm_vsm -r /your/data/path/S2A_MSIL2A_20200529T094041_N0214_R036_T35VLF_20200529T120441.CVAT/tile_2_3/annotations.xml -n /your/data/path/S2A_MSIL2A_20200529T094041_N0214_R036_T35VLF_20200529T120441.CVAT/tile_2_3/T35VLF_tile_2_3.nc

Supported bands

The following bands / layers are supported:

No.NameGround resolutionBit-depthFormatDescription
Label10 m8MaskSegmentation mask from one of the supported labeling tools
1TCI10 m8RGBTrue Color Image
2SCL20 m8MaskSen2Cor Scene Classification Image
3AOT10 m16GrayscaleAerosol Optical Thickness map
4B0160 m16Grayscale433 - 453 nm
5B0210 m16Grayscale457.5 - 522.5 nm
6B0310 m16Grayscale542.5 - 577.5 nm
7B0410 m16Grayscale650 - 680 nm
8B0520 m16Grayscale697.5 - 712.5 nm
9B0620 m16Grayscale732.5 - 747.5 nm
10B0720 m16Grayscale773 - 793 nm
11B0810 m16Grayscale784.5 - 899.5 nm
12B8A20 m16Grayscale855 - 875 nm
13B0960 m16Grayscale935 - 955 nm
14B1060 m16Grayscale1358 - 1389 nm
15B1120 m16Grayscale1565 - 1655 nm
16B1220 m16Grayscale2100 - 2280 nm
17WVP10 m16GrayscaleWater Vapour map
18GMLVectorGML vector mask
19S2CC20 m8MaskSen2Cor cloud probabilities
20S2CS20 m8MaskSen2Cor snow probabilities
21FMC20 m8MaskFmask classification map
22SS2C60 m8MaskSinergise S2Cloudless classification map
23SS2CC60 m8MaskSinergise S2Cloudless cloud probabilities
24MAJAC10 m8MaskCNES MAJA cloud classification map
25BHC60 m8MaskBaetens & Hagolle classification map
26FMSC20 m8MaskFrancis, Mrziglod, and Sidiropoulos classification map
27GSFC10 m8MaskNASA GSFC Vector mask converted into 10 m resolution raster
28DL-L8S2-UV10 m8MaskIPL-UV DL-L8S2-UV rgbiswir classification mask