├── .Rbuildignore ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── GDALSQL.R ├── translate.R └── zzz.R ├── README.Rmd ├── README.md ├── RGDALSQL.Rproj ├── codecov.yml ├── data-raw ├── GDB-Deloraine.R ├── geopackage-vector.R └── hsh.R ├── inst └── extdata │ ├── BNA │ └── hsh.bna │ ├── Deloraine_Area_100_Year_AEP_statewide.gdb │ ├── a00000001.TablesByName.atx │ ├── a00000001.gdbindexes │ ├── a00000001.gdbtable │ ├── a00000001.gdbtablx │ ├── a00000002.gdbtable │ ├── a00000002.gdbtablx │ ├── a00000003.gdbindexes │ ├── a00000003.gdbtable │ ├── a00000003.gdbtablx │ ├── a00000004.CatItemsByPhysicalName.atx │ ├── a00000004.CatItemsByType.atx │ ├── a00000004.FDO_UUID.atx │ ├── a00000004.freelist │ ├── a00000004.gdbindexes │ ├── a00000004.gdbtable │ ├── a00000004.gdbtablx │ ├── a00000004.spx │ ├── a00000005.CatItemTypesByName.atx │ ├── a00000005.CatItemTypesByParentTypeID.atx │ ├── a00000005.CatItemTypesByUUID.atx │ ├── a00000005.gdbindexes │ ├── a00000005.gdbtable │ ├── a00000005.gdbtablx │ ├── a00000006.CatRelsByDestinationID.atx │ ├── a00000006.CatRelsByOriginID.atx │ ├── a00000006.CatRelsByType.atx │ ├── a00000006.FDO_UUID.atx │ ├── a00000006.gdbindexes │ ├── a00000006.gdbtable │ ├── a00000006.gdbtablx │ ├── a00000007.CatRelTypesByBackwardLabel.atx │ ├── a00000007.CatRelTypesByDestItemTypeID.atx │ ├── a00000007.CatRelTypesByForwardLabel.atx │ ├── a00000007.CatRelTypesByName.atx │ ├── a00000007.CatRelTypesByOriginItemTypeID.atx │ ├── a00000007.CatRelTypesByUUID.atx │ ├── a00000007.gdbindexes │ ├── a00000007.gdbtable │ ├── a00000007.gdbtablx │ ├── a00000009.gdbindexes │ ├── a00000009.gdbtable │ ├── a00000009.gdbtablx │ ├── a00000009.spx │ ├── gdb │ └── timestamps │ ├── GPKG │ └── afile.gpkg │ ├── continents │ ├── continent.dbf │ ├── continent.prj │ ├── continent.shp │ └── continent.shx │ ├── hsh.gpkg │ └── shapes.gpkg ├── man ├── GDALSQL.Rd ├── GDALSQLConnection-class.Rd ├── GDALSQLDriver-class.Rd ├── GDALSQLResult-class.Rd ├── dbFetch-GDALSQLResult-method.Rd └── dbSendQuery-GDALSQLConnection-method.Rd └── tests ├── testthat.R └── testthat └── test-dbitest.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^data-raw$ 4 | ^README\.Rmd$ 5 | ^README-.*\.png$ 6 | ^\.travis\.yml$ 7 | ^codecov\.yml$ 8 | ^docs$ 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: required 5 | cache: packages 6 | 7 | # https://github.com/ropensci/rgbif/blob/master/.travis.yml#L9 8 | dist: trusty 9 | 10 | before_install: 11 | - sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes 12 | - sudo apt-get --yes --force-yes update -qq 13 | - sudo apt-get install -y libudunits2-dev libproj-dev libgeos++-dev libgdal-dev 14 | 15 | 16 | # We use clang, --without-libtool and --with-debug for faster build 17 | compiler: 18 | - clang 19 | 20 | after_success: 21 | - Rscript -e 'covr::codecov()' 22 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RGDALSQL 2 | Type: Package 3 | Title: GDAL SQL Interface for R 4 | Version: 0.1.0.9001 5 | Authors@R: c( 6 | person("Michael D.", "Sumner", , "mdsumner@gmail.com", c("aut", "cre")) 7 | ) 8 | Description: A (WIP) DBI Compliant Interface for GDAL. 9 | License: GPL-3 10 | Encoding: UTF-8 11 | LazyData: true 12 | Imports: 13 | DBI (>= 0.3.0), 14 | methods, 15 | tibble, 16 | vapour (>= 0.5.5.9001), 17 | wk 18 | Suggests: 19 | DBItest, 20 | testthat, 21 | covr, 22 | roxygen2 23 | ByteCompile: yes 24 | URL: https://github.com/mdsumner/RGDALSQL 25 | BugReports: https://github.com/mdsumner/RGDALSQL/issues 26 | RoxygenNote: 7.1.1 27 | Remotes: hypertidy/vapour 28 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(db_query_fields,GDALSQLConnection) 4 | export(GDALSQL) 5 | exportClasses(GDALSQLConnection) 6 | exportClasses(GDALSQLDriver) 7 | exportClasses(GDALSQLResult) 8 | exportMethods(dbClearResult) 9 | exportMethods(dbConnect) 10 | exportMethods(dbDataType) 11 | exportMethods(dbDisconnect) 12 | exportMethods(dbExistsTable) 13 | exportMethods(dbFetch) 14 | exportMethods(dbGetInfo) 15 | exportMethods(dbHasCompleted) 16 | exportMethods(dbListTables) 17 | exportMethods(dbReadTable) 18 | exportMethods(dbSendQuery) 19 | exportMethods(dbUnloadDriver) 20 | exportMethods(show) 21 | import(DBI) 22 | import(methods) 23 | importFrom(dplyr,db_query_fields) 24 | importFrom(utils,head) 25 | importFrom(vapour,vapour_layer_names) 26 | importFrom(vapour,vapour_read_attributes) 27 | importFrom(vapour,vapour_read_geometry_text) 28 | importFrom(wk,new_wk_wkb) 29 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # dev 2 | 3 | * Update to use of wk. 4 | 5 | # RGDALSQL 0.1.0 6 | 7 | * basic stub of dbConnect, examples and package scaffolding 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /R/GDALSQL.R: -------------------------------------------------------------------------------- 1 | #' Driver for GDAL SQL. 2 | #' 3 | #' @keywords internal 4 | #' @export 5 | #' @import DBI 6 | #' @import methods 7 | setClass("GDALSQLDriver", contains = "DBIDriver") 8 | 9 | #setOldClass("tbl_df") 10 | setOldClass(c("wk_wkb", "wk_vctr")) 11 | setOldClass(c("wk_wkt", "wk_vctr")) 12 | 13 | 14 | 15 | #' @export 16 | #' @rdname GDALSQLDriver-class 17 | setMethod("dbUnloadDriver", "GDALSQLDriver", function(drv, ...) { 18 | TRUE 19 | }) 20 | 21 | 22 | 23 | 24 | 25 | #' GDALSQL 26 | #' 27 | #' GDALSQL driver 28 | #' @export 29 | GDALSQL <- function() { 30 | new("GDALSQLDriver") 31 | } 32 | 33 | 34 | #' GDALSQL connection class. 35 | #' @rdname GDALSQLConnection-class 36 | #' @export 37 | #' @keywords internal 38 | setClass("GDALSQLConnection", 39 | contains = "DBIConnection", 40 | slots = list( 41 | host = "character", 42 | username = "character", 43 | DSN = "character", 44 | bigint = "character" 45 | ) 46 | ) 47 | 48 | 49 | #' @rdname GDALSQLConnection-class 50 | #' @export 51 | setMethod("show", "GDALSQLConnection", function(object) { 52 | cat("\n") 53 | tables <- DBI::dbListTables(object) 54 | cat(" DSN: ", object@DSN, "\n", sep = "") 55 | cat("tables: ", paste(tables, collapse = ", "), "\n", sep = "") 56 | }) 57 | #' dbConnect 58 | #' 59 | #' dbConnect 60 | #' 61 | #' @param drv GDALSQLDriver created by \code{GDALSQL()} 62 | #' @param DSN data source name, may be a file, or folder path, database connection string, or URL 63 | #' @param readonly open in readonly mode? 64 | #' @export 65 | #' @rdname GDALSQL 66 | #' @examples 67 | #' \dontrun{ 68 | #' ## this is a nothing connection 69 | #' db <- dbConnect(RGDALSQL::GDALSQL()) 70 | #' afile <- system.file("extdata", "shapes.gpkg", package = "RGDALSQL") 71 | #' db <- dbConnect(RGDALSQL::GDALSQL(), afile) 72 | #' dbSendQuery(db, "SELECT * FROM sids") 73 | #' } 74 | setMethod("dbConnect", "GDALSQLDriver", 75 | function(drv, DSN = "", readonly = TRUE, ..., 76 | bigint = c("integer64", "integer", "numeric", "character")) { 77 | new("GDALSQLConnection", host = "", DSN = DSN, ..., bigint = bigint) 78 | }) 79 | #' @export 80 | setMethod("show", "GDALSQLDriver", function(object) { 81 | cat("\n") 82 | }) 83 | #' @export 84 | setMethod("dbDisconnect", "GDALSQLConnection", 85 | function(conn, ...) { 86 | conn@DSN <- "" 87 | conn 88 | }) 89 | 90 | 91 | #' GDALSQL results class 92 | #' 93 | #' @keywords internal 94 | #' @export 95 | setClass("GDALSQLResult", 96 | contains = "DBIResult", 97 | slots = c(layer_data = "list", layer_geom = "wk_vctr", geom_name = "character") 98 | ) 99 | 100 | #' Send a query to GDALSQL. 101 | #' 102 | #' @param conn database connection, s created by \code{\link{dbConnect}} 103 | #' @param statement OGR SQL, see http://www.gdal.org/ogr_sql.html 104 | #' @param ... for compatibility with generic 105 | #' @export 106 | #' @importFrom vapour vapour_read_attributes vapour_read_geometry_text 107 | #' @importFrom wk new_wk_wkb 108 | #' @examples 109 | #' afile <- system.file("extdata", "shapes.gpkg", package = "RGDALSQL") 110 | #' db <- dbConnect(RGDALSQL::GDALSQL(), afile) 111 | #' dbSendQuery(db, "SELECT * FROM sids WHERE FID < 1") 112 | setMethod("dbSendQuery", "GDALSQLConnection", 113 | function(conn, statement, ...) { 114 | ## FIXME: may not be a file 115 | DSN <- normalizePath(conn@DSN, mustWork = FALSE) 116 | 117 | layer_data <- try(vapour::vapour_read_attributes(DSN, sql = statement), silent = TRUE) 118 | 119 | if (inherits(layer_data, "try-error")) { 120 | message("executing SQL failed:") 121 | writeLines(statement) 122 | if (length(gregexpr("SELECT", statement)[[1]]) > 1) { 123 | stop("perhaps driver in use does not support sub-queries?") 124 | } else { 125 | stop("") 126 | } 127 | } 128 | layer_geom <- wk::new_wk_wkb(vapour::vapour_read_geometry(DSN, sql = statement)) 129 | geom_name <- geom_name <- vapour::vapour_geom_name(DSN, sql = statement) 130 | new("GDALSQLResult", 131 | layer_data = layer_data, 132 | layer_geom = layer_geom, 133 | geom_name = geom_name) 134 | 135 | }) 136 | 137 | 138 | #' @export 139 | setMethod("dbClearResult", "GDALSQLResult", function(res, ...) { 140 | ## FIXME maybe a ResetReading here if we use a pointer not a DSN string? 141 | TRUE 142 | }) 143 | #' @importFrom utils head 144 | #' @export 145 | setMethod("show", "GDALSQLResult", 146 | function(object) { 147 | cat(sprintf("Field names: %s\n", 148 | paste(names(object@layer_data), collapse = ", "))) 149 | cat(sprintf("Geometry (%i features): \n%s", 150 | length(object@layer_geom), 151 | paste(utils::head(object@layer_geom), collapse = "\n"))) 152 | invisible(NULL) 153 | }) 154 | #' Retrieve records from GDALSQL query 155 | #' @export 156 | setMethod("dbFetch", "GDALSQLResult", function(res, n = -1, ...) { 157 | new_tib <- FALSE 158 | layer <- tibble::as_tibble(res@layer_data) 159 | if (nrow(layer) < 1) { 160 | new_tib <- TRUE 161 | } 162 | geom_name <- res@geom_name 163 | if (geom_name[1L] == "") { 164 | geom_name <- getOption("RGDALSQL.default.geom.name") 165 | } 166 | 167 | if (!geom_name %in% names(layer) && !all(is.na(res@layer_geom))) { 168 | if (new_tib) { 169 | layer <- tibble::as_tibble(setNames(list(res@layer_geom), geom_name)) 170 | } else { 171 | layer[[geom_name]] <- res@layer_geom 172 | } 173 | } 174 | layer 175 | }) 176 | 177 | 178 | #' @export 179 | setMethod("dbHasCompleted", "GDALSQLResult", function(res, ...) { 180 | TRUE 181 | }) 182 | 183 | 184 | 185 | #' @export 186 | setMethod("dbReadTable", c(conn = "GDALSQLConnection", name = "character"), 187 | function(conn, name, ...){ 188 | x <- dbSendQuery(conn, sprintf("SELECT * FROM %s", name)) 189 | dbFetch(x) 190 | }) 191 | 192 | 193 | #' @importFrom vapour vapour_layer_names 194 | #' @export 195 | setMethod("dbListTables", c(conn = "GDALSQLConnection"), 196 | function(conn, ...){ 197 | x <- vapour::vapour_layer_names(conn@DSN) 198 | }) 199 | 200 | #' @export 201 | setMethod("dbExistsTable", c(conn = "GDALSQLConnection"), 202 | function(conn, name, ...){ 203 | name %in% dbListTables(conn) 204 | }) 205 | 206 | #' @export 207 | setMethod("dbDataType", "GDALSQLDriver", function(dbObj, obj, ...) { 208 | ## see "type of the fields" http://www.gdal.org/ogr_sql.html 209 | ## vapour::vapour_read_attributes(normalizePath(f), sql = "SELECT CAST(osm_id AS integer(8)) AS OSM_ FROM points LIMIT 1") 210 | if (is.factor(obj)) return("character") 211 | if (is.data.frame(obj)) return(callNextMethod(dbObj, obj)) 212 | 213 | switch(typeof(obj), 214 | logical = "boolean", 215 | character = "character", 216 | double = "numeric", 217 | integer = "integer", 218 | list = "character", 219 | raw = "character", 220 | blob = "character", 221 | stop("Unsupported type", call. = FALSE) 222 | ) 223 | } 224 | 225 | 226 | ) 227 | #' @export 228 | setMethod("dbGetInfo", "GDALSQLDriver", 229 | function(dbObj, ...) { 230 | list(name = "GDALSQLDriver", 231 | note = "virtual SQL driver for GDAL", 232 | driver.version = "0.0.1.9001", 233 | client.version = "0.0.1.9001") 234 | }) 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /R/translate.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | #' @importFrom dplyr db_query_fields 3 | db_query_fields.GDALSQLConnection <- function(con, sql, ...) { 4 | sql <- dplyr::sql_select(con, dplyr::sql("*"), sql, limit = 1) 5 | 6 | qry <- DBI::dbSendQuery(con, sql) 7 | on.exit(DBI::dbClearResult(qry)) 8 | 9 | res <- dbFetch(qry, 0) 10 | # browser() 11 | # res <- vapour::vapour_report_attributes(con@DSN, sql = sql) 12 | # geom <- vapour::vapour_geom_name(con@DSN, sql = sql) 13 | # if (nchar(geom) < 1) geom <- getOption("RGDALSQL.default.geom.name") 14 | # c(names(res), geom) 15 | names(res) 16 | } 17 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | RGDALSQL_default_options <- list( 4 | ## weird name, but is the default when none exists aand SQL is executed (otherwise it is "") 5 | RGDALSQL.default.geom.name = "_ogr_geometry_" 6 | ) 7 | 8 | .onLoad <- function(libname, pkgname) { 9 | op <- options() 10 | toset <- !(names(RGDALSQL_default_options) %in% names(op)) 11 | if (any(toset)) options(RGDALSQL_default_options[toset]) 12 | 13 | invisible() 14 | } 15 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | editor_options: 4 | chunk_output_type: console 5 | --- 6 | 7 | 8 | 9 | ```{r, echo = FALSE} 10 | knitr::opts_chunk$set( 11 | collapse = TRUE, 12 | comment = "#>", 13 | fig.path = "README-" 14 | ) 15 | ``` 16 | 17 | [![Travis-CI Build Status](https://travis-ci.org/mdsumner/RGDALSQL.svg?branch=master)](https://travis-ci.org/mdsumner/RGDALSQL) 18 | [![Coverage Status](https://img.shields.io/codecov/c/github/mdsumner/RGDALSQL/master.svg)](https://codecov.io/github/mdsumner/RGDALSQL?branch=master) 19 | 20 | 21 | ## RGDALSQL 22 | 23 | WIP 24 | 25 | ```{r} 26 | library(RGDALSQL) 27 | f = system.file("extdata/continents", package = "RGDALSQL") 28 | db <- dbConnect(RGDALSQL::GDALSQL(), f) 29 | dbSendQuery(db, "SELECT * FROM continent WHERE FID < 1") 30 | 31 | 32 | res <- dbSendQuery(db, "SELECT * FROM continent WHERE continent LIKE '%ca'") 33 | dbFetch(res) 34 | 35 | (res <- dbReadTable(db, "continent")) 36 | 37 | dplyr::tbl(db, "continent") 38 | ``` 39 | 40 | ## Limitations 41 | 42 | * currently read-only, so no temporary tables for `compute()` 43 | * no temporary tables in non-DB drivers (i.e. GPKG is ok, SHP is not) 44 | * no sub-queryies in non-DB drivers (i.e. no collapse for SHP or GDB) 45 | 46 | filter, arrange, summarize, transmute, mutate, ok but cannot be chained for nested sub-queries 47 | 48 | 49 | 50 | 51 | ```{r} 52 | library(dplyr) 53 | tbl(db, "continent") %>% dplyr::filter(continent == "Australia") 54 | 55 | 56 | tbl(db, "continent") %>% dplyr::filter(continent %in% c("Australia", "Antarctica")) %>% collect() 57 | ``` 58 | 59 | Try OSM PBF. 60 | 61 | ```{r, eval=FALSE} 62 | # wget https://download.geofabrik.de/europe/albania-latest.osm.pbf 63 | f <- fs::path_expand("~/albania-latest.osm.pbf") 64 | pbf <- dbConnect(RGDALSQL::GDALSQL(),f) 65 | ## we have to use a normalized path 66 | ## (vapour doesn't do this yet, but GDALSQL will do it *when connecting*, 67 | ## currently maintains the input DSN) 68 | pbf 69 | # db_list_tables(pbf) 70 | 71 | tbl(pbf, "points") 72 | # Source: table [?? x 11] 73 | # Database: GDALSQLConnection 74 | osm_id name barrier highway ref address is_in place man_made other_tags `_ogr_geometry_` 75 | 76 | 1 154606… "" "" "traffic… "" "" "" "" "" "\"crossing\"=>\"traffic_signals\",\… \"uncontrolled\"" \"traffic_signals\",\… \"uncontrolled\"" \"traffic_signals\",\… \"uncontrolled\",\"su… \"peak\"" \"peak\"" \"peak\",\"wikidata\"=… \"peak\",\"prominence\… % filter(osm_id == "53292") %>% select(`_ogr_geometry_`, type) 89 | # Source: lazy query [?? x 2] 90 | # Database: GDALSQLConnection 91 | type `_ogr_geometry_` 92 | 93 | 1 boundary 94 | ``` 95 | 96 | 97 | ```{r} 98 | f <- "inst/extdata/shapes.gpkg" 99 | conn <- dbConnect(RGDALSQL::GDALSQL(),f) 100 | conn 101 | dbListTables(conn) 102 | 103 | x <- dbSendQuery(conn, "SELECT * FROM sids WHERE SID74 < 10") 104 | 105 | tbl(conn, "sids") %>% 106 | arrange(desc(AREA)) %>% 107 | transmute(a = AREA *8, geom, AREA) %>% 108 | filter(a > 1.62) %>% 109 | show_query() 110 | 111 | 112 | ## with SHP we can't do subquery 113 | f <- system.file("shape/nc.shp", package = "sf") 114 | conn <- dbConnect(GDALSQL(), f) 115 | ## but the special variables are there 116 | tbl(conn, "nc") %>% arrange(OGR_GEOM_AREA) 117 | tbl(conn, "nc") %>% arrange(OGR_GEOM_AREA, FID) %>% show_query() 118 | 119 | ## FAILS because subquery 120 | tbl(conn, "nc") %>% mutate(aa = AREA) %>% transmute(a1 = FID) %>% show_query() 121 | 122 | ## ok because a single statement 123 | tbl(conn, "nc") %>% transmute(a1 = FID, aa = AREA) %>% collect() 124 | 125 | ``` 126 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [![Travis-CI Build 5 | Status](https://travis-ci.org/mdsumner/RGDALSQL.svg?branch=master)](https://travis-ci.org/mdsumner/RGDALSQL) 6 | [![Coverage 7 | Status](https://img.shields.io/codecov/c/github/mdsumner/RGDALSQL/master.svg)](https://codecov.io/github/mdsumner/RGDALSQL?branch=master) 8 | 9 | ## RGDALSQL 10 | 11 | WIP 12 | 13 | ``` r 14 | library(RGDALSQL) 15 | f = system.file("extdata/continents", package = "RGDALSQL") 16 | db <- dbConnect(RGDALSQL::GDALSQL(), f) 17 | dbSendQuery(db, "SELECT * FROM continent WHERE FID < 1") 18 | #> Field names: CONTINENT 19 | #> Geometry (1 features): 20 | #> 21 | 22 | 23 | res <- dbSendQuery(db, "SELECT * FROM continent WHERE continent LIKE '%ca'") 24 | dbFetch(res) 25 | #> # A tibble: 4 x 2 26 | #> CONTINENT `_ogr_geometry_` 27 | #> 28 | #> 1 North America 2 Africa 3 South America 4 Antarctica # A tibble: 8 x 2 35 | #> CONTINENT `_ogr_geometry_` 36 | #> 37 | #> 1 Asia 2 North America 3 Europe 4 Africa 5 South America 6 Oceania 7 Australia 8 Antarctica # Source: table [?? x 2] 48 | #> # Database: GDALSQLConnection 49 | #> CONTINENT `_ogr_geometry_` 50 | #> 51 | #> 1 Asia 2 North America 3 Europe 4 Africa 5 South America 6 Oceania 7 Australia 8 Antarctica 73 | #> Attaching package: 'dplyr' 74 | #> The following objects are masked from 'package:stats': 75 | #> 76 | #> filter, lag 77 | #> The following objects are masked from 'package:base': 78 | #> 79 | #> intersect, setdiff, setequal, union 80 | tbl(db, "continent") %>% dplyr::filter(continent == "Australia") 81 | #> # Source: lazy query [?? x 2] 82 | #> # Database: GDALSQLConnection 83 | #> CONTINENT `_ogr_geometry_` 84 | #> 85 | #> 1 Australia % dplyr::filter(continent %in% c("Australia", "Antarctica")) %>% collect() 89 | #> # A tibble: 2 x 2 90 | #> CONTINENT `_ogr_geometry_` 91 | #> 92 | #> 1 Australia 2 Antarctica [?? x 11] 110 | # Database: GDALSQLConnection 111 | osm_id name barrier highway ref address is_in place man_made other_tags `_ogr_geometry_` 112 | 113 | 1 154606… "" "" "traffic… "" "" "" "" "" "\"crossing\"=>\"traffic_signals\",\… \"uncontrolled\"" \"traffic_signals\",\… \"uncontrolled\"" \"traffic_signals\",\… \"uncontrolled\",\"su… \"peak\"" \"peak\"" \"peak\",\"wikidata\"=… \"peak\",\"prominence\… % filter(osm_id == "53292") %>% select(`_ogr_geometry_`, type) 126 | # Source: lazy query [?? x 2] 127 | # Database: GDALSQLConnection 128 | type `_ogr_geometry_` 129 | 130 | 1 boundary 131 | ``` 132 | 133 | ``` r 134 | f <- "inst/extdata/shapes.gpkg" 135 | conn <- dbConnect(RGDALSQL::GDALSQL(),f) 136 | conn 137 | #> 138 | #> DSN: inst/extdata/shapes.gpkg 139 | #> tables: sids 140 | dbListTables(conn) 141 | #> [1] "sids" 142 | 143 | x <- dbSendQuery(conn, "SELECT * FROM sids WHERE SID74 < 10") 144 | 145 | tbl(conn, "sids") %>% 146 | arrange(desc(AREA)) %>% 147 | transmute(a = AREA *8, geom, AREA) %>% 148 | filter(a > 1.62) %>% 149 | show_query() 150 | #> 151 | #> Warning: Ignoring sort order. 152 | #> Hint: `arrange()` only has an effect if used at the end of a pipe or immediately before `head()`. See `?arrange.tbl_lazy` for details. 153 | #> SELECT * 154 | #> FROM (SELECT "AREA" * 8.0 AS "a", "geom", "AREA" 155 | #> FROM "sids") "dbplyr_001" 156 | #> WHERE ("a" > 1.62) 157 | 158 | 159 | ## with SHP we can't do subquery 160 | f <- system.file("shape/nc.shp", package = "sf") 161 | conn <- dbConnect(GDALSQL(), f) 162 | ## but the special variables are there 163 | tbl(conn, "nc") %>% arrange(OGR_GEOM_AREA) 164 | #> # Source: table [?? x 15] 165 | #> # Database: GDALSQLConnection 166 | #> # Ordered by: OGR_GEOM_AREA 167 | #> AREA PERIMETER CNTY_ CNTY_ID NAME FIPS FIPSNO CRESS_ID BIR74 SID74 NWBIR74 168 | #> 169 | #> 1 0.042 0.999 2238 2238 New … 37129 37129 65 5526 12 1633 170 | #> 2 0.044 1.16 1887 1887 Chow… 37041 37041 21 751 1 368 171 | #> 3 0.051 1.10 2109 2109 Clay 37043 37043 22 284 0 1 172 | #> 4 0.053 1.17 1848 1848 Pasq… 37139 37139 70 1638 3 622 173 | #> 5 0.059 1.32 1927 1927 Mitc… 37121 37121 61 671 0 1 174 | #> 6 0.06 1.04 2071 2071 Polk 37149 37149 75 533 1 95 175 | #> 7 0.061 1.23 1827 1827 Alle… 37005 37005 3 487 0 10 176 | #> 8 0.062 1.55 1834 1834 Camd… 37029 37029 15 286 0 115 177 | #> 9 0.063 1 1881 1881 Perq… 37143 37143 72 484 1 230 178 | #> 10 0.064 1.21 1892 1892 Avery 37011 37011 6 781 0 4 179 | #> # … with more rows, and 4 more variables: BIR79 , SID79 , 180 | #> # NWBIR79 , `_ogr_geometry_` 181 | tbl(conn, "nc") %>% arrange(OGR_GEOM_AREA, FID) %>% show_query() 182 | #> 183 | #> SELECT * 184 | #> FROM "nc" 185 | #> ORDER BY "OGR_GEOM_AREA", "FID" 186 | 187 | ## FAILS because subquery 188 | tbl(conn, "nc") %>% mutate(aa = AREA) %>% transmute(a1 = FID) %>% show_query() 189 | #> 190 | #> SELECT "FID" AS "a1" 191 | #> FROM (SELECT "AREA", "PERIMETER", "CNTY_", "CNTY_ID", "NAME", "FIPS", "FIPSNO", "CRESS_ID", "BIR74", "SID74", "NWBIR74", "BIR79", "SID79", "NWBIR79", "_ogr_geometry_", "AREA" AS "aa" 192 | #> FROM "nc") "dbplyr_002" 193 | 194 | ## ok because a single statement 195 | tbl(conn, "nc") %>% transmute(a1 = FID, aa = AREA) %>% collect() 196 | #> # A tibble: 100 x 3 197 | #> a1 aa `_ogr_geometry_` 198 | #> 199 | #> 1 0 0.114 2 1 0.061 3 2 0.143 4 3 0.07 5 4 0.153 6 5 0.097 7 6 0.062 8 7 0.091 9 8 0.118 208 | #> 10 9 0.124 209 | #> # … with 90 more rows 210 | ``` 211 | -------------------------------------------------------------------------------- /RGDALSQL.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace,vignette 22 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | -------------------------------------------------------------------------------- /data-raw/GDB-Deloraine.R: -------------------------------------------------------------------------------- 1 | #cp /rdsi/PUBLIC/raad/data/listdata.thelist.tas.gov.au/opendata/data/Deloraine_Area_100_Year_AEP_statewide.gdb -R inst/extdata/ 2 | -------------------------------------------------------------------------------- /data-raw/geopackage-vector.R: -------------------------------------------------------------------------------- 1 | library(rgdal2) 2 | 3 | ds <- system.file("shapes", package = "maptools") 4 | system(sprintf("ogr2ogr data-raw/shapes.gpkg %s sids -f GPKG", ds)) 5 | 6 | file.copy("data-raw/shapes.gpkg", "inst/extdata/shapes.gpkg") 7 | file.remove("data-raw/shapes.gpkg") 8 | 9 | ## creation ok but writing layers with rgdal2 is not yet possible 10 | ## 11 | # layer <- openOGRLayer(system.file("shapes", package = "maptools")) 12 | # 13 | # newDS <- newOGRDatasource(driver = "GPKG", fname = "data-raw/shapes.gpkg", 14 | # opts = character()) 15 | # sx <- addLayer(newDS, 16 | # lyrname = getLayerName(layer), 17 | # geomType = "Polygon", # rgdal2::getGeometryType(layer), 18 | # srs = getSRS(layer), 19 | # opts = character()) 20 | # 21 | # 22 | # 23 | # dataset <- openOGR(system.file("shapes", package = "maptools")) 24 | # copyDataset(dataset, file = "data-raw/shapes.gpkg", driver = "GPKG", 25 | # opts = character()) 26 | -------------------------------------------------------------------------------- /data-raw/hsh.R: -------------------------------------------------------------------------------- 1 | 2 | library(spbabel) 3 | sph <- spbabel::sp(holey) 4 | sph@data <- as.data.frame(sph@data) 5 | sph$ch <- letters[seq(nrow(sph))] 6 | sph@proj4string <- CRS("+proj=laea +lon_0=147 +lat_0=-42 +units=km") 7 | rgdal::writeOGR(sph, "inst/extdata/hsh.gpkg", "hsh", "GPKG", overwrite = TRUE) 8 | 9 | ## just for laughs 10 | rgdal::writeOGR(sph, "inst/extdata/BNA/hsh.bna", "hsh", "BNA", overwrite = TRUE) 11 | 12 | ## very funny 13 | ## mapview::mapview(sp("inst/extdata/BNA/hsh.bna", crs = proj4string(sph))) 14 | -------------------------------------------------------------------------------- /inst/extdata/BNA/hsh.bna: -------------------------------------------------------------------------------- 1 | "1","a",37 2 | 0.0,0.0 3 | 0.0,19.0 4 | 46.0,19.0 5 | 46.0,0.0 6 | 0.0,0.0 7 | 7.0,6.0 8 | 13.0,6.0 9 | 13.0,13.0 10 | 7.0,13.0 11 | 7.0,6.0 12 | 0.0,0.0 13 | 18.0,1.0 14 | 24.0,1.0 15 | 24.0,12.0 16 | 18.0,12.0 17 | 18.0,1.0 18 | 0.0,0.0 19 | 31.0,4.0 20 | 37.0,4.0 21 | 37.0,11.0 22 | 31.0,11.0 23 | 31.0,4.0 24 | 0.0,0.0 25 | 18.4,6.9 26 | 18.4,7.5 27 | 18.6,7.7 28 | 18.8,7.5 29 | 18.8,6.9 30 | 18.6,6.7 31 | 18.4,6.9 32 | 0.0,0.0 33 | 31.0,27.0 34 | 31.0,34.0 35 | 37.0,34.0 36 | 37.0,24.0 37 | 31.0,27.0 38 | 0.0,0.0 39 | "2","b",6 40 | 0.0,19.0 41 | 21.0,32.0 42 | 31.0,27.0 43 | 37.0,24.0 44 | 46.0,19.0 45 | 0.0,19.0 46 | "3","c",13 47 | 18.0,1.0 48 | 18.0,12.0 49 | 24.0,12.0 50 | 24.0,1.0 51 | 18.0,1.0 52 | 18.4,6.9 53 | 18.6,6.7 54 | 18.8,6.9 55 | 18.8,7.5 56 | 18.6,7.7 57 | 18.4,7.5 58 | 18.4,6.9 59 | 18.0,1.0 60 | -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.TablesByName.atx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.TablesByName.atx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.gdbtablx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000001.gdbtablx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000002.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000002.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000002.gdbtablx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000002.gdbtablx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000003.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000003.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000003.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000003.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000003.gdbtablx: -------------------------------------------------------------------------------- 1 | $  -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.CatItemsByPhysicalName.atx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.CatItemsByPhysicalName.atx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.CatItemsByType.atx: -------------------------------------------------------------------------------- 1 | {70737809-852C-4A03-9E22-2CECEA5B9BFA}{C673FE0F-7280-404F-8532-20755DD8FC06}{F3783E6F-65CA-4514-8315-CE3985DAD3B1}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.FDO_UUID.atx: -------------------------------------------------------------------------------- 1 | {0F280C97-A630-47C5-80CA-F7A69BF2DBF8}{C017154F-98B9-4BD5-9755-A6E4C9D8CF72}{F9CFCAEC-7127-4631-8803-8FEC6E266B79}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.freelist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.freelist -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.gdbtablx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.gdbtablx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000004.spx: -------------------------------------------------------------------------------- 1 | @ -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.CatItemTypesByName.atx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.CatItemTypesByName.atx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.CatItemTypesByParentTypeID.atx: -------------------------------------------------------------------------------- 1 | " 2 |  ! "{00000000-0000-0000-0000-000000000000}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{77292603-930F-475D-AE4F-B8970F42F394}{77292603-930F-475D-AE4F-B8970F42F394}{77292603-930F-475D-AE4F-B8970F42F394}{77292603-930F-475D-AE4F-B8970F42F394}{77292603-930F-475D-AE4F-B8970F42F394}{77292603-930F-475D-AE4F-B8970F42F394}{8405ADD5-8DF8-4227-8FAC-3FCADE073386}{8405ADD5-8DF8-4227-8FAC-3FCADE073386}{8637F1ED-8C04-4866-A44A-1CB8288B3C63}{8637F1ED-8C04-4866-A44A-1CB8288B3C63}{D4912162-3413-476E-9DA4-2AEFBBC16939}{D4912162-3413-476E-9DA4-2AEFBBC16939}{D4912162-3413-476E-9DA4-2AEFBBC16939}{D4912162-3413-476E-9DA4-2AEFBBC16939}{FFD09C28-FE70-4E25-907C-AF8E8A5EC5F3}&" -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.CatItemTypesByUUID.atx: -------------------------------------------------------------------------------- 1 | "  2 |   ! " {28DA9E89-FF80-4D6D-8926-4EE2B161677D}{35B601F7-45CE-4AFF-ADB7-7702D3839B12}{4ED4A58E-621F-4043-95ED-850FBA45FCBC}{5B966567-FB87-4DDE-938B-B4B37423539D}{5ED667A3-9CA9-44A2-8029-D95BF23704B9}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{73718A66-AFB9-4B88-A551-CFFA0AE12620}{74737149-DCB5-4257-8904-B9724E32A530}{76357537-3364-48AF-A4BE-783C7C28B5CB}{767152D3-ED66-4325-8774-420D46674E07}{77292603-930F-475D-AE4F-B8970F42F394}{7771FC7D-A38B-4FD3-8225-639D17E9A131}{787BEA35-4A86-494F-BB48-500B96145B58}{8405ADD5-8DF8-4227-8FAC-3FCADE073386}{8637F1ED-8C04-4866-A44A-1CB8288B3C63}{8C368B12-A12E-4C7E-9638-C9C64E69E98F}{A300008D-0CEA-4F6A-9DFA-46AF829A3DF2}{A3803369-5FC2-4963-BAE0-13EFFC09DD73}{B606A7E1-FA5B-439C-849C-6E9C2481537B}{C29DA988-8C3E-45F7-8B5C-18E51EE7BEB4}{C673FE0F-7280-404F-8532-20755DD8FC06}{CD06BC3B-789D-4C51-AAFA-A467912B8965}{D4912162-3413-476E-9DA4-2AEFBBC16939}{D5A40288-029E-4766-8C81-DE3F61129371}{D86502F9-9758-45C6-9D23-6DD1A0107B47}{D98421EB-D582-4713-9484-43304D0810F6}{DB1B697A-3BB6-426A-98A2-6EE7A4C6AED3}{DC64B6E4-DC0F-43BD-B4F5-F22385DCF055}{DC9EF677-1AA3-45A7-8ACD-303A5202D0DC}{E6302665-416B-44FA-BE33-4E15916BA101}{F3783E6F-65CA-4514-8315-CE3985DAD3B1}{F8413DCB-2248-4935-BFE9-315F397E5110}{FBDD7DD6-4A25-40B7-9A1A-ECC3D1172447}{FFD09C28-FE70-4E25-907C-AF8E8A5EC5F3}&" -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.gdbtablx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000005.gdbtablx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.CatRelsByDestinationID.atx: -------------------------------------------------------------------------------- 1 | {0F280C97-A630-47C5-80CA-F7A69BF2DBF8}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.CatRelsByOriginID.atx: -------------------------------------------------------------------------------- 1 | {F9CFCAEC-7127-4631-8803-8FEC6E266B79}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.CatRelsByType.atx: -------------------------------------------------------------------------------- 1 | {DC78F1AB-34E4-43AC-BA47-1C4EABD0E7C7}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.FDO_UUID.atx: -------------------------------------------------------------------------------- 1 | {581991A9-0913-4605-8752-8C1FE921D8EB}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.gdbtablx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000006.gdbtablx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByBackwardLabel.atx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByBackwardLabel.atx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByDestItemTypeID.atx: -------------------------------------------------------------------------------- 1 |  2 |   {28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{8405ADD5-8DF8-4227-8FAC-3FCADE073386}{8637F1ED-8C04-4866-A44A-1CB8288B3C63}{A300008D-0CEA-4F6A-9DFA-46AF829A3DF2}{CD06BC3B-789D-4C51-AAFA-A467912B8965}{CD06BC3B-789D-4C51-AAFA-A467912B8965}{D86502F9-9758-45C6-9D23-6DD1A0107B47}{D98421EB-D582-4713-9484-43304D0810F6}{F3783E6F-65CA-4514-8315-CE3985DAD3B1}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByForwardLabel.atx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByForwardLabel.atx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByName.atx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByName.atx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByOriginItemTypeID.atx: -------------------------------------------------------------------------------- 1 |    2 | {28DA9E89-FF80-4D6D-8926-4EE2B161677D}{28DA9E89-FF80-4D6D-8926-4EE2B161677D}{4ED4A58E-621F-4043-95ED-850FBA45FCBC}{5B966567-FB87-4DDE-938B-B4B37423539D}{70737809-852C-4A03-9E22-2CECEA5B9BFA}{73718A66-AFB9-4B88-A551-CFFA0AE12620}{74737149-DCB5-4257-8904-B9724E32A530}{76357537-3364-48AF-A4BE-783C7C28B5CB}{767152D3-ED66-4325-8774-420D46674E07}{7771FC7D-A38B-4FD3-8225-639D17E9A131}{7771FC7D-A38B-4FD3-8225-639D17E9A131}{A3803369-5FC2-4963-BAE0-13EFFC09DD73}{A3803369-5FC2-4963-BAE0-13EFFC09DD73}{D86502F9-9758-45C6-9D23-6DD1A0107B47}{D98421EB-D582-4713-9484-43304D0810F6}{F3783E6F-65CA-4514-8315-CE3985DAD3B1}{F3783E6F-65CA-4514-8315-CE3985DAD3B1}{F3783E6F-65CA-4514-8315-CE3985DAD3B1}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.CatRelTypesByUUID.atx: -------------------------------------------------------------------------------- 1 |     2 | {0D10B3A7-2F64-45E6-B7AC-2FC27BF2133C}{17E08ADB-2B31-4DCD-8FDD-DF529E88F843}{55D2F4DC-CB17-4E32-A8C7-47591E8C71DE}{583A5BAA-3551-41AE-8AA8-1185719F3889}{5DD0C1AF-CB3D-4FEA-8C51-CB3BA8D77CDB}{5F9085E0-788F-4354-AE3C-34C83A7EA784}{725BADAB-3452-491B-A795-55F32D67229C}{79CC71C8-B7D9-4141-9014-B6373E236ABB}{8DB31AF1-DF7C-4632-AA10-3CC44B0C6914}{908A4670-1111-48C6-8269-134FDD3FE617}{A1633A59-46BA-4448-8706-D8ABE2B2B02E}{B32B8563-0B96-4D32-92C4-086423AE9962}{CC28387C-441F-4D7C-A802-41A160317FE0}{D022DE33-45BD-424C-88BF-5B1B6B957BD3}{D088B110-190B-4229-BDF7-89FDDD14D1EA}{DC739A70-9B71-41E8-868C-008CF46F16D7}{DC78F1AB-34E4-43AC-BA47-1C4EABD0E7C7}{E79B44E3-F833-4B12-90A1-364EC4DDC43E}& -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.gdbtablx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000007.gdbtablx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.gdbindexes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.gdbindexes -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.gdbtable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.gdbtable -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.gdbtablx: -------------------------------------------------------------------------------- 1 | ( -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.spx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/a00000009.spx -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/gdb: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/timestamps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/Deloraine_Area_100_Year_AEP_statewide.gdb/timestamps -------------------------------------------------------------------------------- /inst/extdata/GPKG/afile.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/GPKG/afile.gpkg -------------------------------------------------------------------------------- /inst/extdata/continents/continent.dbf: -------------------------------------------------------------------------------- 1 | _AWCONTINENTC Asia North America Europe Africa South America Oceania Australia Antarctica -------------------------------------------------------------------------------- /inst/extdata/continents/continent.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] -------------------------------------------------------------------------------- /inst/extdata/continents/continent.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/continents/continent.shp -------------------------------------------------------------------------------- /inst/extdata/continents/continent.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/continents/continent.shx -------------------------------------------------------------------------------- /inst/extdata/hsh.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/hsh.gpkg -------------------------------------------------------------------------------- /inst/extdata/shapes.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsumner/RGDALSQL/37f4bd78511616a33e38a952ae59e9781f4d2663/inst/extdata/shapes.gpkg -------------------------------------------------------------------------------- /man/GDALSQL.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GDALSQL.R 3 | \name{GDALSQL} 4 | \alias{GDALSQL} 5 | \alias{dbConnect,GDALSQLDriver-method} 6 | \title{GDALSQL} 7 | \usage{ 8 | GDALSQL() 9 | 10 | \S4method{dbConnect}{GDALSQLDriver}( 11 | drv, 12 | DSN = "", 13 | readonly = TRUE, 14 | ..., 15 | bigint = c("integer64", "integer", "numeric", "character") 16 | ) 17 | } 18 | \arguments{ 19 | \item{drv}{GDALSQLDriver created by \code{GDALSQL()}} 20 | 21 | \item{DSN}{data source name, may be a file, or folder path, database connection string, or URL} 22 | 23 | \item{readonly}{open in readonly mode?} 24 | } 25 | \description{ 26 | GDALSQL driver 27 | 28 | dbConnect 29 | } 30 | \examples{ 31 | \dontrun{ 32 | ## this is a nothing connection 33 | db <- dbConnect(RGDALSQL::GDALSQL()) 34 | afile <- system.file("extdata", "shapes.gpkg", package = "RGDALSQL") 35 | db <- dbConnect(RGDALSQL::GDALSQL(), afile) 36 | dbSendQuery(db, "SELECT * FROM sids") 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /man/GDALSQLConnection-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GDALSQL.R 3 | \docType{class} 4 | \name{GDALSQLConnection-class} 5 | \alias{GDALSQLConnection-class} 6 | \alias{show,GDALSQLConnection-method} 7 | \title{GDALSQL connection class.} 8 | \usage{ 9 | \S4method{show}{GDALSQLConnection}(object) 10 | } 11 | \description{ 12 | GDALSQL connection class. 13 | } 14 | \keyword{internal} 15 | -------------------------------------------------------------------------------- /man/GDALSQLDriver-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GDALSQL.R 3 | \docType{class} 4 | \name{GDALSQLDriver-class} 5 | \alias{GDALSQLDriver-class} 6 | \alias{dbUnloadDriver,GDALSQLDriver-method} 7 | \title{Driver for GDAL SQL.} 8 | \usage{ 9 | \S4method{dbUnloadDriver}{GDALSQLDriver}(drv, ...) 10 | } 11 | \description{ 12 | Driver for GDAL SQL. 13 | } 14 | \keyword{internal} 15 | -------------------------------------------------------------------------------- /man/GDALSQLResult-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GDALSQL.R 3 | \docType{class} 4 | \name{GDALSQLResult-class} 5 | \alias{GDALSQLResult-class} 6 | \title{GDALSQL results class} 7 | \description{ 8 | GDALSQL results class 9 | } 10 | \keyword{internal} 11 | -------------------------------------------------------------------------------- /man/dbFetch-GDALSQLResult-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GDALSQL.R 3 | \name{dbFetch,GDALSQLResult-method} 4 | \alias{dbFetch,GDALSQLResult-method} 5 | \title{Retrieve records from GDALSQL query} 6 | \usage{ 7 | \S4method{dbFetch}{GDALSQLResult}(res, n = -1, ...) 8 | } 9 | \description{ 10 | Retrieve records from GDALSQL query 11 | } 12 | -------------------------------------------------------------------------------- /man/dbSendQuery-GDALSQLConnection-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GDALSQL.R 3 | \name{dbSendQuery,GDALSQLConnection-method} 4 | \alias{dbSendQuery,GDALSQLConnection-method} 5 | \title{Send a query to GDALSQL.} 6 | \usage{ 7 | \S4method{dbSendQuery}{GDALSQLConnection}(conn, statement, ...) 8 | } 9 | \arguments{ 10 | \item{conn}{database connection, s created by \code{\link{dbConnect}}} 11 | 12 | \item{statement}{OGR SQL, see http://www.gdal.org/ogr_sql.html} 13 | 14 | \item{...}{for compatibility with generic} 15 | } 16 | \description{ 17 | Send a query to GDALSQL. 18 | } 19 | \examples{ 20 | afile <- system.file("extdata", "shapes.gpkg", package = "RGDALSQL") 21 | db <- dbConnect(RGDALSQL::GDALSQL(), afile) 22 | dbSendQuery(db, "SELECT * FROM sids WHERE FID < 1") 23 | } 24 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(RGDALSQL) 3 | 4 | test_check("RGDALSQL") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-dbitest.R: -------------------------------------------------------------------------------- 1 | DBItest::make_context(GDALSQL(), NULL) 2 | DBItest::test_getting_started() 3 | 4 | DBItest::test_driver() 5 | --------------------------------------------------------------------------------