1

The code I am using for clip feature is :

raster ST_Clip(raster rast, geometry geom, double precision[] nodataval=NULL, boolean crop=true);

I tried clip a shape depends on the polygon from the Raster Data. But the PostGIS would clip the raster depend on the Bounding Box of the polygon, and put the Non-data value as 0. Even I tried to modify that with code:

SELECT ST_Clip(rast,geometry, ARRAY[-9999],true) FROM dtm, polygons WHERE polygons.polygonid = 1;

After I dump the data as a ASC-II file from the PostGIS, using gdal_translate with another option -a_nodata -9999, I find out it only changes the Header of the ASC-II file not the exact bounding box value. enter image description here

Is there anyway to change the value from 0 to -9999, or someway to clip the raster depending on the polygon rather than the Bounding Box of the polygon.

THanks.

2

It looks like your band pixel type is 8BUI, which as a valid range of 0 - 255. -9999 when clamped for 8BUI would go to 0.

  • Thanks, but do you know how to modify that? – Yu Guo Jun 4 '13 at 8:28
  • Sorry, I used ST_BandPixelType to check my band type and that is 32BSI – Yu Guo Jun 4 '13 at 9:51
  • What version of PostGIS are your running? {{{ SELECT postgis_full_version(); }}} – dustymugs Jun 4 '13 at 21:48
  • "POSTGIS="2.0.3 r11132" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.2, released 2012/10/08" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER" – Yu Guo Jun 5 '13 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.