I'm using PostGIS to calculate statistics on vector and raster data. The raster data is stored tables with one 128x128 pixel tile per row. I'm seeing an error when comparing clipping certain polygons to certain raster tiles. In a dataset of roughly 10 million polygons, the error occurs a few dozen times. Why is this error occurring? What's the fix?
I've created a minimal example that reproduces the error:
with a (rast) as (values('0100000100756F1820CBD6E23E1D701820CBD6E2BEA14D8090536055C09D958109C1BA3E4000000000000000000000000000000000AD10000001002200020001010101010101010101010101010101010101010101010101010101010101010101'::raster)), b (geom) as (select st_setsrid(st_geomfromtext('POLYGON((-85.5046457277349 30.7311595527075,-85.5046492027152 30.7294850816075,-85.5051002810699 30.7294907086655,-85.5050985678614 30.7303174886974,-85.5050968186801 30.7311624161489,-85.5046457277349 30.7311595527075))'), 4269)) select st_clip(rast, geom, true) from a, b;
This yields the following error:
ERROR: rt_raster_iterator: The set of rasters provided (custom extent included, if appropriate) do not have the same alignment CONTEXT: PL/pgSQL function st_clip(raster,integer,geometry,double precision,boolean) line 8 at RETURN
The example raster data was generated with
ST_AddBand, so I don't think the problem is related to corrupted data. Running other operations on this example raster (and the original data) works fine. For example, here's the output from
Raster of 1x34 pixels has 1 band and extent of BOX(-85.5051003697358 30.7292025857055,-85.505091386583 30.7295080129021) band 1 of pixtype 4BUI is in-db with no NODATA value
At least some of the time, the error goes away if a raster tile is unioned with neighboring tiles.
This occurs on both OS X and Windows, and in CARTO. PostGIS version info:
POSTGIS="2.4.3 r16312" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.3, released 2017/11/20" LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" RASTER