Comments (6)
Yes, this would be really useful for me too; I want to run table() on the extracted points to get a summary of the values within given polygons.
In the meantime, I've added a extract_to_list() function which allows me to pass fun=table as an argument and get the tables back as elements of a list. (currently extract needs fun to return a single numeric, I think, as the results are stored in a matrix). However, this is probably not a proper solution as it only works for nbands = 1.
from velox.
Yes, I think indeed for multi-outputs functions, the best is to have extract() return a data-frame, and let user do the computation. Otherwise, would be quite complicated structure with the multi output/multi-band.
from velox.
Upbump for visibility. Came here and posted the identical issue. This was the only reason I wanted to use this function. Either update it for multiple outputs, or allow for the raw values to be extracted. As it stands it is not particularly useful.
from velox.
Hi everyone. Thanks for your comments.
The extract function now returns 'raw' raster values if argument fun
is set to NULL
. The return value is a list with one list element per polygon, and each list element consisting of a matrix with as many columns as there are raster bands.
## Make VeloxRaster with two bands
set.seed(0)
mat1 <- matrix(rnorm(100), 10, 10)
mat2 <- matrix(rnorm(100), 10, 10)
brk <- brick(raster(mat1), raster(mat2))
vx <- velox(list(mat1, mat2), extent=c(0,1,0,1), res=c(0.1,0.1),
crs="+proj=longlat +datum=WGS84 +no_defs")
## Make SpatialPolygons
coord <- matrix(c(0,0,1,1), 2, 2, byrow = TRUE)
spoint <- SpatialPoints(coords=coord)
spols <- gBuffer(spgeom=spoint, width=0.2, byid = TRUE)
## Extract raw values as list of matrices
vx.elist <- vx$extract(sp=spols, fun = NULL)
## Print
print(vx.elist)
[[1]]
[,1] [,2]
[1,] -0.005767173 -0.5006966
[2,] 2.404653389 1.6782972
[3,] -1.237538422 0.1380527
[[2]]
[,1] [,2]
[1,] -0.7970895 -0.07041738
[2,] 1.2993123 -0.01674826
[3,] -0.8732621 0.16178863
from velox.
nice, thanks a lot for the great work!
from velox.
Great! Can't wait to put this into action. Thanks!
from velox.
Related Issues (20)
- Velox Got A Lot Lot Lot Slower? HOT 1
- Error: long vectors not supported yet: memory.c:3451
- Failed to install on Mac HOT 5
- vx$extract_points failure HOT 1
- copy VeloxRaster object
- Access cell number of extracted value? HOT 3
- Velox extract error: "Error in boostFactory$makePointGrid ... std::bad_alloc" HOT 6
- velox extract area weighted mean
- Include st. dev, min and max focal functions when applying a moving window kernel filter
- extract for lines files
- pointextract.cpp - unused input?
- GeoTIFF raster values "reasonable" with raster extract but all NA velox extract HOT 2
- Feature request: raster arithmetic!
- along = TRUE argument for extract function?
- CRAN archive notification HOT 24
- Failed trying to install in Mac HOT 3
- fatal error: 'math.h' file not found macos Catalina
- compatibility with R 4.0 HOT 3
- Unable to install package HOT 1
- Velox is still the fastest, but compatibility issues make it difficult to share HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from velox.