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. Either cmun or cmun_ine must be provided.

verbose

Logical. If TRUE, displays informational messages.

Value

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

Details

On a successful query, this function returns a tibble with one row including 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.

See also

mapSpain::esp_get_munic_siane() to get shapes of municipalities, including the INE code.

Query OVC province and municipality codes: catr_ovc_get_cod_provinces()

Search for cadastral identifiers: catr_atom_search_munic(), catr_get_code_from_coords(), catr_ovc_get_cod_provinces()

Examples

# \donttest{
# Get municipality by cadastral code
ab <- catr_ovc_get_cod_munic(cpro = 2, cmun = 900)
#>  The request could not be completed.
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Failure when receiving data from the peer [ovc.catastro.meh.es]:
#> Recv failure: Connection reset by peer
#> → Returning "NULL" because the request failed.

ab
#> NULL

# Same query using the INE code

ab2 <- catr_ovc_get_cod_munic(cpro = 2, cmun_ine = 3)
#>  The request could not be completed.
#> ! Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Failure when receiving data from the peer [ovc.catastro.meh.es]:
#> Recv failure: Connection reset by peer
#> → Returning "NULL" because the request failed.

ab2
#> NULL
# }