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 : [email protected] 
[mailto:[email protected]] 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: [email protected] [mailto:postgis-users- 
> [email protected]] On Behalf Of Hugues François
> Sent: Friday, April 05, 2013 6:51 AM
> To: [email protected]
> 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
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

Reply via email to