Giter Club home page Giter Club logo

tgvejs's Introduction

tic codecov CRAN status

This is the R package for the TGVE front end npm package tgve. The R package is developed to facilitate interactive geospatial analysis and visualization in R, use R’s echo-system to drive advanced data processing, and facilitate deployment of geospatial web applications in production.

Install

Install tgver from CRAN

install.packages("tgver")

You can use the latest from GitHub using devtools::install_github("tgve/tgver")

Use

Overall, the package takes advantage of how TGVE can be used (see npm package for documentation) and provides options to R users.

For instance, this document is a Markdown (GitHub) document generated using an Rmarkdown (Rmd) document, if the Rmd is rendered to a HTML output, then using knitr::include_url we should see an instance of the TGVE embedded in the document. Please see the live examples in the vignette which is rendered to HTML.

To do this we can go:

# this is the most basic use
# tgver::tgve()
# to embed in a html rendered Rmd
html.file = tgver::tgve(browse = FALSE)
knitr::include_url(html.file)

The first function tgver::tgve(browse=FALSE) prepares an instance of the TGVE but does not run/open it, it returns its path (a tempdir() path). The second line is knitr function to embed the first line’s output.

That was the simplest way of running an instance of TGVE on the local machine. The more advanced but similar function of this package, with the back-end as a plumber API and serving the same instance, would be like:

# start a tgve instance before embedding it
ps = tgver::tgve_server(background = TRUE)
#> Attempting to serve TGVE instance from: /tmp/Rtmpevq9TT/tgve
#> Running plumber at: http://127.0.0.1/8000
knitr::include_url("http://127.0.0.1:8000")
# kill the process returned from underlying `callr`
ps$kill()
# or use the public one
# knitr::include_url("https://tgve.github.io/app/")

Explore sf objects

For these purposes, the package relies on the plumber API to serve data. So, again within HTML outputs we can explore sf objects like so:

# using sf
nc = sf::st_read(system.file("shape/nc.shp", package="sf"))
tgver::explore_sf(nc)

For more see the vignette.

Preview

tgve-vignette

tgvejs's People

Contributors

dependabot[bot] avatar layik avatar lydiafrance avatar nbarlowati avatar rogerbeecham avatar rolyp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tgvejs's Issues

Production: passing REACT_APP_MAPBOX_ACCESS_TOKEN to container

The .env and then exposing it as process.env as per React docs may not be suitable for the production.
The deployment pipelines means we cannot add the MAPBOX access_token to the prebuilt image on DockerHUb.

Seems passing both REACT_APP_MAPBOX_ACCESS_TOKEN and MAPBOX_ACCESS_TOKEN is not picked up by the JS bundle served.

Looking for a solution.

Mapbox license change

Current release of the npm package 0.0.211 functions without any issues/warnings but current dev work hit warnings which are related to this.

mapbox-gl-js is no longer under the 3-Clause BSD license. By upgrading to this release, you are agreeing to Mapbox terms of service. Refer to LICENSE.txt for the new licensing terms and details. For questions, contact our team at https://support.mapbox.com.

Options are limited, clearly for those who love Mapbox map tiles, they can continue as usual. For the rest, which includes the way eAtlas is used in geoplumber R package, must consider mapblibre-gl-js.

Method to flexibly define DeckGL layer APIs to data columns or custom values

- [ ] Arc
- [ ] Line
- [ ] path

The approach is as follows:

  1. Define the type of settings required.
  2. Define the visualization based on (1)
  3. Define passing the values from (2) in generating the layers.

That does not mean much because it is a functional approach the example is this for a heatmap layer:

  1. Define a variable called getWeight as a column based settings
  2. Generate a dropdown to select a column to be assigned to (1)
  3. Use the value obtained in (2) to generate the layer and also use it in the triggers defined in DeckGL.

Some docs is required see the Wiki pages.

Allow a mapping between columns in data and geographies

e.g.

REACT_APP_GEOGRAPHY_COLUMN_NAME: msoa11cd

means that both the data from REACT_APP_DEFAULT_URL and REACT_APP_GEOGRAPHY_URL must share a common column name, which might require manual editing of the data.

Would it be possible to specify this as a dict, e.g.

REACT_APP_GEOGRAPHY_COLUMN_NAME: msoa11cd: MSOA

(apologies if my yaml syntax is a bit off)

then I could keep the original column name ("MSOA") in the data?

Thanks!

Separate geography API

