[PostGIS] #5496: ST_Clip(raster, geom) include new method to pixel selection: touch

PostGIS trac at osgeo.org
Fri Dec 1 18:17:40 PST 2023


#5496: ST_Clip(raster, geom) include new method to pixel selection: touch
--------------------------+---------------------------
  Reporter:  latot        |      Owner:  robe
      Type:  enhancement  |     Status:  new
  Priority:  medium       |  Milestone:  PostGIS 3.5.0
 Component:  raster       |    Version:  3.4.x
Resolution:               |   Keywords:
--------------------------+---------------------------
Comment (by robe):

 Looking at this closer looks like ST_Clip eventually uses

 GDALRasterizeGeometries function to burn the geometry into an empty
 raster.
 The options is not set



 Looking at the GDALRasterizeGeometries function in GDAL repo, it has a
 clause


 {{{
  * @param papszOptions special options controlling rasterization
  * "ALL_TOUCHED": May be set to TRUE to set all pixels touched
  * by the line or polygons, not just those whose center is within the
 polygon
  * or that are selected by brezenhams line algorithm.  Defaults to FALSE
 }}}

 So I think right now the options postgis raster is passing is NULL so I'm
 guessing it's defaulting to not touched and that's why we have the
 annoying behavior of rasterized geometry not taking up the whole pixel
 being left out.

 My plan is to add a new boolean argument to ST_Clip -- touched, and the
 default, I guess for backward compatibility we should set to "False", but
 I'd really love the default to be set to true.

 But anyway I think this needs to go into 3.5.0 (not prior), to allow
 exposing this new "touched" arg.

 The other question is https://postgis.net/docs/manual-
 dev/en/RT_ST_Clip.html, do we add to all protos.
 I had no idea we had so many, as I've only ever used it as
 ST_Clip(rast,geom) which corresponds to this signature


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

 so that I'd definitely replace with below (though that would be a breaking
 change), so maybe touched=FALSE would be safer.
 But I suspect most people prefer true, or assume touched=true already

 {{{
 raster ST_Clip(raster rast, geometry geom, double precision[]
 nodataval=NULL, boolean crop=TRUE, boolean touched=TRUE);
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5496#comment:3>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list