4

I'm using shell-script, PostGIS 2.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...

1 Answer 1

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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