{"id":13858014,"url":"https://github.com/mdsumner/RGDALSQL","last_synced_at":"2025-07-13T23:31:04.042Z","repository":{"id":72211809,"uuid":"64070993","full_name":"mdsumner/RGDALSQL","owner":"mdsumner","description":"DBI GDAL","archived":false,"fork":false,"pushed_at":"2020-09-22T11:19:57.000Z","size":282,"stargazers_count":17,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T14:55:50.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdsumner.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-07-24T15:05:40.000Z","updated_at":"2024-01-06T22:40:44.000Z","dependencies_parsed_at":"2023-02-24T05:30:32.196Z","dependency_job_id":null,"html_url":"https://github.com/mdsumner/RGDALSQL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mdsumner/RGDALSQL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2FRGDALSQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2FRGDALSQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2FRGDALSQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2FRGDALSQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdsumner","download_url":"https://codeload.github.com/mdsumner/RGDALSQL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2FRGDALSQL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265220217,"owners_count":23729777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:01:53.921Z","updated_at":"2025-07-13T23:31:03.527Z","avatar_url":"https://github.com/mdsumner.png","language":"R","readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\n```\n\n[![Travis-CI Build Status](https://travis-ci.org/mdsumner/RGDALSQL.svg?branch=master)](https://travis-ci.org/mdsumner/RGDALSQL)\n[![Coverage Status](https://img.shields.io/codecov/c/github/mdsumner/RGDALSQL/master.svg)](https://codecov.io/github/mdsumner/RGDALSQL?branch=master)\n\n\n## RGDALSQL\n\nWIP\n\n```{r}\nlibrary(RGDALSQL)\nf = system.file(\"extdata/continents\", package = \"RGDALSQL\")\ndb \u003c- dbConnect(RGDALSQL::GDALSQL(), f)\ndbSendQuery(db, \"SELECT * FROM continent WHERE FID \u003c 1\")\n\n\nres \u003c- dbSendQuery(db, \"SELECT * FROM continent WHERE continent LIKE '%ca'\")\ndbFetch(res)\n\n(res \u003c- dbReadTable(db, \"continent\"))\n\ndplyr::tbl(db, \"continent\")\n```\n\n## Limitations\n\n* currently read-only, so no temporary tables for `compute()`\n* no temporary tables in non-DB drivers (i.e. GPKG is ok, SHP is not)\n* no sub-queryies in non-DB drivers (i.e. no collapse for SHP or GDB)\n\nfilter, arrange, summarize, transmute, mutate, ok but cannot be chained for nested sub-queries\n\n\n\n\n```{r}\nlibrary(dplyr)\ntbl(db, \"continent\") %\u003e% dplyr::filter(continent == \"Australia\")\n\n\ntbl(db, \"continent\") %\u003e% dplyr::filter(continent %in% c(\"Australia\", \"Antarctica\")) %\u003e% collect() \n```\n\nTry OSM PBF. \n\n```{r, eval=FALSE}\n# wget https://download.geofabrik.de/europe/albania-latest.osm.pbf\nf \u003c- fs::path_expand(\"~/albania-latest.osm.pbf\")\npbf \u003c- dbConnect(RGDALSQL::GDALSQL(),f)\n## we have to use a normalized path \n## (vapour doesn't do this yet, but GDALSQL will do it *when connecting*, \n## currently maintains the input DSN)\npbf\n# db_list_tables(pbf)\n\ntbl(pbf, \"points\") \n# Source:   table\u003cpoints\u003e [?? x 11]\n# Database: GDALSQLConnection\n   osm_id  name     barrier highway   ref   address is_in place man_made other_tags                            `_ogr_geometry_`  \n   \u003cchr\u003e   \u003cchr\u003e    \u003cchr\u003e   \u003cchr\u003e     \u003cchr\u003e \u003cchr\u003e   \u003cchr\u003e \u003cchr\u003e \u003cchr\u003e    \u003cchr\u003e                                 \u003cwk_wkb\u003e          \n 1 154606… \"\"       \"\"      \"traffic… \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"crossing\\\"=\u003e\\\"traffic_signals\\\",\\… \u003cPOINT (19.8082 4…\n 2 154926… \"\"       \"\"      \"crossin… \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"crossing\\\"=\u003e\\\"uncontrolled\\\"\"      \u003cPOINT (19.4762 4…\n 3 154927… \"\"       \"\"      \"traffic… \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"crossing\\\"=\u003e\\\"traffic_signals\\\",\\… \u003cPOINT (19.8221 4…\n 4 154927… \"\"       \"\"      \"crossin… \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"crossing\\\"=\u003e\\\"uncontrolled\\\"\"      \u003cPOINT (19.5045 4…\n 5 154928… \"\"       \"\"      \"traffic… \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"crossing\\\"=\u003e\\\"traffic_signals\\\",\\… \u003cPOINT (19.8081 4…\n 6 154936… \"\"       \"\"      \"crossin… \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"crossing\\\"=\u003e\\\"uncontrolled\\\",\\\"su… \u003cPOINT (19.4954 4…\n 7 268630… \"Grykat… \"\"      \"\"        \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"natural\\\"=\u003e\\\"peak\\\"\"               \u003cPOINT (19.9047 4…\n 8 268632… \"Kakiuk… \"\"      \"\"        \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"natural\\\"=\u003e\\\"peak\\\"\"               \u003cPOINT (19.8792 4…\n 9 268635… \"Mali i… \"\"      \"\"        \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"natural\\\"=\u003e\\\"peak\\\",\\\"wikidata\\\"=… \u003cPOINT (19.9241 4…\n10 268635… \"Maja e… \"\"      \"\"        \"\"    \"\"      \"\"    \"\"    \"\"       \"\\\"natural\\\"=\u003e\\\"peak\\\",\\\"prominence\\… \u003cPOINT (20.1628 4…\n# … with more rows\n\ntbl(pbf, \"multipolygons\") %\u003e% filter(osm_id == \"53292\") %\u003e% select(`_ogr_geometry_`, type)\n# Source:   lazy query [?? x 2]\n# Database: GDALSQLConnection\n  type     `_ogr_geometry_`                                                      \n  \u003cchr\u003e    \u003cwk_wkb\u003e                                                              \n1 boundary \u003cMULTIPOLYGON (((20.0126 42.5258, 20.0124 42.5257, 20.0123 42.5258...\u003e\n```\n\n\n```{r}\nf \u003c- \"inst/extdata/shapes.gpkg\"\nconn \u003c- dbConnect(RGDALSQL::GDALSQL(),f)\nconn\ndbListTables(conn)\n\nx \u003c- dbSendQuery(conn, \"SELECT * FROM sids WHERE SID74 \u003c 10\")\n\ntbl(conn, \"sids\") %\u003e% \n  arrange(desc(AREA))  %\u003e% \n  transmute(a = AREA *8, geom, AREA) %\u003e% \n  filter(a \u003e 1.62)  %\u003e% \n  show_query()\n\n\n## with SHP we can't do subquery\nf \u003c- system.file(\"shape/nc.shp\", package = \"sf\")\nconn \u003c- dbConnect(GDALSQL(), f)\n## but the special variables are there\ntbl(conn, \"nc\") %\u003e% arrange(OGR_GEOM_AREA)\ntbl(conn, \"nc\") %\u003e% arrange(OGR_GEOM_AREA, FID) %\u003e% show_query()\n\n## FAILS because subquery\ntbl(conn, \"nc\") %\u003e% mutate(aa = AREA) %\u003e% transmute(a1 = FID) %\u003e% show_query()\n\n## ok because a single statement\ntbl(conn, \"nc\") %\u003e% transmute(a1 = FID, aa = AREA) %\u003e% collect()\n\n```\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2FRGDALSQL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdsumner%2FRGDALSQL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2FRGDALSQL/lists"}