terra | R package for spatial data handling https | Data Visualization library

 by   rspatial C++ Version: CRAN License: GPL-3.0

kandi X-RAY | terra Summary

kandi X-RAY | terra Summary

terra is a C++ library typically used in Analytics, Data Visualization applications. terra has no bugs, it has no vulnerabilities, it has a Strong Copyleft License and it has low support. You can download it from GitHub.

logo by Zane Dax. terra is an R package for spatial data analysis. There are tutorials at rspatial.org/terra. stackoverflow is the best place to ask questions if you get stuck. Make sure to include a simple reproducible example. But if you think you have found a bug, please file an issue. terra replaces the raster package. The interfaces of terra and raster are similar, but terra is simpler, faster and can do more.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              terra has a low active ecosystem.
              It has 446 star(s) with 72 fork(s). There are 27 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 32 open issues and 1047 have been closed. On average issues are closed in 6 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of terra is CRAN

            kandi-Quality Quality

              terra has 0 bugs and 0 code smells.

            kandi-Security Security

              terra has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              terra code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              terra is licensed under the GPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              terra releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of terra
            Get all kandi verified functions for this library.

            terra Key Features

            No Key Features are available at this moment for terra.

            terra Examples and Code Snippets

            No Code Snippets are available at this moment for terra.

            Community Discussions

            QUESTION

            Trying to install package brms in R
            Asked 2022-Apr-16 at 19:16

            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:24

            QUESTION

            Why is terra's focal function changing raster location?
            Asked 2022-Apr-09 at 04:44

            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:44

            That 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?

            Source https://stackoverflow.com/questions/71803441

            QUESTION

            How to count NAs using terra's global function?
            Asked 2022-Apr-04 at 18:18

            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:43

            When I run your code, it actually works:

            Source https://stackoverflow.com/questions/71741391

            QUESTION

            Reorder plot legend categories in a terra SpatVector map
            Asked 2022-Apr-04 at 17:06

            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:35

            I 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:

            Source https://stackoverflow.com/questions/71706409

            QUESTION

            How to iterate crop raster in R using a moving window?
            Asked 2022-Apr-03 at 16:57

            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:57

            Using terra data, by your approach, which I like:

            Source https://stackoverflow.com/questions/71709795

            QUESTION

            How to select a section of a raster in R using a search window?
            Asked 2022-Mar-31 at 20:00

            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:00

            You can use standard indexing

            Source https://stackoverflow.com/questions/71697512

            QUESTION

            How can I perform neighborhood analysis in terra or raster and keep the same NA cells of the input?
            Asked 2022-Mar-23 at 13:12

            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:12

            With terra the focal method has an argument na.policy that can be set to one of "all", "only" or "omit".

            Source https://stackoverflow.com/questions/70429190

            QUESTION

            horizontal legend in terra R package
            Asked 2022-Mar-17 at 16:28

            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:46

            You could use the package raster and spplot which gives you the option to plot the legend below the plot. You can use this code:

            Source https://stackoverflow.com/questions/71511089

            QUESTION

            How to perform spatial crossvalidation using mlr3 and then perform raster predict
            Asked 2022-Mar-02 at 11:11

            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:11

            You 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.

            Source https://stackoverflow.com/questions/71308422

            QUESTION

            How to subset a SpatRasterDataset from the terra package?
            Asked 2022-Feb-27 at 15:08

            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:08

            The names of a SpatRasterDataset do not correspond to the (layer) names of a SpatRaster.

            With your example

            Source https://stackoverflow.com/questions/71271031

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install terra

            terra is available from CRAN, so you can use install.packages("terra") to get the current released version.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/rspatial/terra.git

          • CLI

            gh repo clone rspatial/terra

          • sshUrl

            git@github.com:rspatial/terra.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link