sp_read | R Documentation |
sp_read
is a wrapper for rgdal::readOGR
, but its usage is the
same as the other file readers in R. Unlike rgdal::readOGR
,
sp_read
will expand file paths and make a "best-guess" on what layer
is to be loaded for spatial data files. Use sp_list_layers
to find what
layers a spatial data file contains.
sp_read( file, layer = NULL, geom = NULL, lower = TRUE, use_iconv = FALSE, verbose = TRUE )
file |
Spatial data file name. For shapefiles and Mapinfo TAB files, a
file extension is optional. For File Geodatabases, an extension is required
(usually |
layer |
Layer within |
geom |
An override for when spatial data files contain more than one
geometry type in a layer. This is commonly found in GeoJSON and KML files.
|
lower |
Should the names of the data slot be forced to be lower case?
Note that the default is |
use_iconv |
Should the input strings attempted to be converted by iconv? |
verbose |
Should information about the data be printed when being
loaded? Default is |
sp_read
will also wrap readRDS
if an .rds
file is
detected, but will raise a warning if the file does not contain a spatial
data type.
Stuart K. Grange
readOGR
, sp_list_drivers
,
sp_list_layers
## Not run: # Load a shapefile without extension sp_london <- sp_read("london_borough") # Load a shapefile with an extension within home area sp_london <- sp_read("~/Desktop/london_borough.shp") # Load a gpx file sp_hira <- sp_read("~/Desktop/hira_mtb_park.gpx", type = "tracks") # Load GeoJSON file sp_thames_locks <- sp_read("thames_locks.json", verbose = FALSE) # Load mapinfo file sp_coastline <- sp_read("nz-land-districts.map", verbose = FALSE) # Geodatabase sp_yemen <- sp_read("world.gdb", layer = "yemen", verbose = FALSE) # Load a file by using a url file <- "https://bit.ly/2FkUuAP" sp_ridgeway <- sp_read(file, layer = "routes") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.