[gdal-dev] gdal raster clip - need some help

Scott public at postholer.com
Wed Sep 17 11:06:11 PDT 2025


I'm trying to clip a raster with a vector data source:

gdal raster clip \
    --input=raster.tif \
    --like="PG:dbname=mydb" --like-sql="select geom from vector_table" \
    --output=clipped.tif --overwrite --progress

It gives me the error:
ERROR 1: clip: Cannot get extent from clip dataset

If I use a .gpkg in --like, it works fine.

gdalwarp works fine with the same raster and same PG vector table:

gdalwarp -cutline PG:dbname=mydb -csql "select geom from vector_table" 
raster.tif clipped.tif

If I modify the connection string to:
--like="PG:mydb table=vector_table"

It seems to think it's a raster table:

Creating tile for bbox -12980000,3850000,-12970000,3860000
Warning 1: Cannot find information about public.vector_table table in 
raster_columns view. The raster table load would take a lot of time. 
Please, execute AddRasterConstraints PostGIS function to register this 
table as raster table in raster_columns view. This will save a lot of time.
ERROR 1: Error browsing database for PostGIS Raster properties : ERROR: 
column "rast" does not exist
LINE 1: ...m) as ymax, scale_x, scale_y from (select st_srid("rast") sr...



Am I missing a key parameter here?

Debian 12, GDAL 3.11.3

Thanks!
Scott


More information about the gdal-dev mailing list