Skip to main content
100%

carbon poly tool sum SQL

✓ Published0🌍 Public
Aandrewxhill
Last edited Nov 9, 2012
Created on Nov 9, 2012

This example computes the total carbon stored in a user-defined polygon by summing raster pixel values from a carbon dataset. It shows a SQL query using PostGIS raster functions, where `ST_Intersects` filters relevant pixels, `ST_PixelAsPolygon` converts pixels to polygons, and `ST_Transform` projects them to calculate area. The query also uses `ST_Value` to extract pixel carbon values, dividing by 100 and scaling by area to produce a total, alongside the polygon’s geographic area. The code relies on the PostGIS spatial extension and a `generate_series` cross join to iterate over a 10-by-10 grid of pixels.

AI-generated description

Similar vizzes