Giter Club home page Giter Club logo

autostk's Introduction

autoSTK

  • Description: Automatic spatio-temporal kriging inspired by automap (Hiemstra et al. 2010)
  • Inherits most of automap functions, but extensively revised
  • Includes spatiotemporal variogram fitting and Kriging analysis

Installation

  • remotes::install_github('sigmafelix/autoSTK') in R (The remotes package is required)
  • Before you install the package, please make it sure you have gstat, spacetime, and automap packages in your machine

Supported functions

  • autofitVariogramST: automatically fit the spatiotemporal variogram
  • autoKrigeST: automatically estimate the spatiotemporal variables for specified period ahead (the default value is 6 temporal units)
    • Currently support STFDF and STSDF class and ordinary spatiotemporal Kriging (e.g., y~1)
  • autoKrigeST.cv: automatically cross-validate the spatiotemporal data by spatial, temporal, spatiotemporal, and random slicing

Update plan

  • Add support for STIDF class and universal spatiotemporal Kriging: necessitates the gstat function fix for variogramST.STIDF
  • Transition to sf and sftime in preparation of the retirement of sp in October 2023
  • Add support for the spatiotemporal separability test (referring to covatest (De Iaco, 2020))

Main features

  • Split data into spatial and temporal dimensions which are compatible to be fitted as components of a spatio-temporal variogram
  • Find the optimal theoretical variograms with BFHS algorithm following the autofitVariogram function of automap package; but several changes were applied

Please note

  • I strongly recommend users to convert STIDF to STSDF before running functions
    • When the input is sftime, convert the input into STIDF then into STSDF

Working example

  • Please consult the help page of the main functions autoKrigeST and autoKrigeST.cv.
library(autoSTK)
library(gstat)
library(spacetime)
library(stars)
library(sp)

data(air)
deair = STFDF(stations, dates, data.frame(PM10 = as.vector(air)))
deair_sf = st_as_stars(deair) %>%
    st_transform('+proj=longlat +ellps=sphere')
deair_sf = st_transform(deair_sf, 3857)
deair_r = as(deair_sf, 'STFDF')
deair_r@sp@proj4string = CRS('+init=epsg:3857')

deair_rs = deair_r[,3701:3800]
deair_rss = as(deair_rs, 'STSDF')

## autoKrigeST
akst_stk = autoKrigeST(formula = PM10~1, 
                       input_data = deair_rss, 
                       cutoff = 300000, width = 30000, tlags = 0:7, cores = 8)

akst_stk_stars = st_as_stars(akst_stk[[1]])
plot(akst_stk_stars[1,])

## autoKrigeST.cv
akst_cv_t = autoKrigeST.cv(formula = PM10~1, data = deair_rs,  nfold = 3, fold_dim = 'temporal', 
                         cutoff = 300000, width = 30000, tlags = 0:7, cores = 8)
akst_cv_s = autoKrigeST.cv(formula = PM10~1, data = deair_rs,  nfold = 3, fold_dim = 'spatial', 
                         cutoff = 300000, width = 30000, tlags = 0:7, cores = 8)
akst_cv_spt = autoKrigeST.cv(formula = PM10~1, data = deair_rs,  nfold = 4, fold_dim = 'spacetime', 
                         cutoff = 300000, width = 30000, tlags = 0:7, cores = 8)

Created on 2021-07-15 by the reprex package (v2.0.0)

autostk's People

Contributors

sigmafelix avatar

Stargazers

Johanna Fornberg avatar  avatar Starved Midnight avatar  avatar Stan avatar DaiShaoqing avatar

Watchers

Starved Midnight avatar

autostk's Issues

Error using autofitVariogramST

Hello.
I wanna report an error with:
I used temperature information for my STFDF object.
Thanks for ur help.

v_stk<- autofitVariogramST(datos_STFDF,values ~ 1)

|============================================================| 100%
np dist gamma id timelag spacelag avgDist
2 5108886 0.33196 0.3189710 lag0 0 days 250 0.33196
42 283790 0.00000 0.4311195 lag1 1 days 0 0.00000
43 10216440 0.33196 0.4297990 lag1 1 days 250 0.33196
83 283753 0.00000 0.5638979 lag2 2 days 0 0.00000
84 10215108 0.33196 0.5561521 lag2 2 days 250 0.33196
124 283716 0.00000 0.6718891 lag3 3 days 0 0.00000
125 10213776 0.33196 0.6670738 lag3 3 days 250 0.33196
165 283679 0.00000 0.7382632 lag4 4 days 0 0.00000
166 10212444 0.33196 0.7378229 lag4 4 days 250 0.33196
206 283642 0.00000 0.7915491 lag5 5 days 0 0.00000
207 10211112 0.33196 0.7914823 lag5 5 days 250 0.33196
247 283605 0.00000 0.8531401 lag6 6 days 0 0.00000
248 10209780 0.33196 0.8485189 lag6 6 days 250 0.33196
np dist gamma id timelag spacelag avgDist
2 5108886 0.33196 0.3189710 lag0 0 days 250 0.33196
42 283790 0.00000 0.4311195 lag1 1 days 0 0.00000
43 10216440 0.33196 0.4297990 lag1 1 days 250 0.33196
83 283753 0.00000 0.5638979 lag2 2 days 0 0.00000
84 10215108 0.33196 0.5561521 lag2 2 days 250 0.33196
124 283716 0.00000 0.6718891 lag3 3 days 0 0.00000
125 10213776 0.33196 0.6670738 lag3 3 days 250 0.33196
165 283679 0.00000 0.7382632 lag4 4 days 0 0.00000
166 10212444 0.33196 0.7378229 lag4 4 days 250 0.33196
206 283642 0.00000 0.7915491 lag5 5 days 0 0.00000
207 10211112 0.33196 0.7914823 lag5 5 days 250 0.33196
247 283605 0.00000 0.8531401 lag6 6 days 0 0.00000
248 10209780 0.33196 0.8485189 lag6 6 days 250 0.33196

Error in $<-.data.frame(*tmp*, "dir.hor", value = 0) :
replacement has 1 row, data has 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.