
happign for foresters
Source:vignettes/web_only/happign_for_foresters.Rmd
happign_for_foresters.Rmd
library(happign)
library(sf)
library(dplyr)
library(ggplot2)
library(terra)
library(tmap)
tmap_mode("view")
First choose a zone of interest
For the example we will work with the Camors forest. First of all we
need the commune border that can be obtained with
get_apicarto_commune
from the insee code. For convenience,
happign
provides a table containing all insee codes
(data("com_2025")
).
data("cog_2025")
#> Warning in data("cog_2025"): data set 'cog_2025' not found
#search communes name Camors and extract insee code
insee_code <- com_2025[grepl("^Camors", com_2025$LIBELLE_COM),"COM"]
camors_border <- get_apicarto_cadastre(insee_code, type = "commune")
tm_shape(camors_border)+
tm_borders()+
tm_text("nom_com")
An other way of getting borders without Apicarto is to use ECQL language to directly query IGN WFS geoservers.
camors_border2 <- get_wfs(
layer = "ADMINEXPRESS-COG-CARTO.LATEST:commune",
ecql_filter = "nom_m LIKE 'CAMORS'"
)
#> Features downloaded : 1
# "nom_m" attribut can be found using get_wfs_attributes(layer)
Download cadastral parcel
Cadastral parcels are essential for any forest manager. Here how to
download it with get_wfs
.
layers <- get_layers_metadata("wfs", "parcellaire")
parcellaire_layer <- layers[15,1] # "CADASTRALPARCELS.PARCELLAIRE_EXPRESS:parcelle"
camors_parcels <- get_wfs(
x = camors_border,
spatial_filter = "intersects",
layer = parcellaire_layer)
#> Features downloaded : 1000...2000...3000...3605
tm_shape(camors_border)+
tm_borders(col = "red", lwd = 2)+
tm_shape(camors_parcels)+
tm_polygons(fill_alpha = 0)
#> Registered S3 method overwritten by 'jsonify':
#> method from
#> print.json jsonlite