[postgis-users] Querying Multiple Rasters

Jayson Gallardo jaysontrades at gmail.com
Tue Jul 23 10:43:47 PDT 2013


I've looked and looked, but I have not been able to find an answer to my
question. I have downloaded elevation data for the state of Arkansas (in
the form of multiple tiles), and used raster2pgsql to upload it into a
single table:

raster2pgsql -I -C -e -F -t 50x50 -l 2,4 n*/grdn* public.dem_elevation |
psql -U postgres -d testdb -h localhost -p 5432

I did this because I didn't know how to pull the data if they were in
separate tables. Now, however I would like to add elevation data for other
areas. I tried to just add it to the current table, but that required
dropping the constraints which for such a huge amount of data seems to take
a long time (I let it run for 24+ hours and it didn't finish). So, my
question is, if I load all my rasters as individual tables, how could I run
something similar to this query on them all (from a python script):

SELECT ST_AsGDALRaster(ST_CLIP(ST_Union(rast),
ST_GeomFromText(WKT,900913)),'GTiff') FROM "dem_elevation" WHERE
ST_Intersects(rast, ST_Transform(ST_GeomFromText(WKT,900913),4269))

My goal, if it's not obvious, is to clip elevation data and export it to a
GTiff format and perform some operations on that raster data. Eventually, I
would like to put the whole continental US elevation data into my database,
so I need to be able to do so, while still being able to query them based
on an area of interest the user selects from a map. I started working with
PostGIS and Mapserver last month, so please forgive my ignorance on such
topics. Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130723/a83b339e/attachment.html>


More information about the postgis-users mailing list