Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Miscellaneous Functions for Working with 'stars' Rasters

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

michaeldorman/starsExtra

Repository files navigation

CRAN_Status_BadgeCRAN_Downloads_Badge

starsExtra

R packagestarsExtra provides several miscellaneous functions forworking withstars objects, mainly single-band rasters. Currentlyincludes functions for:

  • Focal filtering
  • Detrending of Digital Elevation Models
  • Calculating flow length
  • Calculating the Convergence Index
  • Calculating topographic aspect and slope

Installation

CRAN version:

install.packages("starsExtra")

GitHub version:

install.packages("remotes")remotes::install_github("michaeldorman/starsExtra")

Usage

Once installed, the library can be loaded as follows.

library(starsExtra)

Documentation

The complete documentation can be found athttps://michaeldorman.github.io/starsExtra/.

Example

The following code applied a 15*15 mean focal filter on a 533*627stars Digital Elevation Model (DEM):

data(carmel)carmel_mean15= focal2(x=carmel,# Input 'stars' rasterw=matrix(1,15,15),# Weightsfun="mean",# Aggregation functionna.rm=TRUE,# 'NA' in neighborhood are removedmask=TRUE# Areas that were 'NA' in 'x' are masked from result)

The calculation takes: 0.5625446 secs.

The original DEM and the filtered DEM can be combined and plotted withthe following expressions:

r= c(carmel,carmel_mean15,along=3)r= st_set_dimensions(r,3,values= c("input","15*15 mean filter"))plot(r,breaks="equal",col= terrain.colors(10),key.pos=4)

Timing

The following code section compares the calculation time offocal2 inthe above example withraster::focal (both using C/C++) and thereference methodfocal2r (using R code only).

library(microbenchmark)library(starsExtra)library(raster)data(carmel)carmelr= as(carmel,"Raster")res= microbenchmark(focal2= focal2(carmel,w=matrix(1,15,15),fun="mean",na.rm=FALSE),focal= focal(carmelr,w=matrix(1,15,15),fun=mean,na.rm=FALSE),focal2r= focal2r(carmel,w=matrix(1,15,15),mean),times=10)res#> Unit: milliseconds#>     expr        min         lq       mean     median         uq        max neval#>   focal2   542.3506   546.0164   587.9224   554.3557   609.8761   793.5663    10#>    focal   114.3561   115.9764   142.2213   119.7932   125.9327   339.7064    10#>  focal2r 17236.5407 17367.5100 17734.2765 17634.1378 17902.5663 19048.0060    10
boxplot(res)

About

Miscellaneous Functions for Working with 'stars' Rasters

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp