Skip to main content

Lidar data processing tools focused on Spanish PNOA datasets

Project description

pypi py Coverage Status Join the chat at https://gitter.im/cartolidar/cartolidar Binder Code style

cartolidar Logo

CartoLidar

Lidar data processing tools focused on Spanish PNOA datasets

Herramientas para procesado de datos Lidar del PNOA

Lidar PNOA: https://pnoa.ign.es/el-proyecto-pnoa-lidar

Introduction

CartoLidar is a collection of tools to process lidar files ("las" and "laz") and generate useful information for forestry and natural environment management (dasoLidar variables, DLVs).

This project is in alpha version and for now only includes the "clidtwins" tool.

"clidtwins" searchs for similar areas to a reference one in terms of dasoLidar variables (DLVs)

DLV: Lidar variables that describe or characterize forest or land cover structure.

CartoLidar es una colección de herramientas destinadas a procesar ficheros lidar ("las" y "laz") para clasificar los puntos mediante inteligencia artificial (GANs) y generar ficheros ráster con DEM y DLVs.

GAN (Generative Adversarial Networks): arquitectura de DL basada en redes neuronales en la que se optimiza simultanemante un discriminador y un generador para obtener imágenes verosímiles a partir de inputs que, en este caso, no son aleatorios (sino variables lidar).

DEM (Digital Elevation Model): modelos digitales de elevaciones (MDT, MDS)

DLV (DasoLidar Variables): variables dasométricas, que representan diversos aspectos de la estructura de una formación arbolada, arbustiva o de matorral como son la altura dominante, la cobertura, etc.

CartoLidar también incluye herramientas adicionales para generar otros productos de utilidad en selvicultura y otras areas de gestión del medio natural a partir de los ficheros ráster con las DLVs.

El proyecto está en fase alpha e incluye únicamente la herramienta adicional "clidtwins". Las herramientas de procesado de ficheros Lidar (clasificación de puntos, generación de DEM y DLVs)) se incorporará a github a partir del cuarto trimestre de 2022.

La herramienta clidtwins está destinada a buscar zonas similares a una(s) de referencia en términos de determinadas variables dasoLidar (DLVs).

+ info: Read the Docs - cartolidar (página en construcción)

Install

  1. Official version from pypi - cartolidar:
pip install cartolidar

or (in case you are working through a proxy server):

pip install cartolidar --proxy https://user:password@proxyserver:port
  1. Development version from github - cartolidar:

You can download the zip version, uncompress it somewhere, i.e.:

C:\users\yourUser\Downloads\cartolidar-main\

That folder contains a setup.py file (and the other components of the project) and you can install cartolidar from that directory for your python environment:

cd C:\users\yourUser\Downloads\cartolidar-main\
pip install .

Requeriments

cartolidar requires Python 3.7 or higher.

See other package requirements in requirements.txt.

Numba requirement (0.53.0) is optional but advisable for speeding up some tasks.

Use

Command line (cmd or bash)

a) Run cartolidar package:

python -m cartolidar [options]

It starts the main menu with the avaliable tools.

This alpha version includes only qlidtwins tools, wich make use of clidtwins package.

Se inicia el menu principal con las herramientas disponibles en cartolidar.

Inicialmente solo está disponible la herramienta qlidtwins que utliza el paquete clidtwins.

[options]

cartolidar general options:
        -h, --help     show this help message and exit
        -V, --version  show program's version number and exit
        -v, --verbose  set verbosity level [default: False]
        -H toolHelp    show help for a cartolidar tool.
                       toolHelp: qlidtwins / clidmerge / etc.
                       By defaut, help is shown without extended args.
        -e             Changes -H behaviour to extended arguments.
        -o menuOption  0. Show main menu; 1. qlidtwins: buscar o verificar
                       zonas analogas a una de referencia (con un determinado
                       patron dasoLidar); 2. qlidmerge: integrar ficheros asc
                       de 2x2 km en una capa tif unica (componer mosaico:
                       merge). Default: 0

    You can show tool-specific help with -H flag. Example:
      python -m cartolidar -H qlidtwins

b) It is also possible to run a tool without displaying the main menu (if the module is accesible). E.g.:

python qlidtwins.py [options]

or

python {path-to-cartolidar}/qlidtwins.py [options]

example:

python D:\cartolidar\cartolidar/qlidwins.py [options]

A module is accesible if is called from its folder, is called with path_to_module or its folder is in the PATH environmental variable.

