Questions tagged [rasterstats]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
35 views

How to treat NAs using a custom function in the lapp function of {terra} in R

I am using the {terra} package of R-Stats. I have some quite complicated conditional maths to run on a set of rasters; a different formula depending on the value in the cell. I have tried to make a ...
user avatar
0 votes
1 answer
17 views

Find the distribution of nlcd categories within polygons

I am new to QGIS. I am trying to find out the distribution of NLCD bins within the buffered areas. The buffered areas is a vector layer, while the other is the NLCD raster (downloaded from MLRC). ...
user avatar
1 vote
0 answers
34 views

How to solve rasterstats nodata warning

I am using the zonal_stats function in the rasterstats package to calculate summary statistics from GeoTiffs containing vegetative index values. The summary statistics come out fine, however with each ...
user avatar
  • 61
0 votes
0 answers
35 views

Unexpected values for 'SUM' and 'COUNT' in Zonal Statistics

I am using the zonal_stats function in the rasterstats package to evaluate the pixels within each polygon in a shapefile. The raster used is a binary mask layer (object exg) in which pixels ...
user avatar
  • 61
0 votes
0 answers
45 views

Rasterstats not working on raster

I am trying to analyze a GeoTiff file with some geojson regions and rasterstats. But rasterstats doesn't seem to work. I suspect that is something related with the GeoTiff file, since I am using a new ...
user avatar
1 vote
1 answer
55 views

Find mean zonal stats using a geoseries or GeoJSON object - Python

I have a TIFF file with imperviousness levels and a Geoseries object containing the boundary coordinates of circles around 9 points. I want to find the mean value using zonal_stats but I don't know ...
user avatar
2 votes
1 answer
184 views

Unable to perform zonal stats in python because of Attribute Error

