Skip to main content

version 1.0 of the DEMIX library

Project description

DEMIX library

The DEMIX Library that allow you to get scores for specific DEMIX tiles and DEM You also can download DEMIX Tile associated DEM Layers like SourceMask, Heights, ...

Table of contents:

  1. Installation
  2. DEMIX lib functions
    1.1 Getting Scores
    1.2 Getting DEM
  3. Available DEMs and criterions
    2.1 Dem list
    2.2 Criterion list
  4. Utility functions
  5. Usage example

Installation

To install the DEMIX library on your python environment :
pip install demix_lib

DEMIX lib functions

This section is a step-by-step guide on how to use the DEMIX lib functions. By getting through this guide, you'll learn how to:
* Get a DEMIX tile id from a given longitude and latitude
* Apply a criterion to a DEM, over a given DEMIX tile
* Retrieve a raster of DEM layer over a DEMIX tile

Getting DEMIX Tile

The DEMIX api enables you to get a DEMIX tile id from a given longitude and latitude.
import demix_lib as dl
lon = 14.44799
lat = 35.81923
print(dl.get_demix_tile_info(lon, lat))
print(dl.get_demix_tile_name(lon, lat))

Getting Scores

First thing first, you can use the demix api to get directly stats from the desired DEMIX Tile and Criterion
In order to get scores to specific dem and tile, you need to choose a criterion. The criterion list is available here. List of supported dems is also visible here.
import demix_lib as dl

#getting the list of implemented criterions
criterions = dl.get_criterion_list()
#getting the list of supported dems
dems = dl.get_supported_dem_list()

#defining the wanted DEMIX Tile name 
demix_tile_name = "N35YE014F"

#getting the score of each dem, for the criterion 
for dem in  dems:
    for criterion in criterions:
        print(dl.get_score(demix_tile_name=demix_tile_name, dem=dem, criterion=criterion))

Getting DEM

To go further : You can always use your own criterions by downloading the wanted layer on your DEMIX tile and apply custom code to it.
To download a DEM layer for a specific DEMIX Tile :
import demix_lib as dl
import matplotlib as plt #we use matplotlib to visualise the downloaded layer
from matplotlib import cm #we use cm to make a legend/colormap
from matplotlib.lines import Line2D #to add colored line in the legend

#defining wanted tile
demix_tile_name = "N35YE014F"
#asking for the SourceMask layer for the CopDEM_GLO-30 dem and the tile N64ZW019C
response = dl.download_layer(demix_tile_name=demix_tile_name,dem="CopDEM_GLO-30",layer="SourceMask")

#creating legend for the plot
legend_handle = list(map(int, response['values'].keys()))
legend_label = list(response['values'].values())
#defining the colormap for the layer (the layer has 6 values)
color_map = cm.get_cmap('rainbow',6)
#we use plt to look at the data
plt.imshow(response["data"], interpolation='none', cmap=color_map, vmin=0, vmax=6)
#creating legend values using the color map and the values stored
custom_handles = []
for value in legend_handle:
    custom_handles.append(Line2D([0], [0], color=color_map(value), lw=4))
plt.legend( custom_handles,legend_label)
#show the layer with custom legend and color map
plt.show()

Utility functions

The DEMIX lib give you some utility functions that allow you to get or print informations about currently implemented criterions, available DEMs, layers...
import demix_lib as dl

#get or show the layers that you can ask in a download_layer function
layer_list = dl.get_layer_list()
dl.print_layer_list()
#get or show the full dem list
dem_list = dl.get_dem_list()
dl.print_dem_list()
#get or show the supported dem list
supported_dem_list = dl.get_supported_dem_list()
dl.print_supported_dem_list()
#get or show the implemented criterion list
criterion_list = dl.get_criterion_list()
dl.print_criterion_list()

Available DEMs and criterions

DEMs list

DEM name supported
ALOS World 3D no
ASTER GDEM no
CopDEM GLO-30 yes
NASADEM no
SRTMGL1 yes

Criterion list

Criterion name Criterion id version Date Category Target
Product fractional cover A01 0.1 20211103 A-completeness All
Valid data fraction A02 0.1 20211103 A-completeness All
Primary data A03 0.1 20211103 A-completeness All
Valid land fraction A04 0.1 20211103 A-completeness All
Primary land fraction A05 0.1 20211103 A-completeness All

Layer list

Layer name
Height
validMask
SourceMask
landWaterMask

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

demix_lib-1.0.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

demix_lib-1.0-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page