[postgis-users] ERROR: rt_raster_to_gdal: Could not create the output GDAL dataset
Regina Obe
lr at pcorp.us
Wed Feb 12 12:28:53 PST 2020
Just tried that query and works okay on my dataset from the book.
Can you confirm you have a record
SELECT name FROM ch07.bag_o_rasters WHERE rast_name = 'Raster 1 band heatmap';
If you missed a step earlier on in the chapter you might not have that record, and that would be one cause of the error you are having.
On a related note
That’s the old way of doing it but not the issue you are having.
New code PostGIS In Action 3rd is as follows – does it with on lo function instead of nested ones
SELECT lo_from_bytea(0, -- <1>
ST_AsGDALRaster(ST_Band(rast,1),
'USGSDEM',
ARRAY[
'PRODUCER=' || quote_literal('postgis_in_action'),
'INTERNALNAME=' || quote_literal(rast_name)]
) -- <2>
) AS oid
FROM ch07.bag_o_rasters
WHERE rast_name = 'Raster 1 band heatmap'; -- <2>
\lo_export 79906 'C:/temp/heatmap.dem' -- <3>
SELECT lo_unlink(79906); -- <4>
-- end::code_st_asgdalraster_output_psql[] --
--[1] create large object
--[2] query output to dem
--[3] use oid from previous query to export to file
--[4] when done delete large object
From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of john polo
Sent: Wednesday, February 12, 2020 12:51 PM
To: postgis-users at lists.osgeo.org
Subject: [postgis-users] ERROR: rt_raster_to_gdal: Could not create the output GDAL dataset
Hi,
I am using PostgreSQL 12 and PostGIS 3 on Windows 10. I am using a practice example for working with raster via psql. The values, like "131072" are from the book, so I don't know exactly what they mean (or much about the lo_ functions for that matter, other than they are meant for large object processing):
SELECT oid, lowrite(lo_open(oid, 131072), img) As num_bytes
FROM (
VALUES (
lo_create(0),
(SELECT
ST_AsGDALRaster(ST_Band(rast,1),
'USGSDEM',
ARRAY[
'PRODUCER=' || quote_literal('postgis_in_action'),
'INTERNALNAME=' || quote_literal(rast_name)]
) As dem
FROM ch07.bag_o_rasters
WHERE rast_name = 'Raster 1 band heatmap')
)
) As v(oid,img);
I get the error:
"ERROR: rt_raster_to_gdal: Could not create the output GDAL dataset "
I am connected to PostgreSQL:
postgis_in_action=# \conninfo
You are connected to database "postgis_in_action" as user "postgres" on host "localhost" (address "::1") at port "5432".
and a simple SELECT for the row ID of the 'Raster 1 band heatmap' works. I tried the same code in pgAdmin and got the same results. I searched for solutions. I found something that said to check the GDAL settings:
postgis_in_action=# SELECT short_name FROM ST_GDALDrivers();
short_name
GTiff
AAIGrid
DTED
PNG
JPEG
GIF
USGSDEM
XYZ
(8 rows)
It seems that GDAL is set to produce a USGSDEM.
I don't know why I am getting the error. Can someone suggest how I fix this, please?
best regards,
John Polo
--
Enlightenment is ego's ultimate disappointment.
-Chogyam Trungpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200212/67fe2249/attachment.html>
More information about the postgis-users
mailing list