The idea comes from SPENSER and now PIGSUSTAIN. Provide a CSV with geography column and eAtlas detects geographies.

Rename eAtlas

  • eAtlas -> tgvejs
  • eatlas-template -> app
  • full-template -> app-full
  • use notation tgve/app, tgve/full-app in docs
  • revisit tgve- prefix for app, app-full
  • search and replace all occurrences of eAtlas
  • rename main/master branches in app and spenser to release
  • references to eatlas-data
  • wip.R refers to ~/Desktop/recent/eAtlas (2+ years old, delete?)
  • package.json in full-app identifies package as eatlas-template
  • package.json in spenser identifies package as eatlas
  • rename eatlas-data
  • tgve.R refers to eatlas-template
  • rename npm component
  • gh-pages.yml in app and full-app refers to layik
  • https://badge.fury.io/js/eatlas.svg
  • get_quant.R, get_spenser.R, plumber.R and Header.jsx in spenser refer to layik/eAtlas
  • rollup.config.js in tgvejs refers to (generates?) dist/eatlas.js
  • update links to npm package

tgve/eAtlas branch revamp/restructure

For clarification, the branch was the main dev repo for eAtlas/TGVE and has now grown out of its purpose.

  • master branch is now way behind branch npm
  • branch npm is the most important part, npm-dev is where I do work and create PRs on npm.
  • Wiki is the main docs for "the project"
  • Dockerfile is based on "old" approach of building the front-end using JS tools (npm)

Must be done:

  • README to serve as pointer to Wiki/docs and other repo docs etc
  • master branch => npm branch?
  • etc

Consider doing:

  • ??

Development workflow

A development workflow for working on tgvejs and running it via app.

  • testing instructions
    • yarn test in tgvejs
      • Cannot find module 'react' from 'ReactSixteenAdapter.js' -- add to devDependencies
  • experiments on master branch
    • build Docker image
    • yarn install/yarn start
  • experiments on npm branch
    • build Docker image ❌ Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
    • yarn install/yarn startCould not find a required file. Name: index.html
    • npm install/npm startWebpack 4.42.0/4.46.0 dependency issue
  • resolve #92
  • tgve/app#4 (?)
  • identify key users:
    • TGVE contributor
    • Node.js/React developer
    • R developer
    • Python developer (building Flask app)
  • native Mac development
    • get to the point where we can run geoplumber::gp_plumb() in the R console
  • Docker-based development
    • move Dockerfile from eAtlas/npm to app
    • locally modify package.json to point to file:../eAtlas (not link:!)
  • identify key use cases
    • contribute to tgvejs
    • build custom app based on TGVE?
    • deploy my own copy of TGVE (e.g. locally to work with sensitive data)?
    • use the publicly available deployment of TGVE
  • move change log to separate .md file
  • #100
  • commit to yarn (vs. npm) to avoid warnings about package-lock.json
  • locally modified package.json is a bit of a pain
    • npm link ../tgvejs seems to achieve same effect but without changing package.json
  • dev workflow instructions in README.md for tgvejs contributors
    • clone tgvejs and app repos to local machine
    • locally modify @tgve/tgvejs dependency in app/package.json to point to link:../tgvejs
    • yarn watch to incrementally update dist dir of tgvejs?
      • app doesn't pick this up -- need to delete node_modules/@tgve/** and then yarn again

Replace `master` branch by `npm`

  • remove references to “the main repo” in eAtlas
  • check in with @layik re. unpublished commits on master
  • rename master -> old
  • delete old

Done/dropped:

  • make npm the default branch
  • delete build and start scripts from package.json
  • delete wip branch
  • #107
  • delete letsbeatcovid and covid19
  • rename npm to (e.g.) release and npm-dev to develop

This is mainly to keep using GH functionality such as automatic issue closing etc.

The npm development is the way forward. However, the original fork is useful for people who might want to use it the way the original work was done. Now is the time for a new master/main branch.

Imported from #96:

For clarification, the branch was the main dev repo for eAtlas/TGVE and has now grown out of its purpose.

  • master branch is now way behind branch npm
  • branch npm is the most important part, npm-dev is where I do work and create PRs on npm.
  • Wiki is the main docs for "the project"
  • Dockerfile is based on "old" approach of building the front-end using JS tools (npm)

Must be done:

  • README to serve as pointer to Wiki/docs and other repo docs etc
  • master branch => npm branch?
  • etc

Consider doing:

  • ??

DeckGL rerender should not happen

