[postgis-users] Best practices for PostGIS raster query and processing from web app

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Tue Apr 9 14:42:39 PDT 2013


> >	Pixel selection is possible via three options:
> >	1) one raster ST_MapAlgebra
> >	2) ST_Reclass
> >	3) ST_DumpAsPolygons (with a where clause)
> 
> OK, we will test the different approaches to see what works best/fastest.  When
> a query refers to multiple raster layers (e.g., select pixels with slope = x,
> elevation = y, landcover = z), I suppose you would use multiple calls to one-
> raster ST_MapAlgebra or a combination of one- and two-raster?

Good question. I was about to say that if you want to return all the bands of the intersecting raster then you should use ST_Intersection with the two raster but apparently only ST_Clip returns all the bands and it take a raster and a geometry :-(

So I guess multiple calls to ST_Mapalgebra is the best approach.

> >	It is possible to build a distance raster in the database. It is a slow
> >operation. But if your data is kind of static you can do it outside. What do you
> >want exactly? The nearest pixels to a rail?
> 
> We are after a raster layer that has a distance via highway to the nearest
> railroad for each raster cell.  That way a user can query cells based on their own
> distance threshold of interest.  Looks like the best way is to precompute
> distance and conduct queries on this value.

Yep. Or you could use pgRouting in vector mode and then assign values to a raster.

> >	Try the new optimized callback map algebra:
> >	http://postgis.net/docs/manual-dev/RT_ST_MapAlgebra.html
> >	You might have to upgrade as it was optimized very recently.
>
> Does this mean switch to PostGIS 2.1, or use the latest 2.0.3?

PostGIS 2.1 SVN

> >	Test needed. If the pixel selected do not involve all the tiles of a tiled
> >raster you might gain a lot by tiling.
> 
> Pixels of interest will likely be found across the spatial extent of the database.
> And they will come in many small clusters.  So it sounds like having few tiles and
> sticking with rasters over vectors is the best way to go.  Currently we have no
> tiles.  Is this sensible?

You could tile very small. Like 10 pixels by 10 pixels.

Pierre



More information about the postgis-users mailing list