Detail
In more detail, this proposal can be divided into three major milestones:
- Fast & efficient geo-spatial data transfer and web-mapping overlays
Data transfer functionality between R memory and the browser will be implemented in a small dedicated add-on package to htmlwidgets - geoarrowWidget. It will provide functions to convert geo-spatial in-memory data formats, such as sf, terra or wk, to geoarrow and to attach relevant dependencies (the geoarrow data and JavaScript libs to read it) to existing widgets. The intention is that other, including non-mapping applications can benefit from this as well. This functionality already largely exists, but is currently part of geoarrowDeckgl and will be moved to this new package.
geoarrowDeckgl will focus on providing highly performant overlays for maplibre maps using deck.gl layers utilising geoarrow/deck.gl-layers which is also used by the python library lonboard. This library is optimised for fast data processing in multiple ways, for example by copying “binary buffers directly from an Arrow JS Table object to the GPU”, among other optimisations (see here for a full list of features). Deck.gl is a GPU-powered tool for rendering large data amounts in the browser. It has dedicated support for several web-mapping libraries, including e.g. maplibre and leaflet, to overlay its layers on top base maps. The API of geoarrowDeckgl is tightly coupled to that of Deck.gl, in order to fully utilise and closely reflect the underlying functionality. This also enables easy adaptability to potential future API changes or extensions of this upstream dependency.
To achieve the above, we rely on packages geoarrow and nanoarrow for data conversion on the R side and several JavaScript libraries, such as arrowjs for client-side (browser) data handling, which will be shipped with the above mentioned newly developed packages (see list of dependencies below).
- Direct rendering support for cloud-native geo-spatial data formats
Most data in cloud-native geo-spatial formats can nowadays be read into R through packages such as sf and terra, among others. However, for visualising data that resides in the cloud it is preferable to not first materialise these data in R memory before sending it off to the rendering canvas in the browser, especially if only a subset of the data is of interest. Cloud-native data formats support partial reads so that data transfer over the wire is minimised, which makes them ideal for web-mapping applications. Reading the complete file and then rendering only parts of it would ignore the benefits of these data formats.
To overcome this, geoarrowDeckgl will provide functionality to allow users to visualise cloud data directly in the browser. The aim is to provide an API similar to that developed in 1., so that e.g. styling instructions can be defined in R, transferred to the browser and then be applied to the incoming data when it arrives. This means that the user is not expected to know any JavaScript. Functionality for cloud optimized geotiffs can be implemented with the Maplibre GL JS add-on maplibre-cog-protocol, while both geoparquet and flatgeobuf are supported by geoarrow/deck.gl-layers.
- Bindings for existing mapping packages
The third aim of this proposal is to scale the developments of 1. and 2. to the wider R spatial community.
Separating development of functionality for data transfer and web map overlays ensures that other, potentially non-mapping applications can benefit from fast data transfer without overhead. Detailed documentation and dedicated vignettes outlining how to use the transfer functionality will enable other developers to adopt it for their own needs. Note that this new package for data transfer will mainly be of interest to developers, not for end users; end users will benefit when it is adopted in downstream packages.
The development of geoarrowDeckgl will benefit both R developers and end users, as these developments will be made available for other web-mapping packages beyond mapgl, i.e. leaflet and mapdeck at the very least. Deck.gl has a dedicated add-on package for leaflet support (deck.gl-community/leaflet), however, as their web page states, this is in minimal maintainence mode, so it remains to be seen how long leaflet support can be realised. mapdeck is a wrapper around Deck.gl and as such it will be easy to provide bindings for it. tmap now has a dedicated extension package for using mapgl as the base map rendering paltform called tmap.mapgl which will also benefit from the developments made in geoarrowDeckgl. mapview is a higher-level mapping package that supports multiple rendering platforms and, as such, is easily extendable to mapgl and can benefit from performant rendering support developed through the efforts of this proposal. In fact, a first bare-bones implementation of mapgl as a rendering platform is already implemented in an experimental branch of mapview.
Minimum Viable Product
A minimum viable product of the above outlined proposal will include (in order of development):
- a new CRAN package -
geoarrowWidget - for fast data transfer as an add-on to htmlwidgets
- a CRAN release of
geoarrowDeckgl including:
- support for the major geo-spatial vector layer types for points, lines and polygons
- support for direct rendering of
cloud native geotiff, geoparquet and flatgeobuf data in the browser
- methods to support
leaflet and mapdeck based workflows
- detailed documentation, vignettes and blog-posts highlighting these new developments
Blog-posts will most likely be published on r-spatial.org, but other platforms such as the RConsortium blog can also be used, when desired by the ISC.
Architecture
The main delivery of this proposal will be geoarrowDeckgl, a new R package for fast and efficient overlays of geo-spatial data on web maps. It will provide dedicated methods for the web-mapping packages mapgl, leaflet and mapdeck. Another small package - geoarrowWidget - will be developed for fast data transfer from R memory to the browser, which will be in imported by geoarrowDeckgl.
Assumptions
There are no critical assumptions being made for this project.
External dependencies
R dependencies:
JavaScript dependencies: