| Title: | Utilities to Download and Manage Files of France National Airborne Laser Scanning Cover (LIDAR HD) |
|---|---|
| Description: | Provides functions for downloading, managing and processing (normalization, digital elevation models computation) laz files provided by the LiDAR HD program of IGN (France). |
| Authors: | Jean-Matthieu Monnet [aut, cre] (ORCID: <https://orcid.org/0000-0002-9948-9891>) |
| Maintainer: | Jean-Matthieu Monnet <[email protected]> |
| License: | GPL-3 |
| Version: | 1.2.1 |
| Built: | 2026-11-12 16:46:07 UTC |
| Source: | https://forge.inrae.fr/lidar/lidarHD.git |
Fonction qui ajoute dans de tableau d'assemblage le chemin d'acces aux produits derives
add_attributes_ta(ta, data_folder, save = FALSE)add_attributes_ta(ta, data_folder, save = FALSE)
ta |
text or 'sf' object. 'sf' object or filename to load it |
data_folder |
test. path to directory with downloaded and computed files |
save |
boolean. in case 'ta' is a file, should it be overwritten ? |
An 'sf' object with additional attributes containing the file path to derived products
## Not run: # charger depuis un fichier presente dans un dossier ta_lidarHD <- load_classified_ta(url = NULL, save_dir = "./data/sig/") ta_lidarHD <- lidarHD::add_attributes_ta(ta_lidarHD, dossier, save = FALSE) ## End(Not run)## Not run: # charger depuis un fichier presente dans un dossier ta_lidarHD <- load_classified_ta(url = NULL, save_dir = "./data/sig/") ta_lidarHD <- lidarHD::add_attributes_ta(ta_lidarHD, dossier, save = FALSE) ## End(Not run)
Adds the height above ground in an ExtraByte attribute H to files of a
catalog. Files are renamed with the prefix "EB-" and are indexed with a
".lax" file because they are not written as "copc" files. Applies the function
add_height_extrabyte, and requires that adjacent tiles are
present in the catalog to avoid border effects.
add_height_catalog(cata, roi, prompt = TRUE, ncores = 2)add_height_catalog(cata, roi, prompt = TRUE, ncores = 2)
cata |
A |
roi |
|
prompt |
boolean. Should the user be prompted before plotting and normalizing ? |
ncores |
Integer, number of cores to use with |
The updated LAScatalog-class object.
## Not run: add_height_catalog## Not run: add_height_catalog
Adds the height above ground in an ExtraByte attribute H to objects of
class LAS-class or to files recorded in an object of
class LAScatalog-class, by applying the function
normalize_height
add_height_extrabyte(las)add_height_extrabyte(las)
las |
An object of class |
A LAS-class object with the H attribute in the
case. In case of a LAScatalog-class input, the function
is used for the side effect of writing files as specified in the catalog
options.
## Not run: add_height_extrabyte## Not run: add_height_extrabyte
Creer un objet cata au format LAScatalog-class
avec les fichiers LAZ situes dans un dossier et le sauvegarde dans le fichier
cata.rda a l'interieur du dossier
catalog_bloc(folder, bloc, save_on_disk = TRUE)catalog_bloc(folder, bloc, save_on_disk = TRUE)
folder |
text. folder to analyse |
bloc |
text. bloc to catalog |
save_on_disk |
boolean. Save catalog on disk or not |
A LAS catalog object
## Not run: catalog_bloc("./LidarHD/data/LAZ_classe/", "OE")## Not run: catalog_bloc("./LidarHD/data/LAZ_classe/", "OE")
Charge les objets au format LAScatalog-class presents
dans les sous-dossiers (fichiers cata.rda) et les fusionne dans un
objet cata au format LAScatalog-class sauvegarde
dans le fichier cata.rda a la racine du dossier. Si blocs est
specifie, le catalogue est mis a jour uniquement pour les fichiers de ces
blocs
catalog_folder(folder, blocs = NULL, save_on_disk = TRUE)catalog_folder(folder, blocs = NULL, save_on_disk = TRUE)
folder |
character. folder to analyse |
blocs |
character vector. subset of blocs to update |
save_on_disk |
boolean. Save catalog on disk or not |
A LAS catalog object
## Not run: catalog_folder("./LidarHD/data/LAZ_classe/")## Not run: catalog_folder("./LidarHD/data/LAZ_classe/")
Verifie que les fichiers laz sont dans le dossier correspondant a leur bloc.
Verifie que les catalogues des dossiers (fichiers cata.rda a la
racine, contenant l'objet cata au format
LAScatalog-class) correspondent aux fichiers presents.
check_folder(folder, ta = NULL)check_folder(folder, ta = NULL)
folder |
text. Folder to analyse |
ta |
sf object. Output of |
No return, the function is used to check folder
catalog_bloc to force updating of LAScatalog of a bloc,
catalog_folder to force updating LAScatalog of all blocs from the saved
LAScatalogs in each bloc, create_lax to generate missing index files.
## Not run: check_folder("./LidarHD/data/LAZ_classe/")## Not run: check_folder("./LidarHD/data/LAZ_classe/")
Ajoute un "/" a un chemin de dossier si ce n'est pas le cas
check_folder_string(folder)check_folder_string(folder)
folder |
text. folder path |
A string
check_folder_string("./LidarHD/data/LAZ_classe/LN")check_folder_string("./LidarHD/data/LAZ_classe/LN")
Compresser un fichier tif (options COMPRESS=LZW, PREDICTOR=3)
compress_tif(file)compress_tif(file)
file |
text. filename |
A boolean
Calcul des fichiers MNT a partir des fichiers LiDAR HD de l'IGN presents dans
un dossier (par exemple telecharges avec download_files) et
les enregistre dans un autre repertoire. Les fichiers MNT deja presents ne
sont pas re-calcules. Le calcul est effectuee avec la fonction
rasterize_terrain et l'algorithme tin
avec les points de classe 2 et 9. Les fichiers a traiter peuvent etre
selectionnes via une zone d'interet, il est conseille que les fichiers adjacents
soient egalement telecharges pour eviter les effets de bord.
compute_dtm( laz_folder, dtm_folder = NULL, res = 1, roi = NULL, prompt = TRUE, ncores = 2L )compute_dtm( laz_folder, dtm_folder = NULL, res = 1, roi = NULL, prompt = TRUE, ncores = 2L )
laz_folder |
Text, path to the folder that contains the laz files downloaded
from IGN. The folder should contain a "cata.rda" file with the saved
|
dtm_folder |
Text, path to the folder that contains or will contain the DTM files. If NULL a folder is created in the same directory as 'laz_folder' with name "DTM_#res#m" where #res# is parameter 'res'. |
res |
numeric, DTM resolution |
roi |
|
prompt |
boolean. Should the user be prompted before plotting and computing ? |
ncores |
Integer, number of cores to use with |
A data.frame with the files to compute the DTM from and a boolean indicating if the computation was successful or not.
## Not run: compute_dtm("./data/LAZ_classe/", res = 1, prompt = TRUE, ncores = 2L)## Not run: compute_dtm("./data/LAZ_classe/", res = 1, prompt = TRUE, ncores = 2L)
Verifie si les fichiers laz dans un dossier ont leur index lax. Propose d'indexer les fichiers qui ne le sont pas. Les fichiers au format copc (par exemple les nuages LiDAR HD fournis par l'IGN) ne sont pas indexes.
create_lax(folder, lasindex_path = NULL, proceed = FALSE, ncores = 4L)create_lax(folder, lasindex_path = NULL, proceed = FALSE, ncores = 4L)
folder |
text. folder to analyse |
lasindex_path |
text. if set to NULL, the function
|
proceed |
boolean. Automatically index files ( |
ncores |
integer. Number of cores to use in a |
Returns the number of indexed files
## Not run: create_lax("./LidarHD/data/LAZ_classe/OE/")## Not run: create_lax("./LidarHD/data/LAZ_classe/OE/")
Selectionne les dalles qui intersectent une region d'interet, ou celles
dans les blocs specifies.
Propose de les telecharger si elles ne sont pas deja dans un repertoire
indique par l'utilisateur, un sous-dossier est cree par bloc.
Les fichiers sont deja indexes (format copc).
Un objet cata au format LAScatalog-class est
sauvegarde dans chaque sous-dossier bloc, fichier cata.rda.
Un objet cata pour l'ensemble des blocs
est sauvegarde a la racine du dossier.
download_files(ta, roi = NULL, folder = NULL, buffer = TRUE, prompt = TRUE)download_files(ta, roi = NULL, folder = NULL, buffer = TRUE, prompt = TRUE)
ta |
|
roi |
|
folder |
text. Local folder for laz files. Already downloaded files should not have their names changed. They are placed in sub-directories corresponding to blocs. |
buffer |
boolean. Should tiles adjacent to tiles intersecting the roi be downloaded to avoid edge artefacts in further processing ? |
prompt |
boolean. Should the user be prompted before plotting and downloading ? |
The input object with an additional attribute containing a text
string indicated if tiles are in (dedans) or out (dehors) of roi, and if they
are already in the target folder done (fait) or todo (a_faire)).
This information is not updated in case the user asks for tiles to be downloaded.
load_classified_ta to download available tiles,
check_folder to check that the structure of the folder which contains
downloaded files is correct
## Not run: ta <- load_classified_ta() download_files(ta, folder = "./LidarHD/data/LAZ_classe/") ## End(Not run)## Not run: ta <- load_classified_ta() download_files(ta, folder = "./LidarHD/data/LAZ_classe/") ## End(Not run)
Verifie les dalles qui intersectent une region d'interet Propose de les telecharger si elles ne sont pas deja dans un repertoire indique par l'utilisateur
download_files_ch( ta, roi = NULL, las2las_path = "~/LAStools/bin/las2las", year = NULL, folder = NULL, buffer = TRUE )download_files_ch( ta, roi = NULL, las2las_path = "~/LAStools/bin/las2las", year = NULL, folder = NULL, buffer = TRUE )
ta |
sf object. Tiles available from swisstopo |
roi |
sf object. Region of interest |
las2las_path |
text. path to the |
year |
numeric. Year of data |
folder |
text. Local folder for laz files. Already downloaded files should not have their names changed |
buffer |
boolean. Should tiles adjacent to tiles intersecting the roi be downloaded to avoid edge artefacts in further processing ? |
The input object with an additional attribute containing "out_of_roi", "in_todo", "in_done". This information is not updated in case the user asks for "in_todo" tiles to be downloaded
Selectionne les dalles MNX qui intersectent une region d'interet. Propose de les telecharger si elles ne sont pas deja dans un repertoire indique par l'utilisateur
download_mnx( ta, mnx = "mnt", roi = NULL, folder = NULL, buffer = TRUE, prompt = TRUE, compress = TRUE, workers = 2 )download_mnx( ta, mnx = "mnt", roi = NULL, folder = NULL, buffer = TRUE, prompt = TRUE, compress = TRUE, workers = 2 )
ta |
|
mnx |
text. which mnx to download ( |
roi |
|
folder |
text. Local folder for files. Already downloaded files should not have their names changed. |
buffer |
boolean. Should tiles adjacent to tiles intersecting the roi be downloaded to avoid edge artefacts in further processing ? |
prompt |
boolean. Should the user be prompted before plotting and downloading ? |
compress |
boolean. Should files be compressed (LZW with predictor = 3) ? |
workers |
integer. Number of cores to use in |
The input object with an additional attribute containing a text string indicating the link to the local file.
load_classified_ta to download available tiles,
## Not run: # definir le roi roi <- c(xmin = 5.72, xmax = 5.75, ymin = 45.11, ymax = 45.14) roi <- sf::st_bbox(roi, crs = 4326) roi <- sf::st_as_sfc(roi) roi <- sf::st_transform(roi, 2154) # charger le tableau ta <- load_classified_ta(url = "https://data.geopf.fr/wfs/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=IGNF_LIDAR-HD_METADONNEE:metadata", bbox = roi) # telecharger les mnt download_mnx(ta, "mnt", roi = roi, folder = "./LidarHD/data/MNT/") ## End(Not run)## Not run: # definir le roi roi <- c(xmin = 5.72, xmax = 5.75, ymin = 45.11, ymax = 45.14) roi <- sf::st_bbox(roi, crs = 4326) roi <- sf::st_as_sfc(roi) roi <- sf::st_transform(roi, 2154) # charger le tableau ta <- load_classified_ta(url = "https://data.geopf.fr/wfs/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=IGNF_LIDAR-HD_METADONNEE:metadata", bbox = roi) # telecharger les mnt download_mnx(ta, "mnt", roi = roi, folder = "./LidarHD/data/MNT/") ## End(Not run)
Fonction qui reconstruit le nom de la dalle du nom du fichier ExtraByte
eb2nom(nom_eb)eb2nom(nom_eb)
nom_eb |
text. Tile download url |
A string
eb2nom("./LidarHD/data/LAZ_classe/LN/EB-LHD_FXX_0686_6384_PTS_C_LAMB93_IGN69.laz")eb2nom("./LidarHD/data/LAZ_classe/LN/EB-LHD_FXX_0686_6384_PTS_C_LAMB93_IGN69.laz")
Ajoute un attribut processed dans un objet au format
LAScatalog-class pour les fichiers qui intersectent une
zone d'interet definie par le nom des blocs ou une emprise spatiale.
flag_processed(cata, roi = NULL, keep_all = FALSE)flag_processed(cata, roi = NULL, keep_all = FALSE)
cata |
|
roi |
|
keep_all |
boolean. Should all tiles be kept in LAScatalog, or only tiles relevant for processing ? |
LAScatalog-class object with additionnal
processed attribute.
download_files to download tiles,
## Not run: flag_processed(cata, "OE") ## End(Not run)## Not run: flag_processed(cata, "OE") ## End(Not run)
Fonction qui extrait le nom du bloc a partir du dossier de stockage
folder2bloc(folder)folder2bloc(folder)
folder |
text. folder names |
A string
## Not run: url2meta("https://data.geopf.fr/telechargement/download/LiDARHD-NUALID/NUALHD_1-0__LAZ_LAMB93_PM_2025-03-25/LHD_FXX_0917_6452_PTS_LAMB93_IGN69.copc.laz")## Not run: url2meta("https://data.geopf.fr/telechargement/download/LiDARHD-NUALID/NUALHD_1-0__LAZ_LAMB93_PM_2025-03-25/LHD_FXX_0917_6452_PTS_LAMB93_IGN69.copc.laz")
Cette fonction cree toutes les combinaisons possibles d'annees, de mois et de jours et retourne uniquement les dates valides du calendrier (en excluant les jours inexistants comme le 31 avril ou le 29 fevrier d'une annee non bissextile).
generer_dates_valides(years, months, days)generer_dates_valides(years, months, days)
years |
Un vecteur numerique d'annees (ex: 'c(2023, 2024)'). |
months |
Un vecteur numerique de mois (1 a 12). |
days |
Un vecteur numerique de jours (1 a 31). |
Un vecteur de chaines de caracteres representant les dates valides au format '"AAAA-MM-JJ"'.
# Exemple de base generer_dates_valides(years = c(2023, 2024), months = 1:3, days = 28:31) # Limiter a une seule annee generer_dates_valides(years = 2025, months = 2, days = 27:29)# Exemple de base generer_dates_valides(years = c(2023, 2024), months = 1:3, days = 28:31) # Limiter a une seule annee generer_dates_valides(years = 2025, months = 2, days = 27:29)
Fonction qui convertit un nom de dalle en nom de fichier MNT
laz_name2tif_name(nom, res, dtm_folder)laz_name2tif_name(nom, res, dtm_folder)
nom |
text. Laz file full filename |
res |
numeric. resolution for dtm file |
dtm_folder |
test. Target folder for files |
A string
## Not run: create_lax("/media/reseau/drones/Lidar/LidarHD/data/LAZ_classe/")## Not run: create_lax("/media/reseau/drones/Lidar/LidarHD/data/LAZ_classe/")
Si une url WFS est fournie : telecharge le tableau d'assemblage des dalles : catalogue stac Theia par defaut (https://api.stac.teledetection.fr), peut telecharger egalement le tableau d'assemblage des metadonnes IGN Sinon charge un gpkg sauvegarde precedemment dans le dossier
load_classified_ta( url = "https://api.stac.teledetection.fr", save_dir = NULL, bbox = NULL )load_classified_ta( url = "https://api.stac.teledetection.fr", save_dir = NULL, bbox = NULL )
url |
text. link of the wfs source, if set to |
save_dir |
text. if specified, directory where the output is saved, with name |
bbox |
sf object from which a bbox can be extracted, with crs information |
An sf object of the tiles
## Not run: # from catalog stac # bbox exemple bbox <- c(xmin = 5.72, xmax = 5.75, ymin = 45.11, ymax = 45.14) # bbox France metrolpolitaine bbox <- c(xmin = -5.14, ymin = 41.35, xmax = 9.56, ymax = 51.10) # ajouter le crs bbox <- sf::st_bbox(bbox, crs = sf::st_crs(4326)) ta <- load_classified_ta(bbox = bbox) # from WFS IGN ta <- load_classified_ta(url="https://data.geopf.fr/wfs/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=IGNF_LIDAR-HD_METADONNEE:metadata", bbox = bbox) ## End(Not run)## Not run: # from catalog stac # bbox exemple bbox <- c(xmin = 5.72, xmax = 5.75, ymin = 45.11, ymax = 45.14) # bbox France metrolpolitaine bbox <- c(xmin = -5.14, ymin = 41.35, xmax = 9.56, ymax = 51.10) # ajouter le crs bbox <- sf::st_bbox(bbox, crs = sf::st_crs(4326)) ta <- load_classified_ta(bbox = bbox) # from WFS IGN ta <- load_classified_ta(url="https://data.geopf.fr/wfs/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=IGNF_LIDAR-HD_METADONNEE:metadata", bbox = bbox) ## End(Not run)
Telecharger manuellement la liste des fichiers sur https://www.swisstopo.admin.ch/fr/geodata/height/surface3d.html selection sur la carte avec un polygone qui englobe la suisse decocher "etat temporel" cocher "publie avant" et mettre la date du jour
load_classified_ta_ch( file = "/media/reseau/drones/Lidar/Swisstopo/data/SIG/ch.swisstopo.swisssurface3d-wNDKT0QW.csv" )load_classified_ta_ch( file = "/media/reseau/drones/Lidar/Swisstopo/data/SIG/ch.swisstopo.swisssurface3d-wNDKT0QW.csv" )
file |
text. file downloaded from swisstopo |
A sf object of the classified tiles
## Not run: ta <- load_classified_ta_ch()## Not run: ta <- load_classified_ta_ch()
Charge le MNT a 0.5 m de resolution sur l'emprise specifiee a partir du flux wms-r Ajuste l emprise sur le maillage MNT (origine a 0.25, 0.25)
load_mnx(emprise, mnx = "MNT")load_mnx(emprise, mnx = "MNT")
emprise |
vector with xmin xmax ymin max |
mnx |
string type of mnx in c("MNT", "MNS", "MNH") |
a raster.
load_classified_ta and download_mnx to download available tiles,
mnh <- load_mnx(c(917400, 917500, 6469400, 6469500), "MNH") mnhmnh <- load_mnx(c(917400, 917500, 6469400, 6469500), "MNH") mnh
Charge le fichier sauvegarde le plus recent dans un repertoire
load_saved_ta(folder = NULL)load_saved_ta(folder = NULL)
folder |
string. Folder containing the saved files, with pattern ta_YYMMDD.gpkg |
An sf object of the classified tiles and blocs
## Not run: ta <- load_saved_ta("./data/sig/ta_231218.gpkg")## Not run: ta <- load_saved_ta("./data/sig/ta_231218.gpkg")
Normalise les fichiers LiDAR HD de l'IGN presents dans un dossier (par exemple
telecharges avec download_files) et les enregistre dans un
autre repertoire. Les fichiers normalises deja presents ne sont pas re-calcules. La
normalisation est effectuee avec la fonction normalize_height
et l'algorithme tin. Les fichiers a normaliser peuvent etre
selectionnes via une zone d'interet, il est conseille que les fichiers adjacents
soient egalement telecharges pour eviter les effets de bord.
normalize_files(original, normalized, roi = NULL, prompt = TRUE, ncores = 2L)normalize_files(original, normalized, roi = NULL, prompt = TRUE, ncores = 2L)
original |
Text, path to the folder that contains the laz files downloaded
from IGN. The folder should contain a "cata.rda" file with the saved
|
normalized |
Text, path to the folder that contains or will contain the
normalized laz files. If some files are already present, the folder should contain
a "cata.rda" file with the saved |
roi |
|
prompt |
Boolean. Should the user be prompted before plotting and normalizing ? |
ncores |
Integer, number of cores to use with |
The updated LAScatalog-class object of normalized
files in the normalized folder.
## Not run: normalize_files("./data/LAZ_classe/", "./data/LAZ_norm/", prompt = TRUE, ncores = 2L)## Not run: normalize_files("./data/LAZ_classe/", "./data/LAZ_norm/", prompt = TRUE, ncores = 2L)
Modification de la chaine de caractere en enlevant "O" ou "C" et en modificant IGN69 en IGN78 pour les blocs en Corse
OVH2GP(fichier, bloc = NULL)OVH2GP(fichier, bloc = NULL)
fichier |
Vecteur de chaine de caracteres. |
bloc |
Vecteur de chaine de caracteres. |
Un vecteur de chaines de caractères
Normalisation et/ou calcul de MNT avec le package lasR
a partir des fichiers LiDAR HD de l'IGN
presents dans un dossier (par exemple telecharges avec
download_files) et les enregistre dans un autre repertoire.
Les fichiers normalises ou DTM deja presents ne sont pas re-calcules.
process_files( original, normalized = "", res = NULL, dtm_folder = NULL, roi = NULL, prompt = TRUE, lasR_options = list(ncores = lasR::concurrent_files(2L)) )process_files( original, normalized = "", res = NULL, dtm_folder = NULL, roi = NULL, prompt = TRUE, lasR_options = list(ncores = lasR::concurrent_files(2L)) )
original |
Text, path to the folder that contains the laz files downloaded
from IGN. The folder should contain a "cata.rda" file with the saved
|
normalized |
Text, path to the folder that contains or will contain the
normalized laz files. If empty string, normalisation will not be done.
If some files are already present, the folder should contain
a "cata.rda" file with the saved |
res |
numeric, DTM resolution, if NULL DTM computation will not be done. |
dtm_folder |
Text, path to the folder that contains or will contain the DTM files. If NULL a folder is created in the same directory as 'laz_folder' with name "DTM_#res#m" where #res# is parameter 'res'. |
roi |
|
prompt |
Boolean. Should the user be prompted before plotting and normalizing ? |
lasR_options |
list. Parameters passed to |
A list with the catalog of all normalised files and/or a data.frame names of computed DTMs
## Not run: process_files("./data/LAZ_classe/", "./data/LAZ_norm/", prompt = TRUE, ncores = 2L)## Not run: process_files("./data/LAZ_classe/", "./data/LAZ_norm/", prompt = TRUE, ncores = 2L)
Fonction qui extrait le nom de l'annee a partir de l'url de telechargement
url2annee(url)url2annee(url)
url |
text. Tile download url or filename |
A dataframe with the fields
Fonction qui extrait le nom du bloc a partir de l'url de telechargement
url2bloc(url)url2bloc(url)
url |
text. Tile download url |
A string
## Not run: url2bloc("https://data.geopf.fr/telechargement/download/LiDARHD-NUALID/NUALHD_1-0__LAZ_LAMB93_PM_2025-03-25/LHD_FXX_0917_6452_PTS_LAMB93_IGN69.copc.laz")## Not run: url2bloc("https://data.geopf.fr/telechargement/download/LiDARHD-NUALID/NUALHD_1-0__LAZ_LAMB93_PM_2025-03-25/LHD_FXX_0917_6452_PTS_LAMB93_IGN69.copc.laz")
Fonction qui extrait les metadonnees a partir de l'url de telechargement
url2meta(url)url2meta(url)
url |
text. Tile download url |
A data.frame
## Not run: url2meta("https://data.geopf.fr/telechargement/download/LiDARHD-NUALID/NUALHD_1-0__LAZ_LAMB93_PM_2025-03-25/LHD_FXX_0917_6452_PTS_LAMB93_IGN69.copc.laz")## Not run: url2meta("https://data.geopf.fr/telechargement/download/LiDARHD-NUALID/NUALHD_1-0__LAZ_LAMB93_PM_2025-03-25/LHD_FXX_0917_6452_PTS_LAMB93_IGN69.copc.laz")