Currently, the Welcome component does quite a lot for a good reason. It is now time to do less. There is a branch to deal with this wip with main problem being a standard React issue of "mirroring state and props" for viewport.

The new component should only rerender if "data" or "layers" has changed, but it also needs to change "viewport" if user interacts or location changes. The latter would be managed by the parent component. But when providing that viewport there is kind of an attempt of mirroring props and state which didn't work on a full day attempt.

Delete `npm-tgver` and `tgver` branches

@layik Looks like this differs from npm by a single commit (5b3535d) which removes the plotly dependency:

Need to figure out if this still needed and if so, whether there is a better solution to having another active branch.

One source of introducing layers

In #38 we have a method to define DeckGL layer properties and use them either in generating layers or indeed in setting their values or assigning values from columns.

For this issue:

  • one source of truth where Layer is defined and used consistently throughout
  • define current set of layer props

For the latter, we can have:

  1. number (numeric)
  2. column (value from column), this is turned into a function on the fly
  3. colour (array) is used in DeckGL layers

This could do most of what eAtlas needs to do.

Consider tooltip graph from current state + data

Given:

  • year as time column
  • column name as layer column
  • data on client side (standalone npm case)

Generate: tooltip graph.

Our other showcases rely on custom code to pull data on tooltip hover. Is it possible to detect at least year + current column used to generate say an area thematic map.

Theme switching

One thing I have not been able to work out is being able to switch themes. Currently the major hurdle is "Slider" from BaseUI itself. When using styled or styletron functions to override css, it complains about some unmounted state issue which definitely does not happen when I remove the overrides affecting Slider component.

Pushed it into a new branch for future ref.

DeckGL layers npm package - scoping options

There are two imminent DeckGL layers in the horizon. With the WP bar vis almost ready to put on npm js.

  1. scoped? Yes!
  2. How? don't know, options are:
  • @eatlas/eatlas, @eatlas/deckgl-barlayer etc
  • @layik/barlayer ... dont like this
  • ?

Choosing date standard

For current (future) releases we must simplify how eAtlas handles date/time. For now:

  • ask users to bring ISO dates
  • continue using luxon to parse them using .fromISO

Update main/master README

This is an issue as the project now has grown beyond a quick README. It does need a structure and some good write up.

backend performance

Hi Layik,

Thanks for making this open source! I had a few questions about your implementation, apologies if these questions would be better suited to the geoplumber repository:

It seems to me that the R backend / geoplumber is used to read geospatial data, convert it to geojson if necessary, and then serve the geojson via API. However, why not cut out the middleman, and get the browser to load geojson directly, from GitHub pages for example? People who want to reuse this wouldn't need to run a server / write R code for each new dataset, and the geojson could be cached by the browser / compressed / served over a CDN. R / plumber / geoplumber operate single threaded - so if one user is requesting some data that takes a long time to download, it can slow down the experience for other users. This can be mitigated by running multiple docker containers and load balancing across them - but this seems like over-engineering when there are freely available CDNs that would be more performant.

For example, with my wired gigabit connection here in Auckland, New Zealand:

time curl http://eatlas.geoplumber.com/api/covid19 > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 43.2M  100 43.2M    0     0   324k      0  0:02:16  0:02:16 --:--:--  501k

real	2m16.520s
user	0m0.186s
sys	0m0.431s

It takes 2 minutes and 16 seconds to load 43MB from your geoplumber.com server, probably due to the 300ms ping.

Cheers,
Nick Young
Centre for eResearch, University of Auckland

Delete `README.Rmd`

README.Rmd is generated from README.md using markdown::render. Since we are regularly updating README.md with installation/setup instructions, this is a bit of a pain.

  • generate .md when .Rmd modified?
    • new .git.hooks folder for storing commit hooks in repo
    • create .git.hooks/pre-commit and make executable
    • symlink to .git.hooks/pre-commit from .git/hooks
    • install rmarkdown into RStudio from CRAN
    • install pandocpackage ‘pandoc’ is not available for this version of R
    • lazy installation of required packages in pre-commit
  • [alternatively] delete README.Rmd

QUANT large scale vis

The data from QUANT is literally huge. Thanks to Dr Richard Milton from UCL for providing the data.

That means DeckGL layers might not have built in layers to assist. This ticket is a place-holder for that.

npm package publish

  • clean up and branch here
  • tested locally
  • minified as one file (not easy due to composite layer)
  • other?

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.