Giter VIP home page Giter VIP logo

Comments (5)

edzer avatar edzer commented on July 18, 2024

Have you tried aggregate?, as in

aggregate(tile_proxy, tt, mean, na.rm = TRUE)

from stars.

kadyb avatar kadyb commented on July 18, 2024

Maybe it will be even better to use the exact = TRUE argument to engage exactextractr (it is very fast for summarizing values)?

Edit: I checked the source of the aggregate() and basically exact_extract() is not used, so you need to test {terra} as backend.

from stars.

richardbeare avatar richardbeare commented on July 18, 2024

No luck with aggregate - similar behaviour to st_apply - slowly consumes RAM/virtual memory until crashing.

I'll look into terra and exact_extract

from stars.

richardbeare avatar richardbeare commented on July 18, 2024

exactextractr::exact_extract works well, crunching through the test set in under a minute while using minimal RAM

library(exactextractr)
a <- raster::raster(tifname)
g <- exact_extract(a, tt, "mean")

# should work with either terra or raster loaders
a <- terra::rast(tifname)
g <- exact_extract(a, tt, "mean")

terra::extract had the same ram problem as the stars approach:

a <- terra::rast(tifname)
g <- terra::extract(a, tt, mean, na.rm = TRUE)

raster::extract didn't appear to have a RAM problem, but took a really long time - I gave up after over an hour.

a <- raster::raster(tifname)
g <- raster::extract(a, tt, mean, na.rm = TRUE)

from stars.

kadyb avatar kadyb commented on July 18, 2024

If you are interested in the highest efficiency, I think the best option will be to use exact_extract() with SpatRaster, it should be faster than for RasterLayer. See these benchmarks:

from stars.

Related Issues (20)

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.