{"id":15292956,"url":"https://github.com/r-barnes/webglobe","last_synced_at":"2025-05-07T03:21:57.088Z","repository":{"id":56936053,"uuid":"88952122","full_name":"r-barnes/webglobe","owner":"r-barnes","description":"3D globe visualization for R","archived":false,"fork":false,"pushed_at":"2020-09-15T16:54:15.000Z","size":11583,"stargazers_count":30,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-18T18:33:38.931Z","etag":null,"topics":["3d","cesiumjs","data-visualization","globe","r","visualization"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-barnes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-21T06:54:28.000Z","updated_at":"2024-10-19T05:27:07.000Z","dependencies_parsed_at":"2022-08-21T06:20:44.114Z","dependency_job_id":null,"html_url":"https://github.com/r-barnes/webglobe","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-barnes%2Fwebglobe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-barnes%2Fwebglobe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-barnes%2Fwebglobe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-barnes%2Fwebglobe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-barnes","download_url":"https://codeload.github.com/r-barnes/webglobe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804791,"owners_count":21806878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","cesiumjs","data-visualization","globe","r","visualization"],"created_at":"2024-09-30T16:36:41.310Z","updated_at":"2025-05-07T03:21:57.071Z","avatar_url":"https://github.com/r-barnes.png","language":"R","readme":"webglobe: Interactive 3D Maps\n=============================\n\nYou want to understand your data, but it's spatially distributed and you're\nafraid that trying to make sense of it on something gross, like a Mercator\nprojection, is going to lead you to bad intuitions.\n\n![Mercator Projection](vignettes/mercator.png)\n\n(Greenland is nowhere near that big in reality.)\n\nwebglobe can help you do this! It allows you to interactively visualize your\ndata on either a three-dimensional globe or a flat map.\n\n\n\nExample: Earth quakes\n-----------------------------\n\n    library(webglobe)              #Load the library\n    data(quakes)                   #Load up some data\n\n    wg \u003c- webglobe(immediate=TRUE) #Make a webglobe (should open a net browser)\n    Sys.sleep(10)                     #Wait for browser to start, or it won't work\n    wg + wgpoints(quakes$lat, quakes$lon, size=5*quakes$mag) #Plot quakes\n    wg + wgcamcenter(-24, 178.0650, 8000)                    #Move camera\n\n![Webglobe earthquakes visualization](vignettes/webglobe_quakes.png)\n\n\n\nExample: States\n-----------------------------\n\n    library(webglobe)                 #Load the library\n    m  \u003c- ggplot2::map_data(\"state\")  #Get data\n    m$extrude_height \u003c- 1000000*runif(nrow(m),min=0,max=1)\n    wg \u003c- webglobe(immediate=TRUE)    #Make a webglobe (should open a net browser)\n    Sys.sleep(10)                     #Wait for browser to start, or it won't work\n    wg + wgpolygondf(m,fill=\"blue\",alpha=1,stroke=NA)\n    Sys.sleep(10)                     #Wait, in case you copy-pasted this\n    wg + wgclear()                    #Clears the above\n\n![Webglobe states visualization](vignettes/webglobe_states.png)\n\n\n\nModes\n-----------------------------\n\nwebglobes have two modes: **immediate** and **not-immediate**. Immediate mode\ndisplays a webglobe upon initialization and immediately prints all commands to\nthat globe. Not-immediate mode stores commands and displays them all at once,\nallowing you to stage visualization without intermediate display. The difference\nis illustrated below.\n\nDisplay timing in intermediate mode:\n\n    library(webglobe)\n    data(quakes)                     #Get data\n    q   \u003c- quakes                    #Alias data\n    wgi \u003c- webglobe(immediate=TRUE)  #Webglobe is displayed now\n    Sys.sleep(10)                    #Ensure webglobe runs before continuing\n    wgi + wgpoints( q$lat,  q$lon)    #Data displays now!\n    wgi + wgpoints(-q$lat, -q$lon)    #Data displays now!\n    #Reloading the browser window clears everything\n\nDisplay timing in not-intermediate mode:\n\n    library(webglobe)\n    data(quakes)                                  #Get data\n    q   \u003c- quakes                                 #Alias data\n    wgn \u003c- webglobe(immediate=FALSE)              #Webglobe is not displayed\n    Sys.sleep(0)                                  #No need to wait\n    #Note that we have to store commands\n    wgn \u003c- wgn + wgpoints( q$lat,  q$lon)         #Nothing shown yet\n    wgn \u003c- wgn + wgpoints(-q$lat, -q$lon)         #Nothing shown yet\n    wgn \u003c- wgn + wgcamcenter(2.89,-175.962,21460) #Nothing shown yet\n    wgn                                           #Show it all now!\n    #Reloading the browser window keeps everything\n\nYou can also switch between modes:\n\n    library(webglobe)\n    data(quakes)                                  #Get data\n    q   \u003c- quakes                                 #Alias data\n    wgn \u003c- webglobe(immediate=FALSE)              #Webglobe is not displayed\n    Sys.sleep(0)                                  #No need to wait\n    #Note that we have to store commands\n    wgn \u003c- wgn + wgpoints( q$lat,  q$lon)         #Nothing shown yet\n    wgn \u003c- wgn + wgpoints(-q$lat, -q$lon)         #Nothing shown yet\n    wgn \u003c- wgn + wgcamcenter(2.89,-175.962,21460) #Nothing shown yet\n    wgn + wgimmediate()                           #Make it all immediate\n    wgn\n    wgn + wgpoints(q$lat, -q$lon)                 #This is shown right away\n    #Reloading the browser window keeps everything up to `wgimmediate()`\n\n\n\nInstallation\n-----------------------------\n\nwebglobe **hopefully will be** available from CRAN via:\n\n    install.packages('webglobe')\n\nIf you want your code to be as up-to-date as possible, you can install it using:\n\n    library(devtools) #Use `install.packages('devtools')` if need be\n    install_github('r-barnes/webglobe', vignette=TRUE)\n\n\n\nDeveloper Notes\n-----------------------------\n\n**How To Add Functionality**\n\nThere are really only two files that are import to contributing developers:\n[inst/client/webglobe.js](inst/client/webglobe.js)\nand\n[R/webglobe.R](R/webglobe.R)\n.\n\nThe package uses a JSON websocket message passing scheme to communicate data\nbetween R and the JavaScript client.\n\nEach `wg*()` function generates a JSON payload as follows:\n\n    toString(jsonlite::toJSON(list(\n      command = jsonlite::unbox(\"COMMAND_NAME\"), #Required\n      lat     = lat,                             #Example\n      lon     = lon                              #Example\n    )))\n\nThe payload consists of a `command` and accompanying data.\n\nFor more complex data, `geojsonio` can be leveraged to conveniently encode the\ndata. However, the resulting GeoJSON must be decoded, so that the whole packae\ncan be sent with only one level of encoding, as follows:\n\n    toString(jsonlite::toJSON(list(\n      command        = jsonlite::unbox(\"polygons\"),\n      polys          = jsonlite::fromJSON(geojsonio::geojson_json(df, group='group', geometry='polygon'))\n    )))\n\nOn the JavaScript side, look for an object named `router`. `router` contains a\nvariety of fields which correspond to command names. To add a new command, add a\nfield with a corresponding function, such as:\n\n    points: function(msg){\n      var points = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());\n      for(var i=0;i\u003cmsg.lat.length;i++){\n        points.add({\n          position:  new Cesium.Cartesian3.fromDegrees(msg.lon[i], msg.lat[i], msg.alt[i]),\n          color:     Cesium.Color[msg.colour[i].toUpperCase()],\n          pixelSize: msg.size[i]\n        });\n      }\n    }\n\nNote that it is standard for the package to accept arguments such as `color`,\n`size`, `width`, and so on as having either one value or a number of values\nequal to the number of input points, polygons, or lines. That is: you should be\nable to set the property of the entire group at once or at an individual level.\n\nNote that functions added to [R/webglobe.R](R/webglobe.R) should be accompanied\nby help text an examples, see the existing functions for templates.\nDocumentation should then be regenerated using\n\n    roxygen2::roxygenise()\n\nChanges to the vignettes (e.g. [vignettes/webglobe.Rmd](vignettes/webglobe.Rmd))\ncan be built using:\n\n    devtools::build_vignettes()\n\nIt is polite to ensure that everything's good by using:\n\n    devtools::check()\n\nOnce you have added your function, documented it, added any pertinent\nexplanations to the vignettes, and checked it, submit a pull request!\n\n\nLicensing\n-----------------------------\n\nThis package uses the following libraries:\n\n * cesiumjs: Cesium is licensed under Apache v2\n\nThis package, and all code and documentation not otherwise mentioned above\n(essentially anything outside the `src/` directory of this package) are released\nunder the MIT (Expat) license, as stated in the `LICENSE` file. The `LICENCE`\nfile exists for use with CRAN.\n\n\n\nRoadmap\n-----------------------------\n\n* Make not-intermediate mode work\n\n* Additional graphics primitives\n\n* Submission to CRAN\n\n\n\nCredits\n-----------------------------\n\nThis R package was developed by Richard Barnes (https://rbarnes.org/).\n\nIt uses the Cesium WebGL virtual globe and map engine ([link](https://cesium.com/cesiumjs/)).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-barnes%2Fwebglobe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-barnes%2Fwebglobe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-barnes%2Fwebglobe/lists"}