gstat | Spatial and spatio-temporal geostatistical modelling
kandi X-RAY | gstat Summary
kandi X-RAY | gstat Summary
Spatial and spatio-temporal geostatistical modelling, prediction and simulation
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gstat
gstat Key Features
gstat Examples and Code Snippets
Community Discussions
Trending Discussions on gstat
QUESTION
I'm fitting an exponential model to an empirical semivariogram using the package gstat.
My dataset (data) has latitude and longitude values in decimal degrees.
The range estimated using fit.variogram()
doesn't match the range that I'd expect by looking at the plot of the model. See code and figures below.
This is the output from fit.variogram()
:
ANSWER
Answered 2021-Mar-12 at 07:06The range reported is the range parameter a in the model exp(-h/a), and not the value at which the exponential model reaches 95% of its (partial) sill. To get that latter value, multiply by (approximately) 3.
QUESTION
I am very new to spatial evaluation and come from psychology.
I am using the software R and the packages "gstat" and "spacetime".
I would like to do a spatio temporal interpolation. For this I follow the paper of Gräler et al. (https://cran.r-project.org/web/packages/gstat/vignettes/spatio-temporal-kriging.pdf)
Unfortunately I can't find/fit the right variogram model. I can create the empirical variogram and this is also conclusive to me, but then I do not get any further. I do not understand how to define the individual parameters such as "sill" or "nugget" or what they stand for.
Here are my previous approaches:
My ST-Dataframe:
...ANSWER
Answered 2021-Jan-24 at 13:04The initial parameters of sill
, range
and nugget
can be read from the empirical spatiotemporal variogram. Produce a 3D wireframe plot of your empirical variogram by:
QUESTION
I'm developing an small application and I have a problem when creating the menu bar. This is my start method:
...ANSWER
Answered 2021-Jan-03 at 19:10You have to loop through pairNameMenu
items after you have created and added all the items to pairNameMenu
:
QUESTION
Does anyone have any suggestions on how to export the values from your kriged data in R. I have them exported as a raster, but I need the actual cell values. The data that I'm working with are fish densities. I'm kriging the data and then converting to densities to abundance. BUT in order to convert to abundances I need the kriged values in .csv format.
Below is the code that I'm using:
...ANSWER
Answered 2020-Apr-10 at 19:40Your example is neither minimal nor reproducible. You could have taken an example from gstat
It looks like you are interested in object fsite.ok
. Presumably a Spatial*DataFrame
.
Example code
QUESTION
library(rgdal)
library(maptools)
library(gstat)
library(sp)
data <- read.table("meuse.txt", sep="", header=TRUE) # read txt file
# transform the data frame into a spatial data frame
coordinates(data) <- ~ x + y
## Set the coordinate system
proj4string(data) <- CRS("+init=epsg:4326")
## the epsg numbers can be found here: http://spatialreference.org/ref/
# import the border shp file
border <- readOGR("meuse_area.shp", "meuse_area")
proj4string(border) <- CRS("+init=epsg:4326")
# import a raster from a ArcInfo ASCII format
zinc <- read.asciigrid("zinc.asc")
proj4string(zinc) <- CRS("+init=epsg:4326")
# Let's first create a prediction grid for the interpolation, starting from
# the shape file
vals <- border@bbox
deltaLong <- as.integer((vals[1, 2] - vals[1, 1]) + 1.5)
deltaLat <- as.integer((vals[2, 2] - vals[2, 1]) + 1.5)
gridRes <- 0.5 # change this value to change the grid size (in metres)
gridSizeX <- deltaLong / gridRes
gridSizeY <- deltaLat / gridRes
grd <- GridTopology(vals[, 1], c(gridRes, gridRes), c(gridSizeX, gridSizeY))
pts <- SpatialPoints(coordinates(grd))
pts1 <- SpatialPointsDataFrame(as.data.frame(pts),
data=as.data.frame(rep(1, nrow(as.data.frame(pts)))))
Overlay <- overlay(pts1, border)
pts1$border <- Overlay
nona <- na.exclude(as.data.frame(pts1))
coordinates(nona) <- ~ x + y
gridded(nona) <- TRUE
proj4string(nona) <- CRS("+init=epsg:4326") # remember to set the coordinate
# system also for the prediction grid
writeAsciiGrid(nona, "prediction_grid.asc")
# For the Co-kriging we need to obtain the value of the covariate for each
# observation
over <- overlay(zinc, data)
data$zinc <- over$zinc.asc
str(as.data.frame(data))
# also the prediction grid need to be overlayed with the covariate
over <- overlay(zinc, nona)
nona$zinc <- over$zinc.asc
# for the cokriging, the first thing to do is create an object with the
# function gstat() that contains both the variable and the covariate
str(data)
complete.cases("data")
str(zinc)
complete.cases("zinc")
g <- gstat(id="lead", formula=lead ~ 1, data=data)
g <- gstat(g, id="zinc", formula=zinc ~ 1, data=data)
# Fitting the variogram
# first, plot the residual variogram
vario <- variogram(g)
...ANSWER
Answered 2018-Dec-31 at 20:29One cause of the confusion here may be that sp used to include it's own overlay function.
https://www.rdocumentation.org/packages/sp/versions/0.9-7/topics/overlay
However the most recent version of the sp package replaced the "overlay" function with "over". I do no believe raster::overlay behaves the same as the overlay function from sp 0.9-7
QUESTION
I am using the following packages in my R script:
...ANSWER
Answered 2020-Feb-15 at 22:57One way is to write a simple function, that takes in a vector of packages and suppresses the output in a way you want, as examplified below.
QUESTION
Using this answer from Ege Rubak as an example, how can I predict pH values for a specific point, say lat = -23.49184
and long = 152.07185
, using the idw()
function in R
?
The closest answer I found was through this document in RPubs, but I could not extract just a specific value.
...ANSWER
Answered 2018-Aug-09 at 16:07You can use the extract
function from the raster
package. Notice that your point is outside of your original grid, so I increase by 1.5 to cover the point.
QUESTION
I have a directory with hundreds of files (macos), and I would like have a bash script copy each file to a directory of the creation stamp on the file. So if temp.mp4 was created on 2019-12-10, the file would be copied to that directory which may or may not exist.
I don't want to write anything to a temp file if I don't have to. I found that the following code gets just the file and date YYYY-MM-DD format:
...ANSWER
Answered 2019-Nov-07 at 17:36A great tool for accessing file information is stat. So first, ask stat to give creation dates and file names, so we can iterate over each of them:
QUESTION
I wish to do some "simple" inverse distance weighing. In the past I have used the idw function in gstat but that stopped working. I found an equivalent idw0 in the same package but I can not get that to work. This example code should produce 50 estimates for z-hat at the 50 points in the unknown.df data frame.
...ANSWER
Answered 2019-Nov-06 at 13:02Need to explicitly denote the coordinate fields.
QUESTION
I'm using Gaussian Process model for prediction, and I'm now at the point where I need to use Grid file based on the coordinates I have in my data but I don't have one and I don't know how to create it.
I followed the post on this link , but it shows the grid on Pennsylvania not Chicago where my data coordinates located!
So I'm confused which will be the ideal way to create grid file including the other columns in the data.
...ANSWER
Answered 2019-Sep-11 at 06:59I'm not sure what happened with your code, but it seems like your origin was set incorrectly. I've updated the code above to produce a grid over Chicago. I've picked a random starting point from Google Maps and modified x_cell
and y_cell
to produce a reasonably sized map over the city.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gstat
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page