I have a huge number of raster files and a polygon that is within the extent of the raster files. I want get the pixel number(count) for each raster files within the polygon. Additionally I want to create a table with the name of raster file and number of pixels(listed) for each raster file. I have tried with stacking but with that I can not keep track of the name. Is there any other way of performing this task in R?
Calculating number of pixel(count) raster files in R
13.4k Views Asked by equastrian91 At
1
There are 1 best solutions below
Related Questions in R
- in R, recovering strings that have been converted to factors with factor()
- How to reinstall pandoc after removing .cabal?
- How do I code a Mixed effects model for abalone growth in Aquaculture nutrition with nested individuals
- How to save t.test result in R to a txt file?
- how to call function from library in formula with R type provider
- geom_bar define border color with different fill colors
- Different outcome using model.matrix for a function in R
- Creating a combination data.table in R
- Force specific interactions in Package 'earth' in R
- Output from recursive function R
- Extract series of observations from dataframe for complete sets of data
- Retrieve path of supplementary data file of developed package
- r package development - own function not visible for opencpu
- Label a dataset according to bins of a histogram
- multiply each columns of a matrix by a vector
Related Questions in RASTER
- gdal_merge on a three band .tif - remove the 'no data' value
- predict with glmer where new data is a Raster Stack of fixed efefcts
- how to create an extent which is not parallel to X and Y axis R raster
- How to rotate an image R raster
- How does R's tikzDevice deal with raster images?
- calculate average correlation for neighboring pixels through time
- How to find maximum value in rasterbrick?
- saving rotate images in R - avoiding background and maintaining size
- Plot basic graph with no borders, titles, etc
- reproject raster (WGS84 to BNG) with large resolution
- How can I avoid white space in my levelplot in R
- R raster functions, splitting multiple rasters from one
- Python Script for percent change in NPP ( Net Primary Production)
- How to plot a spatially explicit hdf5 file? - r - raster
- How to adjust two maps with different extent in R
Related Questions in R-RASTER
- Interactive plotting with R raster: values on mouseover
- Mosaic rasterstacks using minimum of certain layer
- Error when extracting values from a rasterBrick or rasterStack
- Issue using saveRDS() with raster objects
- In R create maximum raster from mulitple raster files
- Fill raster holes in R or Grass GIS
- raster::focal returns incorrect values
- Extract values from PCA on raster
- How to run the Kennard-Stone algorithm with a multilayer raster?
- Interpolating large raster series in R
- how to crop raster based on SpatialPolygons in R
- Remove white space from levelplot plotting Google map
- Create Georeference in R
- Plotting Raster object with points at exact position
- Very slow raster::sampleRandom, what can I do as a workaround?
Related Questions in SPATIAL-DATA
- Send spatial data using Python and Mysql Connector
- Databricks Mosaic's grid_polyfill() is taking longer to explode the index when run using PySpark via AWS EMR
- How to Calculate Euclidean distance from sf data frame points in R
- How to label only one point in tmap in r?
- Possible ways of selecting x/y points that are on or close to a path in R
- Selecting values from a 4d tensor with a 3d tensor
- How to fill data gaps with random coordinates from a polygon?
- How to create a polygon/combine polygons that cross the 180 meridian dateline
- Can I create a SpatialPoints object from a variable with NAs?//How to make lat and long variables with NAs compatible with SpatialPoints?
- Euclidean Distance for Arrays of 3D points in Python
- Calculating number of pixel(count) raster files in R
- Algorithm for identifying non-ambiguous clusters?
- calculate mean for each cell in grid in R
- Deserialization of DbGeography Entity Framework
- Can I use Entity Framework 6 (not core) in .net core?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Always include example data, please
I am not quite sure what you are after. The number of cells (pixels) would be the same for all rasters if you can stack them (which you say you can). I am assuming that you want the sum of the cells that are not
NA. If you actually have rasters with a different origin/resolution, you can repeat these steps, but there no need to stack them into aRasterStack, but you would need to adjust the approach to also count theNAcells.Simple approach for smaller objects:
If that runs out of memory, you can do:
You can also try:
If you want to count all the cells (whether
NAor not), you can do something like