I am trying to carry out a simple zonal statistics task in python, and am having trouble getting this to work. I have a raster layer (in black/grayscale) and a roads polygons layer (in green, actually ...
user avatar
1 vote
1 answer
94 views

"ValueError: negative dimensions are not allowed" when using raster created from points in CSV

My problem is similar to "ValueError: negative dimensions are not allowed" when using raster created from NetCDF I am working on a raster that I generated from the interpolation of some ...
user avatar
0 votes
1 answer
280 views

Error when I try to import rasterstats

I am getting the following error when importing rasterstats package. I searched the internet and found no solution. Does anyone know what this is about? The only command I gave was import rasterstats ...
user avatar
0 votes
1 answer
22 views

QGIS Raster Statistics For Values Intersecting A Line Feature Vector Layer

Using QGIS 3.16.10 I want to obtain statistics for values in a raster layer that intersect with a line feature shapefile. I have tried using v.rast.stats but generate only 0 values.
user avatar
1 vote
0 answers
105 views

Pixel value extraction with rasterio retrieves different value than QGIS

I am extracting the pixel values from a raster using two different methods: one is extracting the values to points (centroids of polygon grids) folder = (...) S2_green = "band_green.tif" ...
user avatar
0 votes
1 answer
259 views

Looping through multiple rasters using Rasterio to calculate mean [closed]

I have a folder with a set of three rasters, before, after, and the difference image for each point of observation as shown below. The before and after dates vary for each observation point and ...
user avatar
  • 162
1 vote
0 answers
55 views

NetCDF with negative dimensions

I am trying to read a NetCDF file with rasterio (Python), however, the resulting affine is showing negative numbers. The .nc4 file comes from NOAA. How can I correct these negative dimensions? nc_fo = ...
user avatar
  • 2,812
0 votes
1 answer
54 views

How Rasterstats function works

I would like to know how the zonal_stats() function from the library rasterstats works, as I am calculating the mean values of a raster within a polygon. If a raster cell touches partially the polygon ...
user avatar
0 votes
0 answers
135 views

QGIS Zonal statistics and Python Rasterstats yield different results

I have one polygon shapefile and one raster file (both EPSG: 4326) and I am calculating the minimum, maximum and average raster value in all polygons using two methods: QGIS 3.16.10, Zonal statistics ...
user avatar
0 votes
0 answers
78 views

Rasterstats: point_query performance

I register point_query (Rasterstats) as spark udf. My TIFF file size is 720 MB (Japan - entire country data) and trying to query and get raster value using point co ordinates (400K) records. It is ...
user avatar
  • 1
0 votes
1 answer
32 views

How to select classes from a GeoTIFF world map and compute the area by regions defined in a shapefile

I have two files: fileLUse.tif defines land cover classes in GeoTiff format (from https://www.esa-landcover-cci.org/?q=node/164) fileRegions.shp defines administrative borders and it is a shapefile (...
user avatar
  • 207
2 votes
1 answer
417 views

Zonal statistics with rasterstats: "Invalid out_shape, must be 2D" (Python)

I'm trying to produce zonal statistics (summing pixel values representing population estimates by polygons), roughly following GeoDelta Labs (19:20 onwards. A ValueError "Invalid out_shape, must ...
user avatar
  • 53
1 vote
1 answer
332 views

Array memory error when reading rasters

I'm attempting to make a spatio-temporal statistics analysis on a few chunks of data using rasterstats, rasterio and pandas/geopandas on Python. # create dataframes for areas of interest and specify ...
user avatar
  • 81
3 votes
1 answer
698 views

rasterstats zonal statistics does not ignore nodata

I am trying to write a script to perform some zonal statistics with rasterestats, but I am really struggling with nodata values. I noticed a different behaviour 1) when running zonal_stats with numpy ...
user avatar
  • 323
2 votes
1 answer
130 views

Calculating zonal entropy index for raster using rasterstats

I have an elevation raster and a grid shapefile: What I want to do is calculate zonal statistics of the raster based on the grid features. The "statistic" I want is the entropy index (...
user avatar
  • 303
0 votes
0 answers
123 views

Width and value problems with rasterstats

I am trying to extract data from a raster with a gpkg file as a vector. The issue is that, the data can't be extracted because the internal Bounding Box is negative. There I am not sure, whether this ...
user avatar
0 votes
1 answer
99 views

Creating raster with cell value counts from another raster in buffer around each cell using PostGIS

Main objective My main objective is to compute 1) the proportion of a given type of land cover around every raster cell in a radius of 500 m at the scale of an island (e.g.: there is 40 % of ...
user avatar
0 votes
1 answer
114 views

Rasterstats in Python with .IMG files

I am currently trying to use zonal_stats of the rasterstats package to get zonal statistics of processed satellite images. The data is stored as .img-format and i have a shapefile containing 1 ...
user avatar
  • 117
1 vote
0 answers
458 views

Raster Zonal Statistics for large files

I have a shapefile that consists of 375m x 375m cells from the State of California, consisting of a total of 3,022,037 cells. The raster file covers the same geographical area, but consists of smaller ...
user avatar
1 vote
1 answer
221 views

How to extract max elevation values for each road links in a shapefile using Python libraries?

I want to extract values from a raster DEM file for each feature (polyline) in a shapefile. For each feature in a road shapefile, I want to extract the max and min elevation within a buffer (say 10 ft)...
user avatar
  • 375
4 votes
1 answer
890 views

Which affine format to use in Rasterstats zonal_stats?

I am working with the Rasterstats package to run zonal statistics on two raster datasets. The documentation calls for the following: import rasterio from rasterstats import zonal_stats with rasterio....
user avatar
  • 50.2k
2 votes
1 answer
1k views

Generating zonal stats for multiple rasters using rasterstats

I'm trying to generate the zonal stats for multiple rasters without using ArcPy. I've successfully obtained results using rasterstats for one image and one polygon. I would like to use the same ...
user avatar
1 vote
0 answers
58 views

Raster statistic

i'm try to use QGIS processing modeler but I've a problem. I need to use the Mean value and the standard deviation in raster calculator algorithm. I've calculated it in raster statistics, how can I do ...
user avatar
  • 121
2 votes
0 answers
909 views

Faster zonal stats for equal rasters with Python

I'm trying to extract data out of many raster images with different bounding boxes. Using the great rasterstats.zonal_stats it's a good approach, but it takes a considerable amount of time, especially ...
user avatar
  • 318
0 votes
0 answers
24 views

Automate exporting raster XMLs

I edit my raster catalogs to get a specific symbology and then I have to manually export the XML. I then load the XML into the mosaic dataset. I can't seem to find a way to automate the process of ...
user avatar
1 vote
1 answer
41 views

How do I build a new raster based on raster stats in QGIS?

I want to create a new raster that uses the mean value of the original raster as the base class of the image and then uses a +- 1 and 2 standard deviations as the other four classes of the image. Is ...
user avatar
3 votes
0 answers
445 views

Memory errors when doing Zonal Statistics on a multi polygon shapefile in Python [closed]

I want to calculate the mean NDVI with the EthNdvi.tif file for each zone (there are around 650 admin zones) in the the woreda shapefile. I'm having some issues with running the following lines of ...
user avatar
2 votes
0 answers
478 views

How to open memory data with ogr in rasterstats function?

I would like to reuse vector data created in memory in another function called rasterstats (source code, documentation): I have a function that creates vector data: def createPolygons: ...
user avatar
3 votes
0 answers
90 views

On-the-fly zonal statistics in QGIS

I would like to know if there is a plugin/method in QGIS to calculate zonal statistics (mean, median, range, max, min etc.) of a raster file, corresponding to a polygon that I draw/highlight in QGIS. ...
user avatar
  • 501
0 votes
1 answer
35 views

Using modeled surfaces together to make predictions?

My question is about stacking multiple rasters of predicted surfaces, that have some of the same predictors. For example, if I make a predicted surface using all the terrain attributes as ...
user avatar
6 votes
1 answer
1k views

Calculating average pixel value for each band across multiple raster layers?

I have a set of raster files that are essentially data sets of precipitation across a region. I have multiple raster files that are the outputs of different climate models. Each pixel in the raster ...
user avatar
1 vote
1 answer
863 views

Calculating Zonal Stacks on imagery with missing pixels

I'm trying to calculate zonal statistics on some imagery that has a bunch of pixels that come out as 0s. This is affecting the mean value for the area, or at least seems to be. I'm using the ...
user avatar
  • 163
3 votes
1 answer
181 views

No data pixels in raster file

I have a TIFF file and I'm trying to use rasterstats to get statistics of different geometries defined in a shapefile or a TopoJSON file. But I'm getting the count as 0 for all the geometries. My ...
user avatar
5 votes
3 answers
5k views

How to calculate raster statistics for each values in a band?

I have one raster scene that contains one band with multiple pixel values (0-14). Each values represent deforestation in certain year (0=no tree cover loss, 1=loss in 2001, 2=loss in 2002, and so on) ...
user avatar
1 vote
0 answers
221 views

Qgis not computing raster stats in layer properties - metadata?

I used to check the sum of all values of a raster (to get some volume information) from the layer properties - Metadata - properties tab, where I had directly the figure I was looking for. However, ...
user avatar
  • 1,821
8 votes
2 answers
659 views

Is there an open-source equivalent of ArcGIS "Zonal Statistics as Table" tool?

With ArcGIS zonal statistics as a table I can easily calculate the mean value from a raster contained within a polygon from a shapefile. I now have a Mac, and therefore I cannot access ArcGIS anymore. ...
user avatar
1 vote
0 answers
1k views

How to resolve "'NoneType' object is not callable" TypeError when calling rasterstats.zonal_stats from ArcPy script?

I'm attempting to workaround the apparent zonal statistics bug in ArcGIS 10.4 by using rasterstats.zonal_stats. stats = zonal_stats(shapefile_full_path, rast_full_path,0,1,None,None,{'mean','min','...
user avatar
  • 14.4k
2 votes
1 answer
1k views

Writing geoJson from rasterstats

How would I write a proper geoJson, readable by a GIS, from the results of the rasterstats package? stats = zonal_stats("somePolygons.shp", "someTif.tif", ...
user avatar
  • 3,017
3 votes
1 answer
528 views

Using zonal_stats with python in QGIS to calculate statistics for each image

I work with Python in QGIS, I want to calculate statistics for each image that I have with a specify shapefile and save result after, I tried to do like this: from rasterstats import zonal_stats ...
user avatar
  • 91
9 votes
2 answers
4k views

Using GeoPandas with rasterstats for zonal statistic gives error

I'm trying to use GeoPandas and zonal statistic from rasterstats together. I run this code import geopandas as gpd from rasterstats import zonal_stats geodf = gpd.read_file("SHP/shape.shp&...
user avatar
4 votes
1 answer
958 views

How to compute zonal statistics fast?

I have 12000 circles with a radius of 50 miles on a raster with 0.05 degree resolution. Global analysis. The raster is 32 bit float and I have to calculate zonal statistics for 20 different rasters. ...
user avatar
  • 2,965
7 votes
1 answer
1k views

Weighted zonal statistics in Python and/or R [closed]

I have raster files with precipitation data (4x4 km), monthly, for about 100 years. I have a shapefile for a watershed (which includes several polygons as sub-basins). I need the average precipitation ...
user avatar
  • 181