From c348bbaffc61bf18b6312f77c52372ca11486f17 Mon Sep 17 00:00:00 2001 From: "Etienne B. Racine" Date: Mon, 3 Aug 2020 10:21:26 -0400 Subject: [PATCH 1/3] Initial commit --- .Rbuildignore | 9 +++++ .github/.gitignore | 1 + .github/workflows/pkgdown.yaml | 46 ++++++++++++++++++++++ .gitignore | 5 +++ DESCRIPTION | 24 ++++++++++++ LICENSE | 2 + LICENSE.md | 21 ++++++++++ NAMESPACE | 2 + R/zzz.R | 26 ++++++++++++ README.Rmd | 62 +++++++++++++++++++++++++++++ README.md | 63 +++++++++++++++++++++++++++++- _pkgdown.yml | 0 codecov.yml | 14 +++++++ man/figures/README-pressure-1.png | Bin 0 -> 7162 bytes sfdbi.Rproj | 22 +++++++++++ tests/testthat.R | 4 ++ 16 files changed, 300 insertions(+), 1 deletion(-) create mode 100644 .Rbuildignore create mode 100644 .github/.gitignore create mode 100644 .github/workflows/pkgdown.yaml create mode 100644 .gitignore create mode 100644 DESCRIPTION create mode 100644 LICENSE create mode 100644 LICENSE.md create mode 100644 NAMESPACE create mode 100644 R/zzz.R create mode 100644 README.Rmd create mode 100644 _pkgdown.yml create mode 100644 codecov.yml create mode 100644 man/figures/README-pressure-1.png create mode 100644 sfdbi.Rproj create mode 100644 tests/testthat.R diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..dc9e0af --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,9 @@ +^sfdbi\.Rproj$ +^\.Rproj\.user$ +^README\.Rmd$ +^LICENSE\.md$ +^codecov\.yml$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..8bc9210 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,46 @@ +on: + push: + branches: master + +name: pkgdown + +jobs: + pkgdown: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Deploy package + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..234f028 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +docs diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..3b37139 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,24 @@ +Package: sfdbi +Title: Database interface for spatial data +Version: 0.0.0.9000 +Authors@R: + c(person(given = "Etienne", + family = "Racine", + role = c("aut", "cre"), + email = "etiennebr@gmail.com", + comment = c(ORCID = "0000-0003-1109-894X")), + person(given = "Edzer", + family = "Pebesma", + role = c("aut"), + email = "edzer.pebesma@uni-muenster.de", + comment = c(ORCID = "0000-0001-8049-7069"))) +Description: An `sf` back end for databases that allows you to + work with database tables as if they are in-memory spatial data frames. +License: MIT + file LICENSE +Encoding: UTF-8 +LazyData: true +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.1.0 +Suggests: + testthat, + covr diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2a02b9e --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2020 +COPYRIGHT HOLDER: Etienne Racine diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..3fdc29b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2020 Etienne Racine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..6ae9268 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,2 @@ +# Generated by roxygen2: do not edit by hand + diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..2f5dd1a --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,26 @@ +# nocov start + +# setup_repo +if (FALSE) { + .sfdbi_setup <- function() { + usethis::create_package("../sfdbi", open = FALSE) + usethis::use_readme_rmd() + usethis::use_news_md() + usethis::use_testthat() + usethis::use_roxygen_md() + usethis::use_mit_license() + usethis::use_git() + #usethis::use_github() + usethis::use_coverage() + usethis::use_lifecycle_badge("experimental") + usethis::use_pkgdown() + usethis::use_github_action("pkgdown") + usethis::use_github_labels( + labels = geotidy:::.geotidy_labels(), + colours = geotidy:::.geotidy_labels_brewer(), + descriptions = geotidy:::.geotidy_labels_descriptions(), + delete_default = TRUE + ) + } +} +# nocov end diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..bd2752b --- /dev/null +++ b/README.Rmd @@ -0,0 +1,62 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# sfdbi + + +[![Codecov test coverage](https://codecov.io/gh/r-spatial/sfdbi/branch/master/graph/badge.svg)](https://codecov.io/gh/r-spatial/sfdbi?branch=master) +[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) + + +The goal of sfdbi is to ... + +## Installation + +You can install the released version of sfdbi from [CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("sfdbi") +``` + +And the development version from [GitHub](https://github.com/) with: + +``` r +# install.packages("devtools") +devtools::install_github("r-spatial/sfdbi") +``` +## Example + +This is a basic example which shows you how to solve a common problem: + +```{r example} +library(sfdbi) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so: + +```{r cars} +summary(cars) +``` + +You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. + +You can also embed plots, for example: + +```{r pressure, echo = FALSE} +plot(pressure) +``` + +In that case, don't forget to commit and push the resulting figure files, so they display on GitHub! diff --git a/README.md b/README.md index 2e27543..45a0589 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,63 @@ + + + # sfdbi -DBI interface to sf + + + +[![Codecov test +coverage](https://codecov.io/gh/r-spatial/sfdbi/branch/master/graph/badge.svg)](https://codecov.io/gh/r-spatial/sfdbi?branch=master) +[![Lifecycle: +experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) + + +The goal of sfdbi is to … + +## Installation + +You can install the released version of sfdbi from +[CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("sfdbi") +``` + +And the development version from [GitHub](https://github.com/) with: + +``` r +# install.packages("devtools") +devtools::install_github("r-spatial/sfdbi") +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +``` r +library(sfdbi) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? +You can include R chunks like so: + +``` r +summary(cars) +#> speed dist +#> Min. : 4.0 Min. : 2.00 +#> 1st Qu.:12.0 1st Qu.: 26.00 +#> Median :15.0 Median : 36.00 +#> Mean :15.4 Mean : 42.98 +#> 3rd Qu.:19.0 3rd Qu.: 56.00 +#> Max. :25.0 Max. :120.00 +``` + +You’ll still need to render `README.Rmd` regularly, to keep `README.md` +up-to-date. + +You can also embed plots, for example: + + + +In that case, don’t forget to commit and push the resulting figure +files, so they display on GitHub\! diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..e69de29 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..04c5585 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true diff --git a/man/figures/README-pressure-1.png b/man/figures/README-pressure-1.png new file mode 100644 index 0000000000000000000000000000000000000000..ba27887ed7b7479b658473926dd31c2ee43cb34d GIT binary patch literal 7162 zcmds6XH=8llSV*kA}CF|h)M@3p_fnt0s_)oP?6qyhhJ1gg@}r@(1J*BA|>?v1OWvh zv=Dlc7J3UcKsKW8{&)Ao{?G2&v*+xGoRjz7nfu# zagT(A6iz~NZkm#eIHG?~>;ef18Hu5ui6-&!+_`h4q@-kIWaQ-J=g*(NaNz<41qCG~ zB^4DFH8nL24b8=i7ino}FI~DsM@L6bPk;IHa8l&6_uG-M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i-eu*xAT^lR?o%0qWwhLt#tX2-ubK9pg_?0zH351bh2;f!ssd=K}H8*>c08b z0OR)zO6@cxlu&zLvzV%#7ZJqIpb|3ryd*pQr_<`a%6(W(YaatAKycCPhWnQbV*jbs g`d?i5R}m=oE4p^xcEQ7mA23LCH1BGZsoj74FDku?I{*Lx literal 0 HcmV?d00001 diff --git a/sfdbi.Rproj b/sfdbi.Rproj new file mode 100644 index 0000000..69fafd4 --- /dev/null +++ b/sfdbi.Rproj @@ -0,0 +1,22 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..8129edc --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(sfdbi) + +test_check("sfdbi") From 0c8743cac7ae32fd81c9e061a1f7a07160870228 Mon Sep 17 00:00:00 2001 From: "Etienne B. Racine" Date: Mon, 3 Aug 2020 10:56:29 -0400 Subject: [PATCH 2/3] add logo --- R/zzz.R | 1 + README.Rmd | 3 +- README.md | 2 +- man/figures/logo.svg | 169 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 man/figures/logo.svg diff --git a/R/zzz.R b/R/zzz.R index 2f5dd1a..bf7a4c1 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -6,6 +6,7 @@ if (FALSE) { usethis::create_package("../sfdbi", open = FALSE) usethis::use_readme_rmd() usethis::use_news_md() + usethis::use_logo("logo.svg") usethis::use_testthat() usethis::use_roxygen_md() usethis::use_mit_license() diff --git a/README.Rmd b/README.Rmd index bd2752b..23746b4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -13,8 +13,7 @@ knitr::opts_chunk$set( ) ``` -# sfdbi - +# sfdbi [![Codecov test coverage](https://codecov.io/gh/r-spatial/sfdbi/branch/master/graph/badge.svg)](https://codecov.io/gh/r-spatial/sfdbi?branch=master) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) diff --git a/README.md b/README.md index 45a0589..c829fe8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# sfdbi +# sfdbi diff --git a/man/figures/logo.svg b/man/figures/logo.svg new file mode 100644 index 0000000..8ba9c66 --- /dev/null +++ b/man/figures/logo.svg @@ -0,0 +1,169 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From dfb14f3d13b6aed3f30758ee1c2b935a4f24de2c Mon Sep 17 00:00:00 2001 From: "Etienne B. Racine" Date: Mon, 3 Aug 2020 16:52:07 -0400 Subject: [PATCH 3/3] readme driven development --- README.Rmd | 77 ++++++++++++++++++++++++------------- README.md | 111 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 127 insertions(+), 61 deletions(-) diff --git a/README.Rmd b/README.Rmd index 23746b4..0bc51b4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,43 +19,68 @@ knitr::opts_chunk$set( [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) -The goal of sfdbi is to ... +## Overview -## Installation - -You can install the released version of sfdbi from [CRAN](https://CRAN.R-project.org) with: +sfdbi helps you manipulate spatial data stored in a database as if it was +in-memory with standard sf and [dplyr](https://dplyr.tidyverse.org/) functions. +With sfdbi, you can reads and write sf objects to databases and translate sf +operations to `SQL`. We support [`postgis`](https://postgis.net/), but feel free +to open an issue for other backends and show you interest. -``` r -install.packages("sfdbi") -``` +## Installation -And the development version from [GitHub](https://github.com/) with: +You can install the development version from [GitHub](https://github.com/) with: ``` r # install.packages("devtools") devtools::install_github("r-spatial/sfdbi") ``` + +sfdbi is not available on CRAN yet. + ## Example -This is a basic example which shows you how to solve a common problem: +This is how you write and read spatial data to a database. Note that sfdbi works best with dplyr. ```{r example} library(sfdbi) -## basic example code +library(sf) +library(dplyr) + +con <- DBI::dbConnect( + RPostgres::Postgres(), + host = "localhost", + port = 25432 +) %>% + postgis() + +# Create a spatial table +pyramids <- tribble( + ~what, ~geom, + "Giza", "POINT(31.1342 29.9792)", + "Khafre", "POINT(31.130833 29.976111)", + "Menkaure", "POINT(31.128333 29.9725)", + "Khentkaus I", "POINT(31.135608 29.973406)", + "Sphynx", "POINT(31.137778 29.975278)", + ) %>% + mutate( + geom = st_as_sfc(geom, crs = 4326) + ) + +# Copy spatial data to database +x <- copy_to(con, pyramids) + +# Queue operations to the database +y <- x %>% + mutate( + geom = geom %>% + st_transform(23035L) %>% + st_buffer(10) + ) + +# View the query to be executed +y %>% show_query() + +# Execute operation in the database and load it in R memory +collect(y) ``` - -What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so: - -```{r cars} -summary(cars) -``` - -You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. - -You can also embed plots, for example: - -```{r pressure, echo = FALSE} -plot(pressure) -``` - -In that case, don't forget to commit and push the resulting figure files, so they display on GitHub! diff --git a/README.md b/README.md index c829fe8..d255b18 100644 --- a/README.md +++ b/README.md @@ -11,53 +11,94 @@ coverage](https://codecov.io/gh/r-spatial/sfdbi/branch/master/graph/badge.svg)]( experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) -The goal of sfdbi is to … +## Overview -## Installation - -You can install the released version of sfdbi from -[CRAN](https://CRAN.R-project.org) with: +sfdbi helps you manipulate spatial data stored in a database as if it +was in-memory with standard sf and [dplyr](https://dplyr.tidyverse.org/) +functions. With sfdbi, you can reads and write sf objects to databases +and translate sf operations to `SQL`. We support +[`postgis`](https://postgis.net/), but feel free to open an issue for +other backends and show you interest. -``` r -install.packages("sfdbi") -``` +## Installation -And the development version from [GitHub](https://github.com/) with: +You can install the development version from +[GitHub](https://github.com/) with: ``` r # install.packages("devtools") devtools::install_github("r-spatial/sfdbi") ``` +sfdbi is not available on CRAN yet. + ## Example -This is a basic example which shows you how to solve a common problem: +This is how you write and read spatial data to a database. Note that +sfdbi works best with dplyr. ``` r library(sfdbi) -## basic example code -``` - -What is special about using `README.Rmd` instead of just `README.md`? -You can include R chunks like so: - -``` r -summary(cars) -#> speed dist -#> Min. : 4.0 Min. : 2.00 -#> 1st Qu.:12.0 1st Qu.: 26.00 -#> Median :15.0 Median : 36.00 -#> Mean :15.4 Mean : 42.98 -#> 3rd Qu.:19.0 3rd Qu.: 56.00 -#> Max. :25.0 Max. :120.00 +library(sf) +#> Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1 +library(dplyr) +#> +#> Attaching package: 'dplyr' +#> The following objects are masked from 'package:stats': +#> +#> filter, lag +#> The following objects are masked from 'package:base': +#> +#> intersect, setdiff, setequal, union + +con <- DBI::dbConnect( + RPostgres::Postgres(), + host = "localhost", + port = 25432 +) %>% + postgis() + +# Create a spatial table +pyramids <- tribble( + ~what, ~geom, + "Giza", "POINT(31.1342 29.9792)", + "Khafre", "POINT(31.130833 29.976111)", + "Menkaure", "POINT(31.128333 29.9725)", + "Khentkaus I", "POINT(31.135608 29.973406)", + "Sphynx", "POINT(31.137778 29.975278)", + ) %>% + mutate( + geom = st_as_sfc(geom, crs = 4326) + ) + +# Copy spatial data to database +x <- copy_to(con, pyramids) +#> Note: method with signature 'DBIObject#sf' chosen for function 'dbDataType', +#> target signature 'PqConnection#sf'. +#> "PqConnection#ANY" would also be valid + +# Queue operations to the database +y <- x %>% + mutate( + geom = geom %>% + st_transform(23035L) %>% + st_buffer(10) + ) + +# View the query to be executed +y %>% show_query() +#> +#> SELECT "what", st_buffer(st_transform("geom", 23035), 10.0) AS "geom" +#> FROM "pyramids" + +# Execute operation in the database and load it in R memory +collect(y) +#> # A tibble: 5 x 2 +#> what geom +#> +#> 1 Giza ((899053.3 3323853, 899053.1 3323851, 899052.6 3323849, 899051.7 3… +#> 2 Khafre ((898740.5 3323498, 898740.3 3323496, 898739.7 3323494, 898738.8 3… +#> 3 Menkaure ((898513.4 3323089, 898513.2 3323087, 898512.7 3323085, 898511.7 3… +#> 4 Khentkaus… ((899212.6 3323215, 899212.4 3323213, 899211.8 3323211, 899210.9 3… +#> 5 Sphynx ((899414.7 3323430, 899414.5 3323428, 899413.9 3323426, 899413 332… ``` - -You’ll still need to render `README.Rmd` regularly, to keep `README.md` -up-to-date. - -You can also embed plots, for example: - - - -In that case, don’t forget to commit and push the resulting figure -files, so they display on GitHub\!