In PostGIS you can easily create a grid with ST_MakeEmptyRaster() and 
ST_PixelAsPolygons()

Pierre

> -----Original Message-----
> From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users-
> boun...@postgis.refractions.net] On Behalf Of pcr...@pcreso.com
> Sent: Monday, May 28, 2012 3:45 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] RE : get unique values from raster intersecting
> apolygon
> 
> You could try something like gdal2xyz.py on you raster to create points for 
> each
> raster cell which can be imported directly into postgis as point geometries, 
> like:
> 
> psql "create table xyz (id serial,x decimal, y decimal, z decimal)"
> gdal2xyz.py <raster file> | psql "copy xyz (x,y,z) from stdin..."
> psql "select addgeometrycolumn()"
> psql "update xyz set geom=setsrid(makepoint(x,y),<srid>)"
> 
> The result is then a simple spatial join using the polygons & the new points,
> based on ST_Contains().
> 
> 
> HTH,
> 
>    Brent Wood
> 
> 
> --- On Tue, 5/29/12, Francois Hugues <hugues.franc...@irstea.fr> wrote:
> 
> 
> 
>       From: Francois Hugues <hugues.franc...@irstea.fr>
>       Subject: [postgis-users] RE : get unique values from raster intersecting
> apolygon
>       To: "PostGIS Users Discussion" <postgis-users@postgis.refractions.net>
>       Date: Tuesday, May 29, 2012, 1:05 AM
> 
> 
>       I want one value per red point (which are raster data).
> 
>       The gid of one polygon will appear as many times as necessary
> regarding how it intersects the raster.
> 
>       Hugues.
> 
> 
>       -------- Message d'origine--------
>       De: postgis-users-boun...@postgis.refractions.net de la part de Pierre
> Racine
>       Date: lun. 28/05/2012 14:24
>       À: PostGIS Users Discussion
>       Objet : Re: [postgis-users] get unique values from raster intersecting
> apolygon
> 
>       You want one value per polygon or one value per red point? It is not
> clear to me from your drawing.
> 
>       Pierre
> 
>       > -----Original Message-----
>       > From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-
> users-
>       > boun...@postgis.refractions.net] On Behalf Of Francois Hugues
>       > Sent: Saturday, May 26, 2012 5:29 PM
>       > To: postgis-users@postgis.refractions.net
>       > Subject: [postgis-users] get unique values from raster intersecting a
> polygon
>       >
>       > Hello list,
>       >
>       > I have to get values from raster where they intersect polygons from a
> layer with
>       > numerous polygons which have shared boundaries, but I don't want to
> have
>       > duplicate values from raster. The final result must be something like 
> :
> gid | val.
>       >
>       > To explain my case, I made a picture.
>       >
>       > I think ST_intersection could help but I don't know what will be the
> exact result.
>       > In my example, we have a grid (a DEM for example), each red point is
> the value
>       > in the centre of each cell and two polygons A and B. I think cells 
> totally
> within
>       > polygons are not a problem, but in green I have highlighted some
> ambiguous
>       > cases :
>       > - 1 and 2 are cells shared by both polygons but not in the same
> proportions and I
>       > would like to get value 1 for polygon A but not for B and value 2 for
> polygon B
>       > but not for A
>       > - What will be the result for cell number 3 and for the other green 
> cell
> without
>       > number (and for all the ones which are not totally within a polygon) 
> ? I
> think the
>       > value is the same for the whole cell (st_dumpaspolygon) and will be
> returned
>       > whatever the part of the cell covered by the polygon, but if someone
> could
>       > confirm.
>       >
>       > If st_intersection use st_DumpAsPolygon, could it be better to work
> directly with
>       > this polygonized table using its own gist index and dealing with 
> shared
> areas of
>       > cells between different polygons ?
>       >
>       > Hugues.
>       >
>       >
>       >
>       >
> 
>       _______________________________________________
>       postgis-users mailing list
>       postgis-users@postgis.refractions.net
>       http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
>       -----Inline Attachment Follows-----
> 
> 
>       _______________________________________________
>       postgis-users mailing list
>       postgis-users@postgis.refractions.net
>       http://postgis.refractions.net/mailman/listinfo/postgis-users
> 

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to