[postgis-users] Rasterize a vector

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Tue May 29 11:25:54 PDT 2012


Basically (I use the old sub query style):

SELECT ST_Union(ST_AsRaster(g.geom, ref.rast, '32BUI', g.id, 0))) rast
FROM (SELECT ST_MakeEmptyRaster(1, 1, 0, 0, 1, -1, 0, 0, 0) AS rast) ref, mygeomtable g

however if your raster is high resolution ST_Union might be impractically slow.

The other technique untill we get a faster ST_Union is to use ST_MapAlgebraFct and write your own function returning the geometry value from the intersection with the centroid of the pixel. See this example http://postgis.refractions.net/pipermail/postgis-users/2012-April/033875.html

I agree this is relatively cumbersome but it should be much faster than ST_Union.

Pierre

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-
> bounces at postgis.refractions.net] On Behalf Of Bborie Park
> Sent: Tuesday, May 29, 2012 2:11 PM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] Rasterize a vector
> 
> On 05/29/2012 11:07 AM, Paolo Cavallini wrote:
> > Il 29/05/2012 20:05, Pierre Racine ha scritto:
> >
> >> The most important is: At the end do you want all geometries to be burned
> into the same raster or you want one raster per geometries?
> >
> > same raster - see gdal_rasterize for an example.
> > thanks a lot.
> >
> 
> Run an ST_Union upon the set of output rasters.
> 
> -bborie
> 
> --
> Bborie Park
> Programmer
> Center for Vectorborne Diseases
> UC Davis
> 530-752-8380
> bkpark at ucdavis.edu
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list