[postgis-users] How to perform st_PixelAsPolygon(rast, geom) ?
Pierre Racine
Pierre.Racine at sbf.ulaval.ca
Fri Apr 5 09:12:09 PDT 2013
You can do:
SELECT ST_PixelAsPolygon(rast, ST_WorldToRasterCoordX(rast, ST_X(geom)), ST_WorldToRasterCoordY(rast, ST_Y(geom))) geom
FROM yourrast, yourpoints
WHERE ST_Intersects(rast, geom)
Note that PixelAsPolygon has no "s".
You will get the vectorization of every pixels having a point inside. Up to you to deal with duplicates.
Pierre
> -----Original Message-----
> From: postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-
> bounces at lists.osgeo.org] On Behalf Of Hugues François
> Sent: Friday, April 05, 2013 6:51 AM
> To: postgis-users at lists.osgeo.org
> Subject: [postgis-users] How to perform st_PixelAsPolygon(rast, geom) ?
>
> Hello,
>
>
>
> I need to work with a dem raster at the pixel scale but there are few functions to
> access them. Maybe I forgot something but, if we can have a value crossing a
> point with raster using st_value, we can't access the pixel geometry directly
> from a point.
>
>
>
> The only way I found was first to use St_PixelAsPolygons to access pixel
> geometry (for relevant tiles) and then intersects resulting geometries with
> original points but this method costs very much.
>
>
>
> Anyone have an idea to increase performances ?
>
>
>
> Hugues.
More information about the postgis-users
mailing list