[postgis-users] How to perform st_PixelAsPolygon(rast, geom) ?

Hugues François hugues.francois at irstea.fr
Sat Apr 6 05:11:23 PDT 2013


Thank you very much Pierre ! That's exactly what I was looking for. Sorry I didn't find the st_worldtorastercoord functions which do exactly what I need (maybe it should be a good idea to add a reference in the pixel accessors et setter functions -in "see also" -  since theses function work at the pixel level).

Hugues.

-----Message d'origine-----
De : postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] De la part de Pierre Racine
Envoyé : vendredi 5 avril 2013 18:12
À : PostGIS Users Discussion
Objet : Re: [postgis-users] How to perform st_PixelAsPolygon(rast, geom) ?

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.

_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


More information about the postgis-users mailing list