[postgis-users] How to handle tiled rasters (ST_Value, grid_pt=>coord, coord=>grid_pt etc)?

Stefan Keller sfkeller at gmail.com
Fri Dec 10 17:35:27 PST 2010


I have some questions which bother my perception of PostGIS Raster concepts:

First, I've successfully imported into PostGIS 2.0.0 a tiled raster
into table ch1000_tif_tiled, like this:

raster2pgsql.py" -r ch1000.ti
  f -t ch1000_tif_tiled -s 21781 -k 20x20 -I -o ch1000_tif_tiled.sql
  ------------------------------------------------------------
   Summary of GDAL to WKT Raster processing:
  ------------------------------------------------------------
  Number of processed raster files: 1 (ch1000.tif)
  List of generated tables (number of tiles):
  1       ch1000_tif_tiled (240)

Query 1 - Get no. of bands of a tiled raster:
> SELECT ST_numbands(rast) FROM ch1000_tif_tiled;
  1
  1
  1
  ...
  240 times!
This is not what I expected; I'd like one row, since I inputted one
raster file (now tiled though). And "SELECT MAX(ST_numbands(rast))
does'nt make it better. => ?

Query 2 - Get value at raster "grid" point 10/20 (default band=1).
> SELECT ST_Value(rast,10,20) FROM ch1000_tif_tiled;
This query again returns 240 rows (values)! What I'd expect is one
value and one grid point.

Query 3 - Get projected coordinate and value given a raster "grid"
point at 10/20 (after a note at ST_Value):
SELECT ST_AsText(ST_SetSRID(ST_Point(ST_UpperLeftX(rast) +
ST_PixelSizeX(rast)*10, ST_UpperLeftY(rast) + ST_PixelSizeY(rast)*20),
ST_SRID(rast))), ST_Value(rast,10,20) FROM ch1000_tif_tiled;
  "POINT(489500 102500)";0
  "POINT(489500 122500)";468
  "POINT(489500 142500)";1273
  "POINT(489500 162500)";948
  "POINT(489500 182500)";0
=> I'd expext only one POINT and it's value.

There are of course more functions, like ST_Envelope(rast) which gives
back 24 envelopes..., etc.
=> Should I really have to care about tiled raster doing MAX,
ST_Union, GROUP BY, etc.?

Query 4: Given one real projected coordinate (e.g. 489500/102500)
return the corresponding ("closest") grid point and its value.
=> ?

Yours, S.

P.S. BTW, table "raster_overviews" was emtpy after import (as
described above). What's its purpose?



More information about the postgis-users mailing list