Implementation of the cadastre module from the IGN's apicarto
Usage
get_apicarto_cadastre(x,
type = "commune",
code_com = NULL,
section = NULL,
numero = NULL,
code_arr = NULL,
code_abs = NULL,
dTolerance = 0L,
source = "pci",
progress = TRUE)
Arguments
- x
It can be a shape, insee codes or departement codes :
Shape : must be an object of class
sf
orsfc
.Code insee : must be a
character
of length 5Code departement : must be a
character
of length 2 or 3 (DOM-TOM)
- type
A
character
from"parcelle"
,"commune"
,"feuille"
,"division"
,"localisant"
- code_com
A
character
of length 5 corresponding to the commune code. Only use withtype = "division"
ortype = "feuille"
- section
A
character
of length 2- numero
A
character
of length 4- code_arr
A
character
corresponding to district code for Paris, Lyon, Marseille- code_abs
A
character
corresponding to the code of absorbed commune. This prefix is useful to differentiate between communes that have merged- dTolerance
numeric; Complex shape cannot be handle by API; using
dTolerance
allow to simplify them. See?sf::st_simplify
- source
Can be "bdp" for BD Parcellaire or "pci" for Parcellaire express. See detail for more info.
- progress
Display a progress bar? Use TRUE to turn on a basic progress bar, use a string to give it a name. See
httr2::req_perform_iterative()
.
Details
x
, section
, numero
, code_arr
, code_abs
, code_com
can take vector of character.
In this case vector recycling is done. See the example section below.
source
: BD Parcellaire is a discontinued product. Its use is no longer
recommended because it is no longer updated. The use of PCI Express is
strongly recommended and will become mandatory. More information on the
comparison of this two products can be found
here
Examples
if (FALSE) { # \dontrun{
library(sf)
library(tmap)
# shape from the town of penmarch
penmarch <- read_sf(system.file("extdata/penmarch.shp", package = "happign"))
# get commune borders
## from shape
penmarch_borders <- get_apicarto_cadastre(penmarch, type = "commune")
qtm(penmarch_borders, fill = NA)+qtm(penmarch)
## from insee_code
border <- get_apicarto_cadastre("29158", type = "commune")
borders <- get_apicarto_cadastre(c("29158", "29135"), type = "commune")
qtm(borders, fill="nom_com")
# get cadastral parcels
## from shape
parcels <- get_apicarto_cadastre(penmarch, section = "AW", type = "parcelle")
## from insee code
parcels <- get_apicarto_cadastre("29158", type = "parcelle")
# Use parameter recycling
## get sections "AX" parcels from multiple insee_code
parcels <- get_apicarto_cadastre(c("29158", "29135"), section = "AW", type = "parcelle")
qtm(penmarch_borders, fill = NA)+qtm(parcels)
## get parcels numbered "0001", "0010" of section "AW" and "BR"
section <- c("AW", "BR")
numero <- rep(c("0001", "0010"), each = 2)
parcels <- get_apicarto_cadastre("29158", section = section, numero = numero, type = "parcelle")
qtm(penmarch_borders, fill = NA)+qtm(parcels)
## generalization with expand.grid
params <- expand.grid(code_insee = c("29158", "29135"),
section = c("AW", "BR"),
numero = c("0001", "0010"),
stringsAsFactors = FALSE)
parcels <- get_apicarto_cadastre(params$code_insee,
section = params$section,
numero = params$numero,
type = "parcelle")
qtm(penmarch_borders, fill = NA)+qtm(parcels$geometry)
} # }