Re: [postgis-users] ERROR: rt_raster_to_gdal: Could not create the output GDAL dataset

2020-02-12 Thread john polo

On 2/12/2020 12:28 PM, Regina Obe wrote:

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>

Thanks, Regina. I tried the new code above and I still get the same error.

Here is the simple SELECT statement:

postgis_in_action=# SELECT rast_name FROM ch07.bag_o_rasters WHERE 
rast_name = 'Raster 1 band heatmap';

   rast_name
---
 Raster 1 band heatmap
(1 row)

I made different attempts and replaced 'USGSDEM' with 'JPEG' and 
'GTiff'. I tried with the old and new code. It worked either way with 
the JPEG and GTiff types. It seems like 'USGSDEM' is the problem here. I 
don't know why. I don't know how to diagnose the problem pertaining to 
one raster type. I suppose it's not a problem until I'll need to 
actually produce output as USGSDEM. :)


best regards,

John

--
Enlightenment is ego's ultimate disappointment.
-Chogyam Trungpa

___
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ERROR: rt_raster_to_gdal: Could not create the output GDAL dataset

2020-02-12 Thread Regina Obe
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-boun...@lists.osgeo.org] On Behalf Of 
john polo
Sent: Wednesday, February 12, 2020 12:51 PM
To: postgis-users@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
___
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

[postgis-users] ERROR: rt_raster_to_gdal: Could not create the output GDAL dataset

2020-02-12 Thread john polo

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

___
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users