TransWikia.com

Zonal stats for raster in PostGIS

Geographic Information Systems Asked on November 6, 2021

I am trying to do zonal stat in PostGIS with the following command.

SELECT
    (ST_SummaryStats(ST_Clip(agri_final_proj.rast, district.geom, TRUE))).*,
    district.district_1 AS district_1,
    district.geom AS geom
INTO
    regions_with_elevation
FROM
    agri_final_proj, district;

Here agri_final_proj is my raster and district is my vector file.
But when running the query I am facing this issue:

"ERROR:  lwgeom_intersection: GEOS Error: TopologyException: Input geom 1 is invalid: Ring Self-intersection at or near point 458031.90649999958 4166648.6541000009 at 458031.90649999958 4166648.6541000009"

One Answer

It looks like your input geometry is invalid at a certain point (Check coordinates in error message). Also you can check if your vector data-geometry is valid with ST_IsValid() https://postgis.net/docs/ST_IsValid.html, if not you can try to solve this problem with ST_MakeValid()https://postgis.net/docs/ST_MakeValid.html . For more information about valid geometry construction in PostGIS check following link: PostGIS Validity

Answered by DrSnuggles on November 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP