Git Product home page Git Product logo

beastr's Introduction

Hi there ๐Ÿ‘‹

beastr's People

Contributors

rgzn avatar

Watchers

 avatar

beastr's Issues

sqlite erases timezones

On writing to geopackage sqlite, the timezone from the R datetime object is erased. When read back into R, the time field no longer has a zone.

Currently have to handle this manually. Avoid confusion by always writing UTC times. In visualization we can convert back to local times.

`append_layer()` does not work with Shiny

Using append_layer() or append_database() uses sf::st_write() to modify an existing database. This is convenient because it handles all the necessary spatial columns, and modifies a geopackage's metadata to include new spatial data.

However, using st_write with geopackages in Shiny is difficult. A geopackage is an sqlite database, but the st_write interface to them treats them as a normal file. File I/O in Shiny is designed to isolate the side effects on a local computer, so it reads the entire file into a temporary directory, then you are just modifying Shiny's copy.

There are two potential workarounds:

  • Do all the modifications on the Shiny copy of the database, and then provide a download button for the user to write over their local copy of the geopackage.
  • Connect to the geopackage as a database using DBI::dbConnect(). This will allow for the Shiny app to interface with the data through a database connection instead of copying the file.

The latter is the proper approach. Besides being a cleaner interface, it starts down the road of extending these functions to other databases besides geopackage. But it will require some more work:

  • Shiny DB connections should be done with the pool library to avoid complications with repeatedly connecting/disconnecting.
  • This will require some additional options in append_layer(), perhaps a use_dbi = TRUE parameter.
  • If the data added is spatial, we will have to write the necessary SQL modify a geopackage's metadata tables. There is an example of how to do this in build_database() because it was necessary for creating the View that ties fixes to animals. This process should be separated into its own function for re-use in append_layer() if using geopackages.

No unique id constraints in db

Using sf::st_write() to create tables in the geopackage doesn't support speciging UNIQUE constraints on tables (I think?). And SQLite3 doesn't support adding them to existing tables.

Possible workarounds:

  • After creating tables but before creating View in build_database(), create the constraints via copying the tables and creating new ones as in this example: https://stackoverflow.com/questions/42969127/add-constraint-to-existing-sqlite-table

  • Do everything in R. This is what I'm doing currently. This is not ideal, as the constraints only come from the R code within this package and any external modification could corrupt data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.