[postgis-devel] wktraster ST_ConvexHull

Paragon Corporation lr at pcorp.us
Mon Apr 5 18:14:47 PDT 2010


I'm a little bit confused about what ST_ConvexHull is supposed to return. I
thought it would return the convex hull 
of the polygon formed by the pixels that aren't the BandNoDataValue value.

It seems to always return the same result as ST_Envelope regardless of what
I set the ST_BandNoDataValue too.

See attached image that has all overlaid to see what I mean.  I expected
convex hull to return something that looks like my simulated convex
hull(that thick green parallelogram thingy).

Here is my example -- basically same one as
http://trac.osgeo.org/postgis/ticket/478

Forget about the mirror image issue. Haven't figured out why that happens
and doesn't seem to happen with other rasters I have tried that I haven't
mangled.  

Anyway I did this

-- Set my no band value to 255 for my 4 bands
UPDATE ch13.wpostgis SET rast = ST_SetBandNoDataValue(ST_SetBandNoDataValue(
			ST_SetBandNoDataValue(
				ST_SetBandNoDataValue(
					rast,1, 255)
				,2,255),
				3,255),4,255) ;


-- Now my simulation of what a ST_Polygon and ST_ConvexHull should return

-- ST_Polygon simulation - I'm doing 8 steps instead of 1 to speed things up
- a bit more edgey but you get the idea
SELECT ST_Union(ST_MakeEnvelope(x-8,y-8,x,y,-1)))
FROM ch13.wpostgis CROSS JOIN
generate_series(1,600,8) As x CROSS JOIN generate_series(1,600,8) As y
WHERE x <= ST_Width(rast) AND y <= ST_Height(rast) AND (ST_Value(rast, 1, x,
y)  <> 255
OR ST_Value(rast, 2, x, y)  <> 255 OR ST_Value(rast, 3, x, y)  <> 255
OR ST_Value(rast, 4, x, y)  <> 255); 

-- ST_ConvexHull Simulation
SELECT ST_ConvexHull(ST_Union(ST_MakeEnvelope(x-8,y-8,x,y,-1))))
FROM ch13.wpostgis CROSS JOIN
generate_series(1,600,8) As x CROSS JOIN generate_series(1,600,8) As y
WHERE x <= ST_Width(rast) AND y <= ST_Height(rast) AND (ST_Value(rast, 1, x,
y)  <> 255
OR ST_Value(rast, 2, x, y)  <> 255 OR ST_Value(rast, 3, x, y)  <> 255
OR ST_Value(rast, 4, x, y)  <> 255) ;


So I was expecting this to return something that looks like my simulation,
but instead seems to just return what looks like the 
envelop returns the yellow rectangle.
SELECT ST_ConvexHull(rast)
FROM ch13.wpostgis;

Thanks,
Regina

-------------- next part --------------
A non-text attachment was scrubbed...
Name: simulated_convex_andasPolygon.png
Type: image/png
Size: 88446 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20100405/54460ffa/attachment.png>


More information about the postgis-devel mailing list