mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-25 17:42:38 +00:00
Add another example to st_value demonstrating sampling and fix other example
git-svn-id: http://svn.osgeo.org/postgis/trunk@5568 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
497206806f
commit
b3b5b89e00
|
@ -1213,7 +1213,7 @@ FROM (SELECT ST_Translate(ST_MakeEnvelope(
|
|||
ST_UpperLeftX(rast) + ST_PixelSizeX(rast),
|
||||
ST_UpperLeftY(rast) + ST_PixelSizeY(rast), 0
|
||||
), ST_PixelSizeX(rast)*x, ST_PixelSizeY(rast)*y
|
||||
) As pixpolyg, ST_Value(rast, 1, x, y) As b1val
|
||||
) As pixpolyg, ST_Value(rast, 2, x, y) As b2val
|
||||
FROM dummy_rast CROSS JOIN
|
||||
generate_series(1,1000) As x CROSS JOIN generate_series(1,1000) As y
|
||||
WHERE rid = 2
|
||||
|
@ -1221,21 +1221,54 @@ WHERE rid = 2
|
|||
WHERE
|
||||
ST_Intersects(
|
||||
pixpolyg,
|
||||
ST_GeomFromText('POLYGON ((3427935.6902608695 5793250.889478261,
|
||||
3427932.0770434784 5793251.682173912,
|
||||
3427931.9295652173 5793250.400956522,
|
||||
3427933.0576086957 5793248.985, 3427933.518478261 5793249.192391304,
|
||||
3427934.611826087 5793248.999913043, 3427935.6902608695 5793250.889478261))',0)
|
||||
) AND b1val != 254;
|
||||
ST_GeomFromText('POLYGON((3427928 5793244,3427927.75 5793243.75,3427928 5793243.75,3427928 5793244))',0)
|
||||
) AND b2val != 254;
|
||||
|
||||
|
||||
shadow
|
||||
------------------------------------------------------------------------------------
|
||||
MULTIPOLYGON(((3427933.75 5793248.5,3427933.75 5793250,3427935.25 5793250,
|
||||
3427935.25 5793248.5,3427933.75 5793248.5)),
|
||||
((3427930.75 5793250,3427930.75 5793251.5,3427930.75 5793253,3427932.25 5793253,
|
||||
3427932.25 5793251.5,3427932.25 5793250,3427930.75 5793250)),
|
||||
((3427935.25 5793250,3427935.25 5793251.5,3427936.75 5793251.5,
|
||||
3427936.75 5793250,3427935.25 5793250)))
|
||||
MULTIPOLYGON(((3427928 5793243.9,3427928 5793243.85,3427927.95 5793243.85,3427927.95 5793243.9,
|
||||
3427927.95 5793243.95,3427928 5793243.95,3427928.05 5793243.95,3427928.05 5793243.9,3427928 5793243.9)),((3427927.95 5793243.9,3427927.95 579324
|
||||
3.85,3427927.9 5793243.85,3427927.85 5793243.85,3427927.85 5793243.9,3427927.9 5793243.9,3427927.9 5793243.95,
|
||||
3427927.95 5793243.95,3427927.95 5793243.9)),((3427927.85 5793243.75,3427927.85 5793243.7,3427927.8 5793243.7,3427927.8 5793243.75
|
||||
,3427927.8 5793243.8,3427927.8 5793243.85,3427927.85 5793243.85,3427927.85 5793243.8,3427927.85 5793243.75)),
|
||||
((3427928.05 5793243.75,3427928.05 5793243.7,3427928 5793243.7,3427927.95 5793243.7,3427927.95 5793243.75,3427927.95 5793243.8,3427
|
||||
927.95 5793243.85,3427928 5793243.85,3427928 5793243.8,3427928.05 5793243.8,
|
||||
3427928.05 5793243.75)),((3427927.95 5793243.75,3427927.95 5793243.7,3427927.9 5793243.7,3427927.85 5793243.7,
|
||||
3427927.85 5793243.75,3427927.85 5793243.8,3427927.85 5793243.85,3427927.9 5793243.85,
|
||||
3427927.95 5793243.85,3427927.95 5793243.8,3427927.95 5793243.75)))
|
||||
</programlisting>
|
||||
|
||||
<programlisting>
|
||||
--- Checking all the pixels of a large raster tile can take a long time.
|
||||
--- You can dramatically improve speed at some lose of precision by orders of magnitude
|
||||
-- by sampling pixels using the step optional parameter of generate_series.
|
||||
-- This next example does the same as previous but by checking 1 for every 4 (2x2) pixels and putting in the last checked
|
||||
-- putting in the checked pixel as the value for subsequent 4
|
||||
|
||||
SELECT ST_AsText(ST_Union(pixpolyg)) As shadow
|
||||
FROM (SELECT ST_Translate(ST_MakeEnvelope(
|
||||
ST_UpperLeftX(rast), ST_UpperLeftY(rast),
|
||||
ST_UpperLeftX(rast) + ST_PixelSizeX(rast)*2,
|
||||
ST_UpperLeftY(rast) + ST_PixelSizeY(rast)*2, 0
|
||||
), ST_PixelSizeX(rast)*x, ST_PixelSizeY(rast)*y
|
||||
) As pixpolyg, ST_Value(rast, 2, x, y) As b2val
|
||||
FROM dummy_rast CROSS JOIN
|
||||
generate_series(1,1000,2) As x CROSS JOIN generate_series(1,1000,2) As y
|
||||
WHERE rid = 2
|
||||
AND x <= ST_Width(rast) AND y <= ST_Height(rast) ) As foo
|
||||
WHERE
|
||||
ST_Intersects(
|
||||
pixpolyg,
|
||||
ST_GeomFromText('POLYGON((3427928 5793244,3427927.75 5793243.75,3427928 5793243.75,3427928 5793244))',0)
|
||||
) AND b2val != 254;
|
||||
|
||||
shadow
|
||||
------------------------------------------------------------------------------------
|
||||
MULTIPOLYGON(((3427927.9 5793243.85,3427927.8 5793243.85,3427927.8 5793243.95,
|
||||
3427927.9 5793243.95,3427928 5793243.95,3427928.1 5793243.95,3427928.1 5793243.85,3427928 5793243.85,3427927.9 5793243.85)),
|
||||
((3427927.9 5793243.65,3427927.8 5793243.65,3427927.8 5793243.75,3427927.8 5793243.85,3427927.9 5793243.85,
|
||||
3427928 5793243.85,3427928 5793243.75,3427928.1 5793243.75,3427928.1 5793243.65,3427928 5793243.65,3427927.9 5793243.65)))
|
||||
</programlisting>
|
||||
</refsection>
|
||||
|
||||
|
|
Loading…
Reference in a new issue