Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 8520

Zonal statistics summarize the values of one raster within the zones of another dataset (either raster or vector) and output the results as a raster (for a single statistic) or table (for multiple statistics).

6 votes
Accepted

How to use zonal statistics in R with shapefile

As recommended raster::extract will accomplish what you are after. However, from a computational speed and modernization standpoint, I would recommend using the terra package, which is a replacement f …
Jeffrey Evans's user avatar
7 votes
Accepted

What is (if there's any) difference between MAUP and Edge Effect

The Modifiable Aerial Unit Problem (MAUP) is a change of support issue associated with arbitrary aggregate units. Two classic examples are census tracks and wildlife game units. These have been found …
Jeffrey Evans's user avatar
2 votes

How can I determine which raster attribute covers the highest area of a polygon?

Here is an R solution that uses the mode of the observed distribution. Create some example data require(raster) r <- raster(ncol=36, nrow=18) r[] <- sample(1:3, ncell(r), replace=TRUE) …
Jeffrey Evans's user avatar
4 votes
Accepted

Fast Zonal Statistics to replace velox?

I have moved to using the exact_extract function in the exactextractr package. One nice thing is that it returns all cell intersections with the fractional proportion of each cells intersection. You c …
Jeffrey Evans's user avatar
4 votes

R zonal statistics for classes

You can write a simple function using prop.table and table to return proportions of multiple classes. The catch is that you have to know what all of the classes are before hand so you can fix the numb …
Jeffrey Evans's user avatar
5 votes
Accepted

Zonal stats percentile values using R?

Here are two ways to do this. The raster extract function is the common approach. However, the zonal.stats function uses velox under the hood, which speeds things up considerably. You will not see muc …
Jeffrey Evans's user avatar
4 votes

Counting raster values using another raster as mask in R?

You could approach this as a raster/vector integration problem, where your course resolution data are essentially sampling blocks represented as polygons. First, let's create your example data. li …
Jeffrey Evans's user avatar
9 votes
Accepted

Calculating statistics per area for categorical raster using R?

In R, you can extract the raster data for each polygon and then summarize it. First, lets create some data (FYI, you can read in a shapefile using raster::shapefile or rgdal::readOGR and a raster usin …
Jeffrey Evans's user avatar
3 votes

Getting count of non-NA raster cells within polygon using R

I am not sure if you want the ratio based on the "real value" of the polygon(s) areas or the areas of the cells intersecting them. Here is some example code that uses all cells intersecting the polygo …
Jeffrey Evans's user avatar