VtotheG opened a new issue, #1715:
URL: https://github.com/apache/sedona/issues/1715

   I want to use ZonalStats 
(https://sedona.apache.org/latest/api/sql/Raster-operators/#rs_zonalstats) for 
my use case of integrating polygons of buildings with information from a tif 
file.
   
   In the past I used the rasterstats library to get the info in python, but i 
have a lot of buildings and wanted to use the power of Sedona. When I look at 
rasterstats it has the property all_touched which determines if the pixel 
should be included in the rasterstats calculation see; 
https://pythonhosted.org/rasterstats/manual.html#zonal-statistics. 
   
   ## Actual behavior
   The current RS_ZonalStats function only returns the value of pixels that 
fall within my polygon. This causes a lot of issues when the houses / buildings 
are quite small (it will return a NaN because non of the pixels are fully 
encapsulated by the polygon. 
   
   ## Steps to reproduce the problem
   ```
   Example of the usage
   results = sedona.sql('''
   select 
   id
   , geometry
   , RS_ZonalStats(r.raster, a.geometry, 1, 'max', false, true) as 
max_elevation 
   from buildings a, tifmap_with_elevation r
   where 
   RS_intersects(geometry, r.raster) 
   '''
   ```
   
   It would be great to have an additional parameter which would indicate if 
RS_ZonalStats should only summarize the statistics of pixels within the 
geometry or all pixel that are being touched by the geometry 
   
   I thought that adding a buffer with the size of my pixels would solve my 
issue, but i think it is then still possible to grab pixels which should not be 
part of the calculation. 
   
   ## Settings
   
   Sedona version = 1.7.0
   
   Apache Spark version = 3.5.0
   
   Apache Flink version = ?
   
   API type = Python / SQL 
   
   Scala version = 2.12
   
   JRE version = ?
   
   Python version = 3.11
   
   Environment = Databricks
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@sedona.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to