Coder Social home page Coder Social logo

kleok / downscale-satellitelst Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pansism/downscale-satellitelst

1.0 1.0 0.0 95.28 MB

A python class for enhancing the spatial resolution of satellite-derived Land Surface Temperatures (LST) using statistical downscaling.

License: MIT License

Python 100.00%

downscale-satellitelst's Introduction

downscale-satelliteLST

A python class for enhancing the spatial resolution of Land Surface Temperature (LST) raster data using statistical downscaling.

Description

This class implements the typical workflow of a statistical downscaling scheme for enhancing the spatial resolution of satellite-derived Land Surface Temperatures (LST). It uses GDAL to perform the resampling of the raster data and scikit-learn to build the regression models by combining two CART regressors (ADAboost & Random Forest) and two linear regressors (ElasticNET & Ridge) into an ensemble VotingRegressor.

Before using the class, the user must: (a) prepare and standarize the predictors; and (b) determine the best hyperparameters for each one of the employed AdaBoost, RandomForest, ElasticNet and Ridge regressors. The required hyperparameters are:

Regressor Required Hyperparameters
AdaBoost loss, n_estimators
RandomForest max_depth, n_estimators, min_samples_split, min_samples_leaf
ElasticNet l1_ratio, n_alphas, cv
Ridge alpha

Input Data:

  1. LST: A single raster dataset with one or more bands (each band is a LST image).
  2. Predictors: A single raster dataset with one or more bands (each band is a predictor).

The class does not require the two raster datasets to have the same SRS and Bounding Box. The only requirement is the predictors to be within the bounds of the LST data.

Checks before downscaling the LST data:

If a LST band misses more than 40% of its pixels, then this band is discarded and no model is built. In addition, if a model achieves a R^2 that is lower than 0.5, it is also discarded. These two thresholds can be changed using the setters SetMissingPxlsThreshold() and SetR2Threshold(), respectively.

Output:

A dictionary with the Downscaled LST (DLST) data of all the non-discarded models. The spatial resolution and the SRS of the output data is that of the predictors.

To save the DLST data as a raster dataset use SaveDLSTasGeotiff(savename). The savedir of the output raster is the workdir.

Usage

from osgeo import gdal
from DownscaleSatelliteLST import DownscaledLST     # Import the class

# Make an instance of the class
data = DownscaledLST(
        LST=gdal.Open("inputLST.tif"),				 
        predictors=gdal.Open("LSTpredictors.tif"),   
        LST_noDataVal=-1000,						
        predictors_noDataVal=-1000,		
        workdir="./DLST_save_folder",
        )

# Before applying the downscaling, it is mandatory to specify
# the following hyperparameters:
data.SetAdaBoostParams(loss="exponential", n_estimators=70)
data.SetRandomForestParams(max_depth=9, n_estimators=50, min_samples_split=2, min_samples_leaf=1)
data.SetElasticNetParams(l1_ratio=0.1, n_alphas=50, cv=5)
data.SetRidgeRegrParams(alpha=1.0)

# Change the R^2 threshold for discarding a model (the default value is 0.5)
data.SetR2Threshold(0.6)

# Downscale the LST data and apply the residual correction.
DLST = data.ApplyDownscaling(residual_corr=True)

# Get a list with the LST bands that have been downscaled.
# LST bands that miss more than 40% of their pixels 
# and regression models that achieve a R^2 below the
# R2-threshold are discarded.
bands = data.GetDLSTBandIndices(indexing_from_1=False)

# Save a report with the scores of all the non-discarded models
# The report is saved in workdir
data.GenerateReport()

# Export the DLST data as a compressed Geotiff file
# The geotiff file is saved in workdir 
data.SaveDLSTasGeotiff(savename="DLST.tif")

Things to keep in mind:

  • The recommended datatype for the input rasters is float.
  • If the LST or the predictors contain any water bodies or clouds, then these pixels should be NoData.
  • All the NoData pixels should have the same NoData value.
  • The class builds a "global" regression model for each LST band. Hence, it should be used with data that cover an area of limited extent, e.g. a city with its surroundings.
  • If the predictors are gapless, the algorithm will generate DLST data and for the cloud-covered areas. Handle them with caution.

To Do

  • Add a class for preparing the predictors.
  • Implement a function for finding the best parameters for each regressor
  • Add unittests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Reference

If you use this class please cite:

@phdthesis{Sismanidis2018,
    author = {Sismanidis, Panagiotis},
    pages  = {154},
    school = {National Technical University of Athens},
    title  = {{Applying Computational Methods for Processing Thermal Satellite Images of Urban Areas}},
    type   = {PhD Dissertation},
    year   = {2018}
}

downscale-satellitelst's People

Contributors

pansism avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.