Opened 13 years ago
Closed 13 years ago
#1574 closed defect (fixed)
[raster] ST_AsRaster(geometry, rast) do not align raster properly
Reported by: | pracine | Owned by: | Bborie Park |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.0 |
Component: | raster | Version: | master |
Keywords: | Cc: |
Description (last modified by )
I made the queries to be easily displayable in OpenJump...
I have a geometry:
SELECT ST_Asbinary(ST_Buffer(ST_SetSRID(ST_MakePoint(2, 1), 0), 1.3));
and a raster:
SELECT ST_Asbinary((gv).geom) geom, (gv).val FROM (SELECT ST_PixelAsPolygons(ST_MakeEmptyRaster(4, 4, 0, 0, 1, 1, 0, 0, 0)) gv) foo
and I want to rasterize that geometry aligned on this raster:
SELECT ST_Asbinary((gv).geom) geom, (gv).val FROM (SELECT ST_PixelAsPolygons( ST_AsRaster( ST_Buffer(ST_SetSRID(ST_MakePoint(2, 1), 0), 1.3), ST_MakeEmptyRaster(4, 4, 0, 0, 1, 1, 0, 0, 0) ) ) gv ) foo
The produced raster is not aligned properly.
Change History (9)
comment:1 by , 13 years ago
Description: | modified (diff) |
---|
comment:2 by , 13 years ago
comment:4 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
#1395 isn't related. I've rewritten your test case and see what the problem is. I'm going to have to investigate but am expecting a floating point issue.
comment:6 by , 13 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Now for the same geometry, if the raster I want to align to is:
SELECT ST_Asbinary((gv).geom) geom, (gv).val FROM (SELECT ST_PixelAsPolygons(ST_MakeEmptyRaster(4, 4, 0, 0, 1, -1, 0.2, 0.2, 0)) gv) foo
then:
SELECT ST_Asbinary((gv).geom) geom, (gv).val FROM (SELECT ST_PixelAsPolygons( ST_AsRaster( ST_Buffer(ST_SetSRID(ST_MakePoint(2, 1), 0), 1.3), ST_MakeEmptyRaster(4, 4, 0, 0, 1, -1, 0.2, 0.2, 0) ) ) gv ) foo
is also wrongly aligned... sorry...
comment:7 by , 13 years ago
Now that is probably a skew issue related to #1395. Since GDAL suggests a deskewed raster for the geometry, we need to reintroduce the skew (the same issue is true for GDAL Warp).
I'll see when I can get to this as this will take longer to resolve.
comment:9 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
The skewed example works. Refactored code
WITH foo AS ( SELECT ST_MakeEmptyRaster(4, 4, 0, 0, 1, -1, 0.2, 0.2, 0) AS rast ) SELECT ST_SameAlignment( ST_AsRaster( ST_Buffer(ST_SetSRID(ST_MakePoint(2, 1), 0), 1.3), rast ), rast ) FROM foo
If I just negate the scaley of the raster then I get a raster correctly aligned :