TransWikia.com

Wrong result when clip a raster with PostGIS

Geographic Information Systems Asked by Nguyen Duc Tien on May 5, 2021

I’m newbie of GIS, I have my first project with GIS without experience before.
I want to clip a zone of raster for the calculation of NDVI index. It is ok when I did it with GDAL and TIFF file. But I want to save raster and geom to PostGIS because I found that is quicker.

Geom

In the image 1 you can see the zone which I want to clip.
But when I using the Query:

SELECT b4.rast 
FROM area as ar, band4 as b4 
WHERE 
ST_Intersects(b4.rast, ar.area) and ar.area_name = 'nefta';

Then I use ST_AsGdalRaster(rast, 'GTiff') to convert to GDAL TIFF file for NDVI calculation.

My result which I have is an other zone you can see the black rectangle:
Wrong position

What is the problem with my procedure? The Geometry and Raster file I converted to WGS84: 4326 before pushing them to PostGIS.

One Answer

I solved my question by using ST_AsGdalRaster(ST_Union(rast), 'GTiff') instead of ST_AsGdalRaster(rast, 'GTiff'). Do you have any ideas for this Postgis function?

Correct answer by Nguyen Duc Tien on May 5, 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