{"id":13857774,"url":"https://github.com/adamlilith/fasterRaster","last_synced_at":"2025-07-13T22:31:10.722Z","repository":{"id":38080974,"uuid":"148095721","full_name":"adamlilith/fasterRaster","owner":"adamlilith","description":"Faster raster processing in R using GRASS GIS","archived":false,"fork":false,"pushed_at":"2025-06-19T21:59:47.000Z","size":96688,"stargazers_count":61,"open_issues_count":12,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-19T22:20:33.354Z","etag":null,"topics":["aspect","distance","fragmentation","fragmentation-indices","gis","grass","grass-gis","raster","raster-projection","rasterize","slope","topography","vectorization"],"latest_commit_sha":null,"homepage":"https://adamlilith.github.io/fasterRaster/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamlilith.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-10T03:45:11.000Z","updated_at":"2025-06-09T06:51:39.000Z","dependencies_parsed_at":"2023-02-15T20:45:34.372Z","dependency_job_id":"2e4b4837-ece4-4e5f-8486-c14093066f04","html_url":"https://github.com/adamlilith/fasterRaster","commit_stats":{"total_commits":141,"total_committers":2,"mean_commits":70.5,"dds":0.05673758865248224,"last_synced_commit":"74467d3066d47c2412de6d7f1dfeb5c1486abc3e"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/adamlilith/fasterRaster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlilith%2FfasterRaster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlilith%2FfasterRaster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlilith%2FfasterRaster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlilith%2FfasterRaster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamlilith","download_url":"https://codeload.github.com/adamlilith/fasterRaster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamlilith%2FfasterRaster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265218201,"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":["aspect","distance","fragmentation","fragmentation-indices","gis","grass","grass-gis","raster","raster-projection","rasterize","slope","topography","vectorization"],"created_at":"2024-08-05T03:01:46.618Z","updated_at":"2025-07-13T22:31:10.703Z","avatar_url":"https://github.com/adamlilith.png","language":"R","readme":"# fasterRaster\n\u003c!-- badges: start --\u003e\n\n[![cran version](https://www.r-pkg.org/badges/version/fasterRaster)](https://cran.r-project.org/package=fasterRaster) [![R-CMD-check](https://github.com/adamlilith/fasterRaster/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/adamlilith/fasterRaster/actions/workflows/R-CMD-check.yaml) [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](http://perso.crans.org/besson/LICENSE.html)\n\n\u003c!-- badges: end --\u003e\nFaster raster processing in `R` using `GRASS`\n\n\u003ca href=\"https://adamlilith.github.io/fasterRaster/index.html\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"130\" alt=\"fasterRaster website\" /\u003e\u003c/a\u003e\n\n`fasterRaster` is an **R** package designed specifically to handle large-in-memory/large-on-disk spatial rasters and vectors. `fasterRaster` does this using Open Source Geospatial's \u003ca href=\"https://grass.osgeo.org/\"\u003e`GRASS`\u003c/a\u003e\n\n`fasterRaster` was created with five design principles:\n\n* **Value added**: `fasterRaster` complements `terra` and `sf`, and is highly dependent on them! It is useful for analyzing large-in-memory/large-on-disk rasters and vectors that those packages struggle to handle. For medium- and small-size objects, `terra` and `sf` will almost always be faster.  \n* **Familiarity**: If you know how to use `terra`, you basically know how to use `fasterRaster`! That's because most of the functions have the same name and almost the same arguments as `terra` functions.  \n* **Comparability**: To the degree possible, outputs from `fasterRaster` are the same as those from functions in `terra` with the same name.  \n* **Simplicity**: `GRASS` requires users to track things like \"locations\" or \"projects\", \"mapsets\", and \"regions\" for which there is no comparable analog in the `terra` or `sf` packages. `fasterRaster` handles these behind the scenes so you don't need to.  \n* **It's R**: The `rgrass` package provides a powerful conduit through which you can run `GRASS` tools from `R`. As such, it provides much more flexibility than `fasterRaster`. However, to use `rgrass`, you need to know what `GRASS` tools you want to use and be familiar with `GRASS` syntax. `fasterRaster` obviates this step but uses `rgrass` as a backend, allowing you to focus on `R` syntax and look up help for functions the normal way you do in `R`. You don't need to know `GRASS`!\n\n`fasterRaster` makes heavy use of the \u003ca href=\"https://cran.r-project.org/package=rgrass\"\u003e`rgrass`\u003c/a\u003e package by Roger Bivand and others, the \u003ca href=\"https://cran.r-project.org/package=rgrass\"\u003e`terra`\u003c/a\u003e package by Robert Hijmans, the \u003ca href=\"https://cran.r-project.org/package=sf\"\u003e`sf`\u003c/a\u003e package by Edzer Pebesma, Roger Bivand, and others, and of course \u003ca href=\"https://grass.osgeo.org/\"\u003e`GRASS`\u003c/a\u003e, so is greatly indebted to all of these creators!\n\n# Vignettes \u0026 documentation\n**fasterRaster** comes with four user-oriented vignettes, plus a `pkgdown` \u003ca href=\"https://adamlilith.github.io/fasterRaster/index.html\"\u003esite\u003c/a\u003e with full documentation:\n\no \u003ca href=\"https://adamlilith.github.io/fasterRaster/articles/fasterRaster.html\"\u003eGetting started\u003c/a\u003e (also reproduced below)  \no \u003ca href=\"https://adamlilith.github.io/fasterRaster/articles/GRasters.html\"\u003eTypes of `GRaster`s\u003c/a\u003e  \no \u003ca href=\"https://adamlilith.github.io/fasterRaster/articles/faster_fasterRaster.html\"\u003eMaking **fasterRaster** faster\u003c/a\u003e  \no \u003ca href=\"https://adamlilith.github.io/fasterRaster/articles/addons.html\"\u003eAddons\u003c/a\u003e  \no \u003ca href=\"https://adamlilith.github.io/fasterRaster/\"\u003eDocumentation\u003c/a\u003e  \n\n# Installation\nTo install `fasterRaster`, please use:\n\n`install_packages('fasterRaster', dependencies = TRUE)`  \n\nYou can get the latest stable release using:\n\n`remotes::install_github('adamlilith/fasterRaster', dependencies = TRUE)`  \n\n...and the development version from:\n\n`remotes::install_github('adamlilith/fasterRaster@intuitive_fasterRaster', dependencies = TRUE)`  \n\nTo use `fasterRaster` you must install [GRASS version 8.3+](https://grass.osgeo.org/) on your operating system. **You will need to use the stand-alone installer, not the Open Source Geospatial (OS Geo) installer.**\n\n**Optional**: A few functions in **fasterRaster** require **GRASS** \"addon\" tools, which do not come bundled with **GRASS**. You do not need to install these addons if you do not use functions that call them. A list of functions that require addons can be seen in the \"addons\" vignette (in **R**, use `vignette(\"addons\", package = \"fasterRaster\")`). This vignette also explains how to install addons.\n\n# An example\n\nThe example presented here is the same as that presented in the the [\"getting started\"](https://adamlilith.github.io/fasterRaster/articles/fasterRaster.html) vignette.\n\nWe'll do a simple operation in which we:\n\n1. Add a buffer to lines representing rivers, then\n\n2. Calculate the distance to from each cell to the closest buffer and burn the distance values into a raster.\n\nTo do this, we'll be using maps representing the middle of the eastern coast of Madagascar. We will also use the `terra` and `sf` packages.\n\n```\nlibrary(terra) # GIS for rasters and vectors\nlibrary(sf) # GIS for vectors\nlibrary(fasterRaster)\n\n# Get example elevation raster and rivers vector:\nmadElev \u003c- fastData('madElev') # SpatRaster with elevation\nmadRivers \u003c- fastData('madRivers') # sp vector with rivers\n\n# Plot inputs:\nplot(madElev)\nplot(st_geometry(madRivers), col = \"lightblue\", add = TRUE)\n```\n\u003cimg src=\"man/figures/elev_rivers.png\"/\u003e  \n\nBefore you use nearly any function in the package, you need to tell `fasterRaster` where `GRASS` is installed on your system. The installation folder will vary by operating system and maybe `GRASS` version, but will look something like this:  \n\n```\n# Choose the appropriate one, and modify as needed:\ngrassDir \u003c- \"C:/Program Files/GRASS GIS 8.4\" # Windows\ngrassDir \u003c- \"/Applications/GRASS-8.4.app/Contents/Resources\" # Mac OS\ngrassDir \u003c- \"/usr/local/grass\" # Linux\n```\n\nNow, use the `faster()` function to tell `fasterRaster` where `GRASS` is installed:\n```\nfaster(grassDir = grassDir)\n```\n\nThe `fast()` function is the key function for loading a raster or vector into `fasterRaster` format. Rasters in this package are called `GRaster`s and vectors `GVector`s (the \"G\" stands for `GRASS`). We will now convert the `madElev` raster, which is a `SpatRaster` from the `terra` package, into a `GRaster`.\n```\nelev \u003c- fast(madElev)\nelev\n```\nYou will see the `GRaster`s metadata:\n```\nclass       : GRaster\ntopology    : 2D \ndimensions  : 1024, 626, NA, 1 (nrow, ncol, ndepth, nlyr)\nresolution  : 59.85157, 59.85157, NA (x, y, z)\nextent      : 731581.552, 769048.635, 1024437.272, 1085725.279 (xmin, xmax, ymin, ymax)\ncoord ref.  : Tananarive (Paris) / Laborde Grid \nname(s)     : madElev \ndatatype    : integer \nmin. value  :       1 \nmax. value  :     570\n```\n\nNext, we'll do the same for the rivers vector. In this case, the vector is an `sf` object from the `sf` package, but we could also use a `SpatVector` from the `terra` package.\n```\nrivers \u003c- fast(madRivers)\nrivers\n```\n```\nclass       : GVector\ngeometry    : 2D lines \ndimensions  : 11, 11, 5 (geometries, sub-geometries, columns)\nextent      : 731627.1, 762990.132, 1024541.235, 1085580.454 (xmin, xmax, ymin, ymax)\ncoord ref.  : Tananarive (Paris) / Laborde Grid \nnames       :   F_CODE_DES          HYC_DESCRI      NAM   ISO     NAME_0 \ntype        :        \u003cchr\u003e               \u003cchr\u003e    \u003cchr\u003e \u003cchr\u003e      \u003cchr\u003e \nvalues      : River/Stream Perennial/Permanent MANANARA   MDG Madagascar \n              River/Stream Perennial/Permanent MANANARA   MDG Madagascar \n              River/Stream Perennial/Permanent      UNK   MDG Madagascar \n             ...and  8  more rows\n\n```\n\nNow, let's add a 1000-m buffer to the rivers using `buffer()`. As much as possible, `fasterRaster` functions have the same names and same arguments as their counterparts in the `terra` package to help users who are familiar with that package.\n\nNote, though, that the output from `fasterRaster` is not necessarily guaranteed to be the same as output from the respective functions `terra`. This is because there are different methods to do the same thing, and the developers of `GRASS` may have chosen different methods than the developers of other GIS packages.\n```\n# width in meters because CRS is projected\nriver_buffers \u003c- buffer(rivers, width = 1000)\n```\n\nNow, let's calculate the distances between the buffered areas and all cells on the raster map using `distance()`.\n```\ndist_to_rivers_meters \u003c- distance(elev, river_buffers)\n```\n\nFinally, let's plot the output.\n```\nplot(dist_to_rivers_meters)\nplot(river_buffers, border = 'white', add = TRUE)\nplot(rivers, col = \"lightblue\", add = TRUE)\n```\n\n\u003cimg src=\"man/figures/dist_to_rivers.png\"/\u003e  \n\nAnd that's how it's done!  You can do almost anything in `fasterRaster`  you can do with `terra`. The examples above do not show the advantage of `fasterRaster` because the they do not use in large-in-memory/large-on-disk spatial datasets. For very large datasets, `fasterRaster` can be much faster! For example, for a large raster (many cells), the `distance()` function in `terra` can take many days to run and even crash `R`, whereas in `fasterRaster`, it could take just a few minutes or hours.\n\n## Exporting `GRaster`s and `GVector`s from a `GRASS` session\n\nYou can convert a `GRaster` to a `SpatRaster` raster using `rast()`:\n\n`terra_elev \u003c- rast(elev)`  \n\nTo convert a `GVector` to the `terra` package's `SpatVector`, use `vect()`:\n\n```\nterra_rivers \u003c- vect(rivers)\n```\n\nYou can use `writeRaster()` and `writeVector()` to save `fasterRaster` rasters and vectors directly to disk. This will *always* be faster than using `rast()` or `vect()` and then saving.\n```\nelev_temp_file \u003c- tempfile(fileext = \".tif\") # save as GeoTIFF\nwriteRaster(elev, elev_temp_file)\n\nvect_temp_shp \u003c- tempfile(fileext = \".shp\") # save as shapefile\nvect_temp_gpkg \u003c- tempfile(fileext = \".gpkg\") # save as GeoPackage\nwriteVector(rivers, vect_temp_shp)\nwriteVector(rivers, vect_temp_gpkg)\n```\n\n# Versioning\n\n`fasterRaster` versions will look something like `8.3.1.2`, or more generally, `M1.M2.S1.S2`. Here, `M1.M2` will mirror the version of `GRASS` for which `fasterRaster` was built and tested. For example, `fasterRaster` version 8.4.x.x will work using `GRASS` 8.4 (and version 8.3). The values in `S1.S2` refer to \"major\" and \"minor\" versions of `fasterRaster`.  That is, a change in the value of `S1` (e.g., from `x.x.1.0` to `x.x.2.0`) indicates changes that potentially break older code developed with a prior version of `fasterRaster`.  A change in `S2` refers to a bug fix, additional functionality in an existing function, or the addition of an entirely new function.\n\nNote that the `M1.M2` and `S1.S2` increment independently. For example, if the version changes from `8.3.1.5` to `8.4.1.5`, then the new version has been tested on `GRASS` 8.4, but code developed with version `8.3.1.x` of `fasterRaster` should still work.\n\n**NOTE**: While `fasterRaster` is still in beta/alpha release, the version will look something like `8.3.0.7XXX`, following Hadley Wickham's guidelines for versioning under development.\n\n# Further reading\n\n* Robert Hijman's [`terra`](https://cran.r-project.org/package=terra) package and Edzer Pebesma's [`sf`](https://cran.r-project.org/package=sf) package are good places to start if you are not familiar with doing GIS in `R`.  \n* Roger Bivand's [`rgrass`](https://cran.r-project.org/package=rgrass) package allows users to call any `GRASS` function with all of its functionality, which in some cases is far beyond what is allowed by `fasterRaster`.  \n* The [GRASS](https://grass.osgeo.org/) website is authoritative and contains the manual on all the `GRASS` functions used in this package and more.  \n* The Wiki on [how to run `GRASS` in `R` or `R` in `GRASS`](https://grasswiki.osgeo.org/wiki/R_statistics/rgrass) will help you to become a power-user of `GRASS` in `R`.\n\n# Citation\nA publication is forthcoming! In the meantime, please cite:\n\nSmith, A.B. 2024. `fasterRaster`: Faster raster processing in `R` using `GRASS`. URL: https://cran.r-project.org/package=fasterRaster.\n\n~ Adam\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamlilith%2FfasterRaster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamlilith%2FfasterRaster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamlilith%2FfasterRaster/lists"}