{"version":"1.0","type":"rich","title":"carbon poly tool sum SQL","description":"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.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-4046900?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}