{"id":13857677,"url":"https://github.com/plotly/rasterly","last_synced_at":"2025-07-13T22:31:02.353Z","repository":{"id":56936320,"uuid":"203848334","full_name":"plotly/rasterly","owner":"plotly","description":"Rapidly generate raster images from large datasets in R with Plotly.js","archived":true,"fork":false,"pushed_at":"2020-06-04T14:25:12.000Z","size":17057,"stargazers_count":48,"open_issues_count":0,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-22T15:41:15.527Z","etag":null,"topics":["data-visualization","plotly","plotly-dash","r","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plotly.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":"2019-08-22T18:08:46.000Z","updated_at":"2024-06-04T13:13:29.000Z","dependencies_parsed_at":"2022-08-21T01:10:23.100Z","dependency_job_id":null,"html_url":"https://github.com/plotly/rasterly","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/plotly/rasterly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotly%2Frasterly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotly%2Frasterly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotly%2Frasterly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotly%2Frasterly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plotly","download_url":"https://codeload.github.com/plotly/rasterly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotly%2Frasterly/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265218200,"owners_count":23729496,"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":["data-visualization","plotly","plotly-dash","r","rstats"],"created_at":"2024-08-05T03:01:43.851Z","updated_at":"2025-07-13T22:31:01.531Z","avatar_url":"https://github.com/plotly.png","language":"R","readme":"# rasterly \u003cimg src=\"https://user-images.githubusercontent.com/9809798/67056539-75d75200-f11a-11e9-9b62-2b62a349a45b.jpg\" align=\"right\" height=\"144\" width=\"124.8\"\u003e\n\n[![Build Status](https://travis-ci.org/z267xu/rasterly.svg?branch=master)](https://travis-ci.org/z267xu/rasterly)\n[![Codecov test coverage](https://codecov.io/gh/z267xu/rasterly/branch/master/graph/badge.svg)](https://codecov.io/gh/z267xu/rasterly?branch=master)\n[![CRAN status](https://www.r-pkg.org/badges/version/rasterly)](https://cran.r-project.org/web/packages/rasterly/index.html)\n[![](https://cranlogs.r-pkg.org/badges/rasterly)](https://cran.r-project.org/package=rasterly)\n\nEasily and rapidly generate raster data in R, even for larger volumes of data, with an aesthetics-based mapping syntax that should be familiar to users of the `ggplot2` package. \n\nWhile `rasterly` does not attempt to reproduce the full functionality of the Datashader graphics pipeline system for Python, the `rasterly` API has several core elements in common with that software package. Combined with Plotly.js and the `plotly` package, `rasterly` enables analysts to generate interactive figures which are responsive enough to embed into web applications.\n\nDocumentation: [https://z267xu.github.io/rasterly/](https://z267xu.github.io/rasterly/)\n\n## Importing datasets for use with rasterly\n\nThere are several ways to import large datasets into R for use with `rasterly`; one option is the `data.table` package (https://cran.r-project.org/web/packages/data.table/vignettes/datatable-intro.html).\n\n* csv file:\n```\nlibrary(data.table)\ndata \u003c- data.table::fread(\"yourpath/somefile.csv\") # or a link\n```\n\n* parquet file:\nApache Parquet is a column-oriented, open-source format which offers efficient data compression. There are a few options in R for importing Parquet data. One of these is the [`arrow`](https://cran.r-project.org/web/packages/arrow/index.html) package, now available on CRAN.\n\nThe package must build Apache Arrow first, so it may take a few minutes to install the first time around.\n\n```\nlibrary(arrow)\nparquet_data \u003c- read_parquet(\"somefile.parquet\")\n# returns a data.frame if sparklyr is not loaded, otherwise it will be a tibble\n# to obtain an ordinary data.frame, some slight postprocessing may be required\n# parquet_data \u003c- base::as.data.frame(parquet_data)\n```\n\n* fst file:\nThe [fst package](https://www.fstpackage.org/) is an excellent option for extremely fast serialization of large data frames in R. In addition to rapid compression using LZ4 and ZSTD, it provides support for multithreading to parallelize operations.\n\n```\nlibrary(fst)\nfst_data \u003c- read.fst(\"somefile.fst\")\n```\n\n## Installing the package\n\nThe `rasterly` package is now available from CRAN, and the most recent release will always be available on GitHub. To install the CRAN package:\n```\ninstall.packages(\"rasterly\")\n```\nTo install the current version available via GitHub instead:\n```\nremotes::install_github(\"plotly/rasterly\")\n```\n\n## Visualizing data with `rasterly`\n\n`rasterly` is inspired by the [`datashader`](http://datashader.org/getting_started/index.html) package available for Python. Both provide the capability to generate raster data for rapid rendering of graphics for even very large datasets.\n\nIn terms of performance, `datashader` is faster but `rasterly` is comparable. `rasterly` aims to provide a user-friendly interface to generate raster data for use with the `plotly` package; it cannot be used for plotting or rendering figures on its own.\n\n#### Producing an interactive graph with the plotly package\n\nTo illustrate the basic functionality provided by the package, we'll start by retrieving data on Uber trips taken in New York City from April 1st until September 30th of 2014. The dataset includes 4,533,327 observations.\n\n```\n# Load New York Uber data\nridesRaw_1 \u003c- \"https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data1.csv\" %\u003e%\n  data.table::fread(stringsAsFactors = FALSE)\nridesRaw_2 \u003c- \"https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data2.csv\" %\u003e%\n  data.table::fread(stringsAsFactors = FALSE)\nridesRaw_3 \u003c- \"https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data3.csv\"  %\u003e%\n  data.table::fread(stringsAsFactors = FALSE)\nridesDf \u003c- list(ridesRaw_1, ridesRaw_2, ridesRaw_3) %\u003e%\n  data.table::rbindlist()\n```\n\nNow that the data are loaded, we can pass them to `plot_ly` and pipe the output into `add_rasterly`:\n\n```\nplot_ly(ridesDf, x = ~Lat, y = ~Lon) %\u003e%\n add_rasterly_heatmap()\n```\n![](man/figures/add_rasterizer.gif)\n\n#### General usage\n\nPass the data into `rasterly`:\n```\nridesDf %\u003e%\n  rasterly(mapping = aes(x = Lat, y = Lon)) %\u003e%\n  rasterly_points() -\u003e p\np\n# or use simplied `rplot`\nwith(ridesDf,\n     rplot(x = Lat, y = Lon)\n)\n```\n![](man/figures/grid_rasterizer.png)\n\nNote that, `p` is a list of environments. The display info can be accessed through\n```\nr \u003c- rasterly_build(p)\nstr(r)\n```\n\n\"r\" contains image raster and other useful info (like numeric aggregation matrices) required to produce the image but it does **not** provide any graphs.\n\n## Example use in interactive web applications\n\nThe Uber NYC Rasterizer application in our Dash Gallery provides a simple live demo of the `rasterly` package in action. Check it out [here](https://dash-gallery.plotly.host/dashr-uber-rasterizer/)!\n\n\u003cimg width=\"840\" alt=\"Uber NYC Rasterizer screenshot\" src=\"https://user-images.githubusercontent.com/9809798/67794376-f1a69800-fa52-11e9-930d-ce57575ddef7.png\"\u003e\n\nA second [Dash for R](https://github.com/plotly/dashR) application to visualize (a much larger) dataset from the US Census Bureau is also [available](https://github.com/plotly/rasterly/tree/master/apps/UScensus).\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotly%2Frasterly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplotly%2Frasterly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotly%2Frasterly/lists"}