Opened 10 years ago

Closed 10 years ago

#2920 closed defect (fixed)

[raster] ST_Union(raster): ERROR: rt_raster_from_two_rasters: The two rasters provided do not have the same alignment

Reported by: strk Owned by: robe
Priority: high Milestone: PostGIS 2.1.4
Component: documentation Version: 2.1.x
Keywords: Cc:

Description

The PostGIS manual does not say anything about ST_Union argument need to be aligned: http://postgis.net/docs/RT_ST_Union.html

But ST_Union() errors out complaining about the provided rasters not being aligned here:

WITH inp AS (                                                                   
 SELECT                                                                         
'0100000100000000000000104000000000000010C00000000000003E4000000000000044C00000000000000000000000000000000000000000030003004400000000000000000000'
::raster r
UNION ALL SELECT
'0100000100000000000000104000000000000010C00000000000003E4000000000000049C00000000000000000000000000000000000000000030003004400000000000000000000'
::raster
)                                                                               
SELECT ST_Union(r) FROM inp;

Is it a bug in the implementation or in the manual ? I'd guess the former.

The rasters metadata show they have the same scale, size and upper-left X ordinate, while Y ordinate is 10 units apart (not representable with a pixel height of 4):

strk=# WITH inp AS (
 SELECT
'0100000100000000000000104000000000000010C00000000000003E4000000000000044C00000000000000000000000000000000000000000030003004400000000000000000000'
::raster r
UNION ALL SELECT
'0100000100000000000000104000000000000010C00000000000003E4000000000000049C00000000000000000000000000000000000000000030003004400000000000000000000'
::raster
)
SELECT (ST_Metadata(r)).* FROM inp;
 upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands 
------------+------------+-------+--------+--------+--------+-------+-------+------+----------
         30 |        -40 |     3 |      3 |      4 |     -4 |     0 |     0 |    0 |        1
         30 |        -50 |     3 |      3 |      4 |     -4 |     0 |     0 |    0 |        1
(2 rows)

Failure is both in trunk and 2.1.4dev r12924.

Tested with "GDAL 2.0.0dev, released 2014/04/16"

Change History (5)

comment:1 by strk, 10 years ago

Summary: ST_Union(raster): ERROR: rt_raster_from_two_rasters: The two rasters provided do not have the same alignment[raster] ST_Union(raster): ERROR: rt_raster_from_two_rasters: The two rasters provided do not have the same alignment

comment:2 by strk, 10 years ago

I've just also tested with GDAL 1.11.0, released 2014/04/16 and the results are the same (again both with 2.1 and trunk)

comment:3 by Bborie Park, 10 years ago

The bug is in the manual. ST_Union is a wrapper around ST_MapAlgebra. Alignment is required. It's no different than ST_Union(geom, geom) requiring the geometries to have the same SRID. Alignment is ensuring that the two rasters are in the same coordinate system.

comment:4 by strk, 10 years ago

Component: rasterdocumentation
Owner: changed from Bborie Park to robe
Priority: criticalhigh

Looking up the manual for "alignemnt" issues I found:

.. more things to look at

comment:5 by robe, 10 years ago

Resolution: fixed
Status: newclosed

updated docs for ST_Union and ST_SameAlignment at r12954 for 2.1 and r12952 - r12953 for trunk (2.2). I'm not going to bother with ST_MapAlgebraExpr2 since that's deprecated.

Note: See TracTickets for help on using tickets.