-
-
Notifications
You must be signed in to change notification settings - Fork 9
Examples of OGRSQL
Michael Sumner edited this page Apr 7, 2020
·
1 revision
Basic examples
library(geovctrs)
library(vapour)
file <- "list_locality_postcode_meander_valley.tab"
f <- system.file(file.path("extdata/tab", file),
package = "vapour", mustWork = TRUE)
(wkb <- geo_wkb(vapour_read_geometry(f)))[6:15]
## limit/skip
geo_wkb(vapour_read_geometry(f, skip_n = 5, limit_n = 10))
## read as wkt
geo_wkt(vapour_read_geometry_text(f, textformat = "wkt",
sql = "SELECT * FROM list_locality_postcode_meander_valley WHERE FID > 5 AND FID < 16"))
Using CAST to convert and WHERE to filter geometry type.
library(geovctrs)
library(vapour)
file <- "list_locality_postcode_meander_valley.tab"
f <- system.file(file.path("extdata/tab", file),
package = "vapour", mustWork = TRUE)
## find all multi-geoms and cast to multilinestring
wkb <- geo_wkb(vapour_read_geometry(f,
sql = "SELECT CAST(OGR_GEOM_WKT AS geometry(MULTILINESTRING)) from
list_locality_postcode_meander_valley
WHERE OGR_GEOM_WKT LIKE 'MULTI%'"))