terra | A large scale terrain rendering library written in Rust | Game Engine library
kandi X-RAY | terra Summary
kandi X-RAY | terra Summary
Terra supports rendering an entire planet with details ranging in scale from thousands of kilometers down to centimeters. In Terra, terrain is treated as a heightmap along with a collection of texture maps storing the surface normal, albedo, etc. All of this information can take quite a bit of space, so it isn't included in this repository. Instead, the necessary files are streamed from the internet at runtime and cached locally in a subdirectory with the current user's cache directory (which for instance defaults to ~/.cache/terra on Linux).
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 terra
terra Key Features
terra Examples and Code Snippets
Community Discussions
Trending Discussions on terra
QUESTION
I'm trying to install the package brms
in R so that I can rename the parameters returned from the function stan
(from the rstan
package). When I try install.package("brms", dependencies=TRUE)
, I get the (partial) output pasted at the end of this post (it's too long to paste the whole thing). At the end of the output, you can see that I get a series of "dependency errors", which makes sense because the very first error is not a dependency error, but rather a compilation error that says:
ANSWER
Answered 2022-Apr-16 at 17:24Start with
QUESTION
I am using the focal function in the terra package to fill holes in a DEM raster. However, after running focal(m, w=19, fun=mean, na.policy="only", na.rm=TRUE)
my DEM is moved ~11cm relative to it's original position (see images below). This problem does not occur when I simply read in the raster using rast()
and then write it using writeRaster()
, but it happens when I use focal()
regardless of whether I save the output using writeRaster()
or using the filename =
argument within focal()
.
I have also noticed that the larger the window size used, the greater the movement of the output raster. A window size of 9 produced ~5cm error. Raster pixels are ~1.2cm in size so focal()
appears to be causing a movement of ~1/2 the width of the window used. As far as I can tell the movement is straight up/north.
Any idea why this might be occuring and how it could be avoided?
This the correctly aligned raster:
And this is after running focal (w = 19):
...ANSWER
Answered 2022-Apr-09 at 04:44That is a bug that, I believe, has been fixed in the development version of terra
available at https://github.com/rspatial/terra (and that is also the best place to report bugs). Can you please try it?
QUESTION
I am trying to count the non-NA values in a spatRaster using the global()
function from the terra package. All the functions (mean, max, sd, etc.) seem to work except for "isNA"
and "notNA"
. For these two functions it returns this error: Error in fun(values(x[[i]]), ...) : could not find function "fun"
, which is the same error it returns for a misspelled/non-existent function.
ANSWER
Answered 2022-Apr-04 at 17:43When I run your code, it actually works:
QUESTION
Is there a way to have the plot legend categories in a specific order with a SpatVector map of package terra? Example:
...ANSWER
Answered 2022-Apr-01 at 12:35I have a bit tricky solution. You can manually set a legend in your plot using the base R legend
function. You can use the following code:
QUESTION
I want to crop a raster using a bbox or a known extent, i.e., 10 pixels in row and col.
Below you can see a reproducible example:
...ANSWER
Answered 2022-Apr-03 at 16:57Using terra
data, by your approach, which I like:
QUESTION
I want to select a group of pixels from a raster.
The user should enter an n value for selecting the number of columns and rows (or window size).
A window would fetch the number of pixels defined.
Would return a raster with the values.
Below is a piece of reproducible example:
...ANSWER
Answered 2022-Mar-31 at 20:00You can use standard indexing
QUESTION
I want to perform a neighborhood analysis in R to smooth the layer I have but keeping all the NAs of the input raster intact.
However, when I do, for instance, the following, the calculation "propagates" over the NA values - what it is an undesiderable behavior, in my case.
...ANSWER
Answered 2022-Mar-23 at 13:12With terra
the focal
method has an argument na.policy
that can be set to one of "all", "only" or "omit".
QUESTION
With terra
I would like to place the legend horizontally below the map.
From help
it seems that this can be done by either passing a character to legend
(e.g. legend = "bottomleft"
) or by passing a list to plg
with arguments from the base-R legend function. However, for me none of these work. Please, see code sample below.
Thanks!
...ANSWER
Answered 2022-Mar-17 at 13:46You could use the package raster
and spplot
which gives you the option to plot the legend below the plot. You can use this code:
QUESTION
I have the following problem. I want to build a model for landcover classification. My data are multitemporal Remote Sensing data with several bands. For training I created stratified randomly distributed points to extract spectral data at their positions. With these data a Random Forrest (Rpart) was trained using mlr3 package. For accuracy measurement a repeated spatial cross validation using mlr3spatiotempcv was performed. The resulting model of the training step is, after extraction, stored in an R Object of type rpart. In the terms field of this object are the variable names stored. These are all my used bands but also the spatial x and y coordinates. This brings problems when predicting new data. I used terra package and got an error the x and y layer are missing in my input data. Which kind of makes sense because they are stored in the terms field of the model. But from my understanding, the coordinates should not be a variable of the model. The coordinates are just used for spatial resampling and not for predicting. I "solved" this problem by removing x and y coordinates during the training process and perform just an ordinary non-spatial cross validation. After that I performed the prediction and it works perfectly.
So, my Question is, how can I train a model, using mlr3 package, with data containing coordinates, to perform spatial cross validation?, and then use this model to predict a new Raster.
...ANSWER
Answered 2022-Mar-02 at 11:11You have found a bug. When the task is created from a data.frame
instead of an sf
object, coords_as_features
is set to TRUE
. The default should be FALSE
. You can install a fixed version of the package with remotes::install_github("mlr-org/mlr3spatiotempcv")
. This fix should be included in the next CRAN version soon. Thanks for reporting.
This brings problems when predicting new data.
Why do you use the models from resampling to predict new data? Usually, you estimate the performance of the final model with (spatial) cross validation but the final model to predict new data is fitted on the complete data set.
QUESTION
I am trying to select several rasters from a SpatRasterDataset using the terra package in R. However when I try to select x rasters at once, the names show only the first x raster names, regardless of which rasters I try to select. Selecting a single raster seems to work fine, although the name given to it is not present.
So how do I properly subset a SpatRasterDataset keeping the correct names associated with rasters?
Reproducible example:
...ANSWER
Answered 2022-Feb-27 at 15:08The names of a SpatRasterDataset do not correspond to the (layer) names of a SpatRaster.
With your example
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install terra
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