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 , 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 , 10 years ago
comment:3 by , 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 , 10 years ago
Component: | raster → documentation |
---|---|
Owner: | changed from | to
Priority: | critical → high |
Looking up the manual for "alignemnt" issues I found:
- ST_MapAlgebraExpr2 will make the _output_ have the alignment of the first argument (meaning the input do not need to be aligned, right ?): http://postgis.net/docs/RT_ST_MapAlgebraExpr2.html
- ST_SameAlignment short description does not mention offset as being part of the definition (in the detailed description there is more): http://postgis.net/docs/RT_ST_SameAlignment.html
.. more things to look at
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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)