Use -h to show help for a cartolidar tool. Example for qlidtwins (qlidtwins.py has to be accesible):

python qlidtwins.py -h

A module is accesible if is called from its folder, is called with path_to_module or its folder is in the PATH environmental variable.

Python code

You can import packages, modules, classes of functions from a script.py or within the python interactive interpreter. Examples:

import cartolidar
from cartolidar import clidtools
from cartolidar.clidtools import clidtwins
from cartolidar.clidtools.clidtwins import DasoLidarSource

To execute module qlidtwins.py from python code:

from cartolidar import qlidtwins

In this case, there are no options: it runs with qlidtwins.cfg configuration (if exists) or default configuration.

Required inputs

Read Read the Docs - cartolidar for details.

clidtwins reads files in "asc" format (single vector layers) each with a dasoLidar variable (DLV).

Those files have to be named as: XXX_YYYY_*IdFileType*.asc where:

  • XXX, YYYY are UTM coordinates (miles) that identifies the location (the block).
    • XXX, YYYY are usually the upper-left corner of a 2x2 km square area
  • *IdFileType* is any string that includes a DVL identifier (like alt95, fcc05, etc.).

Example: 318_4738_alt95.asc and 320_4738_alt95.asc are two files with alt95 variable (blocks: 318_4738 and 320_4738).

If we want to process two blocks (318_4738 and 320_4738) with two DLVs (e.g. alt95 and fcc05), we need these files: 318_4738_alt95.asc, 318_4738_fcc05.asc, 320_4738_alt95.asc, 320_4738_fcc05.asc

It's also advisable to include a layer with forest type codes.

TODO: describe procedure

Use example with python code

Procedure:

  1. Import package (or Class) and instantiate DasoLidarSource Class:
from cartolidar.clidtools.clidtwins import DasoLidarSource
myDasolidar = DasoLidarSource()
  1. Delimit the prospecting area (optional):
myDasolidar.setRangeUTM(
    LCL_marcoCoordMiniX=348000,
    LCL_marcoCoordMaxiX=350000,
    LCL_marcoCoordMiniY=4598000,
    LCL_marcoCoordMaxiY=4602000,
)
  1. Search for dasoLidar files in the prospecting zone (if any):

First argument (LCL_listLstDasoVars) is a string with a sequence of DLV identifiers and second one (LCL_rutaAscRaizBase) is a path to look for the files with those DLV ids.

myDasolidar.searchSourceFiles(
    LCL_listLstDasoVars='Alt95,Fcc05,Fcc03',
    LCL_rutaAscRaizBase='C:/myAscFiles',
)

This method creates a property named inFilesListAllTypes. It is a list for every DLV, each with the list of found file tuples for that file type. It only includes files of blocks that have all the file types (one file type = one DLV). Every file tuple consist of a file path and file name.

  1. Create a raster (Tiff) file from the DLV found files:

The createMultiDasoLayerRasterFile method requires the name (with path) of the forest type or land cover type vector layer (e.g. Spanish Forest Map -MFE25-) and the name of the field (type int) with the forest or land cover type identifier (e.g. main species code).

myDasolidar.createMultiDasoLayerRasterFile(
    LCL_rutaCompletaMFE='C:/mfe25/24_mfe25.shp',
    LCL_cartoMFEcampoSp='SP1',
)
  1. Analyze the ranges of every DLV in the reference area:

The analyzeMultiDasoLayerRasterFile method requires the name (with path) of the vector file with the reference polygon for macthing (shp or gpkg). If it is ageopackage, the layer name is also required.

myDasolidar.analyzeMultiDasoLayerRasterFile(
    LCL_patronVectrName='C:/vector/CorralesPlots.gpkg,
    LCL_patronLayerName='plot01Quercus',
)
  1. Create new Tiff files with similar zones and proximity to reference one (patron):
myDasolidar.generarRasterCluster()
  1. After carrying out steps 5 and 6 for several reference ones (example 1, 2, 3):
listaTM = [1, 2, 3]
myDasolidar.asignarTipoDeMasaConDistanciaMinima(listaTM)

to be continued...

Ayuda Markdown de github Ayuda Markdown de github Ayuda Markdown de markdownguide

Actions Status

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

cartolidar-0.0a10.tar.gz (967.5 kB view hashes)

Uploaded Source

Built Distribution

cartolidar-0.0a10-py3-none-any.whl (980.5 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