Skip to contents

Query the OVCCallejero ConsultaMunicipioCodigos service to retrieve municipality names and codes from the Spanish Cadastre and the National Statistics Institute (INE).

Usage

catr_ovc_get_cod_munic(cpro, cmun = NULL, cmun_ine = NULL, verbose = FALSE)

Arguments

cpro

Province code returned by catr_ovc_get_cod_provinces().

cmun, cmun_ine

Municipality code as recorded by the Spanish Cadastre (cmun) or the National Statistics Institute (cmun_ine). Either cmun or cmun_ine must be provided.

verbose

Logical. Whether to display informational messages.

Value

A tibble as described in Details. Returns NULL if the request fails.

Details

On a successful query, this function returns a one-row tibble with the following columns:

  • munic: Municipality name used by the Spanish Cadastre.

  • catr_to: Cadastral territorial office code.

  • catr_munic: Municipality code as recorded by the Cadastre.

  • catrcode: Full cadastral code for the municipality.

  • cpro: Province code according to the INE.

  • cmun: Municipality code according to the INE.

  • inecode: Full INE code for the municipality.

  • Remaining fields: See the API documentation.

Examples

# \donttest{
# Get municipality by cadastral code
ab <- catr_ovc_get_cod_munic(cpro = 2, cmun = 900)

ab
#> # A tibble: 1 × 12
#>   munic  catr_to catr_munic catrcode cpro  cmun  inecode nm    cd    cmc   cp   
#>   <chr>  <chr>   <chr>      <chr>    <chr> <chr> <chr>   <chr> <chr> <chr> <chr>
#> 1 ALBAC… 02      900        02900    02    003   02003   ALBA… 2     900   2    
#> # ℹ 1 more variable: cm <chr>

# Same query using the INE code

ab2 <- catr_ovc_get_cod_munic(cpro = 2, cmun_ine = 3)

ab2
#> # A tibble: 1 × 12
#>   munic  catr_to catr_munic catrcode cpro  cmun  inecode nm    cd    cmc   cp   
#>   <chr>  <chr>   <chr>      <chr>    <chr> <chr> <chr>   <chr> <chr> <chr> <chr>
#> 1 ALBAC… 02      900        02900    02    003   02003   ALBA… 2     900   2    
#> # ℹ 1 more variable: cm <chr>
# }