Skip to contents
#> Please make sure you have an internet connection.
#> Use happign::get_last_news() to display latest geoservice news.
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>     filter, lag
#> The following objects are masked from 'package:base':
#>     intersect, setdiff, setequal, union
library(tmap); tmap_mode("view"); tmap_options(check.and.fix = TRUE)
#> Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
#> remotes::install_github('r-tmap/tmap')
#> tmap mode set to interactive viewing
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE


APIs carto were developed to automatically retrieve certain spatial information required in administrative forms. The main advantage of these APIs is that they can be queried without spatial data. To do this with get_wfs, you would have to use an ECQL query with the ecql_filter argument which can be tricky.

happign implements APIs carto through get_apicarto_* functions.

API carto cadastre

Documentation :

The API carto cadastre provides following informations :

  • the boundaries of a town (type = "commune")
  • the parcel sections or divisions (type = "section" or type = "division")
  • the cadastral parcels (type = "cadastre")
  • information on non-vectorized parcels (type = "localisant")

At least three parameters must be set :

  • x : An indication about the location. Could be a shape, an insee code or a departement code
  • type : What service do you want to use? (see above)
  • source : The data source "PCI" for “Parcellaire Express” or "BDP" for “BD Parcellaire”. The BD Parcellaire product is a historical product that is no longer updated. It is therefore strongly recommended to use the Parcellaire Express product which is updated every six months.

All other parameters are used to refine the query.


We’ll start with a simple example : retrieve borders of multiple town. Because get_apicaro_cadastre is a vectorized function, it’s possible to set multiple insee code. If you do not know insee codes, you can consult existing codes from the internal dataframe cog_2023.

# all town starting with "Plou"
plou_insee_code <- cog_2023[startsWith(cog_2023$LIBELLE, "Plou"), "COM"]
plou_borders <- get_apicarto_cadastre(plou_insee_code, type = "commune")

# result
   tm_borders(col = "black")