Skip to content

Instantly share code, notes, and snippets.

@aadennis
Created June 16, 2023 15:07
Show Gist options
  • Save aadennis/6b8426c603d9f903b09808308c6d87e4 to your computer and use it in GitHub Desktop.
Save aadennis/6b8426c603d9f903b09808308c6d87e4 to your computer and use it in GitHub Desktop.
Read a shape file using st_read
require("sf")
# local variables
shapefile_name <- "LSOA_2011_EW_BFC"
shape_location <- "C:/mapdata/lsoa/boundaries/demo"
columns <- "*"
local_tempdir <- "c:/temp"
# arrange
shapefile <- paste(shape_location, "/", shapefile_name, ".shp", sep = "")
sql_query <- paste(
"select", columns, "from", shapefile_name
)
# act
map <- st_read(shapefile, query = sql_query)
map_rowcount <- nrow(map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment