Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Im using shell-script, postgis2.0 and gdal for trying to clip raster apart, using an overlapping raster and a the_geom-object. At first I create a view to clip the overlapping part of the raster. It gives me several raster-tiles as results, which I bundle with st_union as one raster. It works all fine and i can see results in the tables.

psql -h localhost -p 5432 -d testlauf -U postgres <<EOF CREATE OR REPLACE VIEW profilschnitt.cliptest AS SELECT st_union(st_clip(a.rast, b.the_geom)) FROM rastertable a JOIN tiletable b ON (st_envelope(a.rast) && b.the_geom); EOF

Now i want to see how the unified raster looks in GIS and try to export the raster via gdal_translate into SAGA-rasterformat:

gdal_translate -ot Float32 -of SAGA PG:"host=localhost port=5432 dbname=testlauf user=postgres password=postgresdb schema=profilschnitt table=cliptest mode=2" ~/Desktop/cliptest.sdat

Problem is, that gdal tells me the following:

ERROR 1: Error browsing database for PostGIS Raster properties GDALOpen failed - 1

My db-connection is set up correctly and gdal-translate already worked with other raster-views/-tables too. So I assume that the problem must be somewhere within the query-view... For any ideas i would be grateful :)

share|improve this question
add comment

1 Answer 1

Okay, i found my mistake: it seems helpful to create a, additional column "rid" in the view. Now export works fine. I added the correct query:

psql -h localhost -p 5432 -d testlauf -U postgres <<EOF CREATE OR REPLACE VIEW profilschnitt.cliptest AS SELECT 1 as rid, st_union(st_clip(a.rast, b.the_geom)) FROM rastertable a JOIN tiletable b ON (st_envelope(a.rast) && b.the_geom); EOF

Regards, knutella

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.