Read .shp files

read_shp(file, col_spec = "?", encoding = NA, geometry_col = "geometry")

Arguments

file

A vector of filenames.

col_spec

A character vector of length one with one character for each column or one character to be used for all columns. The following characters are supported (designed to align with readr::cols()):

  • "?": Use DBF-specified field type

  • "-": Skip column

  • "c": Character

  • "i": Parse integer

  • "d": Parse double

  • "l": Parse as logical

encoding

Use NA to automatically guess encoding, "" to use system encoding, or a length-one character vector overriding the automatically detected encoding.

geometry_col

The column name in which

Value

A tibble::tibble() with geometry column created using shp_geometry().

Examples

read_shp(shp_example("mexico/cities.shp"))
#> # A tibble: 36 x 5 #> NAME CAPITAL STATE_NAME POPULATION geometry #> <chr> <chr> <chr> <dbl> <shp:point> #> 1 Monterrey Y Nuevo Leon 2015000 (-100.31709 25.67735) #> 2 Mazatlan N Sinaloa 199830 (-106.41607 23.20383) #> 3 Guadalajara Y Jalisco 2325000 (-103.34380 20.67359) #> 4 Tampico N Tamaulipas 435000 ( -97.84263 22.24323) #> 5 Mexico City C Distrito Federal 14100000 ( -99.12757 19.42705) #> 6 Puebla de Zarag… Y Puebla 1055000 ( -98.19295 19.04863) #> 7 Veracruz N Veracruz-Llave 385000 ( -96.08524 19.00683) #> 8 Oaxaca Y Oaxaca 154223 ( -96.95135 16.90743) #> 9 Merida Y Yucatan 400142 ( -89.55286 20.82187) #> 10 Mexicali Y Baja California No… 365000 (-115.29424 32.62020) #> # … with 26 more rows