Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 1 committers (100.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.3%) to scientific vocabulary
Keywords
Repository
3D globe visualization for R
Basic Info
- Host: GitHub
- Owner: r-barnes
- License: mit
- Language: R
- Default Branch: master
- Size: 11 MB
Statistics
- Stars: 30
- Watchers: 4
- Forks: 2
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
webglobe: Interactive 3D Maps
You want to understand your data, but it's spatially distributed and you're afraid that trying to make sense of it on something gross, like a Mercator projection, is going to lead you to bad intuitions.

(Greenland is nowhere near that big in reality.)
webglobe can help you do this! It allows you to interactively visualize your data on either a three-dimensional globe or a flat map.
Example: Earth quakes
library(webglobe) #Load the library
data(quakes) #Load up some data
wg <- webglobe(immediate=TRUE) #Make a webglobe (should open a net browser)
Sys.sleep(10) #Wait for browser to start, or it won't work
wg + wgpoints(quakes$lat, quakes$lon, size=5*quakes$mag) #Plot quakes
wg + wgcamcenter(-24, 178.0650, 8000) #Move camera

Example: States
library(webglobe) #Load the library
m <- ggplot2::map_data("state") #Get data
m$extrude_height <- 1000000*runif(nrow(m),min=0,max=1)
wg <- webglobe(immediate=TRUE) #Make a webglobe (should open a net browser)
Sys.sleep(10) #Wait for browser to start, or it won't work
wg + wgpolygondf(m,fill="blue",alpha=1,stroke=NA)
Sys.sleep(10) #Wait, in case you copy-pasted this
wg + wgclear() #Clears the above

Modes
webglobes have two modes: immediate and not-immediate. Immediate mode displays a webglobe upon initialization and immediately prints all commands to that globe. Not-immediate mode stores commands and displays them all at once, allowing you to stage visualization without intermediate display. The difference is illustrated below.
Display timing in intermediate mode:
library(webglobe)
data(quakes) #Get data
q <- quakes #Alias data
wgi <- webglobe(immediate=TRUE) #Webglobe is displayed now
Sys.sleep(10) #Ensure webglobe runs before continuing
wgi + wgpoints( q$lat, q$lon) #Data displays now!
wgi + wgpoints(-q$lat, -q$lon) #Data displays now!
#Reloading the browser window clears everything
Display timing in not-intermediate mode:
library(webglobe)
data(quakes) #Get data
q <- quakes #Alias data
wgn <- webglobe(immediate=FALSE) #Webglobe is not displayed
Sys.sleep(0) #No need to wait
#Note that we have to store commands
wgn <- wgn + wgpoints( q$lat, q$lon) #Nothing shown yet
wgn <- wgn + wgpoints(-q$lat, -q$lon) #Nothing shown yet
wgn <- wgn + wgcamcenter(2.89,-175.962,21460) #Nothing shown yet
wgn #Show it all now!
#Reloading the browser window keeps everything
You can also switch between modes:
library(webglobe)
data(quakes) #Get data
q <- quakes #Alias data
wgn <- webglobe(immediate=FALSE) #Webglobe is not displayed
Sys.sleep(0) #No need to wait
#Note that we have to store commands
wgn <- wgn + wgpoints( q$lat, q$lon) #Nothing shown yet
wgn <- wgn + wgpoints(-q$lat, -q$lon) #Nothing shown yet
wgn <- wgn + wgcamcenter(2.89,-175.962,21460) #Nothing shown yet
wgn + wgimmediate() #Make it all immediate
wgn
wgn + wgpoints(q$lat, -q$lon) #This is shown right away
#Reloading the browser window keeps everything up to `wgimmediate()`
Installation
webglobe hopefully will be available from CRAN via:
install.packages('webglobe')
If you want your code to be as up-to-date as possible, you can install it using:
library(devtools) #Use `install.packages('devtools')` if need be
install_github('r-barnes/webglobe', vignette=TRUE)
Developer Notes
How To Add Functionality
There are really only two files that are import to contributing developers: inst/client/webglobe.js and R/webglobe.R .
The package uses a JSON websocket message passing scheme to communicate data between R and the JavaScript client.
Each wg*() function generates a JSON payload as follows:
toString(jsonlite::toJSON(list(
command = jsonlite::unbox("COMMAND_NAME"), #Required
lat = lat, #Example
lon = lon #Example
)))
The payload consists of a command and accompanying data.
For more complex data, geojsonio can be leveraged to conveniently encode the
data. However, the resulting GeoJSON must be decoded, so that the whole packae
can be sent with only one level of encoding, as follows:
toString(jsonlite::toJSON(list(
command = jsonlite::unbox("polygons"),
polys = jsonlite::fromJSON(geojsonio::geojson_json(df, group='group', geometry='polygon'))
)))
On the JavaScript side, look for an object named router. router contains a
variety of fields which correspond to command names. To add a new command, add a
field with a corresponding function, such as:
points: function(msg){
var points = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
for(var i=0;i<msg.lat.length;i++){
points.add({
position: new Cesium.Cartesian3.fromDegrees(msg.lon[i], msg.lat[i], msg.alt[i]),
color: Cesium.Color[msg.colour[i].toUpperCase()],
pixelSize: msg.size[i]
});
}
}
Note that it is standard for the package to accept arguments such as color,
size, width, and so on as having either one value or a number of values
equal to the number of input points, polygons, or lines. That is: you should be
able to set the property of the entire group at once or at an individual level.
Note that functions added to R/webglobe.R should be accompanied by help text an examples, see the existing functions for templates. Documentation should then be regenerated using
roxygen2::roxygenise()
Changes to the vignettes (e.g. vignettes/webglobe.Rmd) can be built using:
devtools::build_vignettes()
It is polite to ensure that everything's good by using:
devtools::check()
Once you have added your function, documented it, added any pertinent explanations to the vignettes, and checked it, submit a pull request!
Licensing
This package uses the following libraries:
- cesiumjs: Cesium is licensed under Apache v2
This package, and all code and documentation not otherwise mentioned above
(essentially anything outside the src/ directory of this package) are released
under the MIT (Expat) license, as stated in the LICENSE file. The LICENCE
file exists for use with CRAN.
Roadmap
Make not-intermediate mode work
Additional graphics primitives
Submission to CRAN
Credits
This R package was developed by Richard Barnes (https://rbarnes.org/).
It uses the Cesium WebGL virtual globe and map engine (link).
Owner
- Name: Richard Barnes
- Login: r-barnes
- Kind: user
- Website: https://richard.science
- Repositories: 43
- Profile: https://github.com/r-barnes
Scientist. Developer. Tinkerer.
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Richard Barnes | r****s@u****u | 82 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: about 1 year
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 4.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- amsantac (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 211 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
cran.r-project.org: webglobe
3D Interactive Globes
- Homepage: https://github.com/r-barnes/webglobe/
- Documentation: http://cran.r-project.org/web/packages/webglobe/webglobe.pdf
- License: MIT + file LICENCE
-
Latest release: 1.0.3
published over 5 years ago
Rankings
Maintainers (1)
Dependencies
- R >= 3.4.0 depends
- geojsonio >= 0.3.2 depends
- httpuv >= 1.3.3 depends
- jsonlite >= 1.4 depends
- R.rsp >= 0.41.0 suggests
- knitr * suggests
- rmarkdown >= 1.0 suggests