if (FALSE) {
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)+qtm(penmarch, fill = "red")
## 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, type = "parcelle")
## from insee code
parcels <- get_apicarto_cadastre("29158", type = "parcelle")
# Use parameter recycling
## get sections "AW" parcels from multiple insee_code
parcels <- get_apicarto_cadastre(
c("29158", "29135"),
section = "AW",
type = "parcelle"
)
qtm(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)
}
Run the code above in your browser using DataLab