Hello List,<br><br>I'm using ST_SummaryStats() to calculate the total value of the pixels selected using ST_Intersect. The number I want is the weighted sum of this area. e.g. SUM (number of times value occurs * value)<br>
I'm doing this using the following query where I intersect a raster with zip code boundaries. The pixel values contain the number of people, so I want to sum up all of the selected rasters.<br><br>SELECT <br> (stats).count,<br>
(stats).sum <br>FROM (<br> SELECT <br> ST_SummaryStats(r.rast) as stats<br> from <br> new_york as r, <br> ny_zip as e<br> where<br> ST_Intersects(r.rast, e.geom)<br> and<br>
e.zipcode = '10456'<br> ) As foo<br><br>However, I don't understand the values from ST_SummaryStats. I've summarized the results below and the PostGIS results are quite different from each other, and from my ArcGIS result. I didn't think that the chunk size influenced the accuracy of the result, and I'm not sure why the 'sum' between ArcGIS and PostGIS is so different.<br>
<br>-- Count Sum<br>-- ArcGIS: 499 149881 (100m cell-size)<br>-- PostGIS: 1200 297167 (10 x 10 chunks)<br>-- PostGIS: 4926 1074925 (50 x 50 chunks)<br>-- PostGIS: 7872 1361671 (100 x 100 chunks)<br>
-- PostGIS: 348722 10572532 (1000 x 1000 chunks)<br><br><br>The original raster is 100m in cell-size and I am loading it into postgresql using the following command:<br><br>raster2pgsql -I -C -F -s 900913 -t 50x50 \new_york_pop.tif new_york_50 | psql.exe -U postgres -d raster_analysis -h localhost -p 5434 <br>
<br>I'm using PostGIS 2.0.0 on Win 7. <br><div style="text-align:left"><br>Thanks,<br>David<br></div>