I've the following table in PostGIS
-- Table: public.elevation_data
-- DROP TABLE public.elevation_data;
CREATE TABLE public.elevation_data
(
rid integer NOT NULL DEFAULT nextval('elevation_data_rid_seq'::regclass),
rast raster,
CONSTRAINT elevation_data_pkey PRIMARY KEY (rid)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.elevation_data
OWNER TO username;
-- Index: public.elevation_data_st_convexhull_idx
-- DROP INDEX public.elevation_data_st_convexhull_idx;
CREATE INDEX elevation_data_st_convexhull_idx
ON public.elevation_data
USING gist
(st_convexhull(rast));
created with the following command
raster2pgsql -I -s 4326 -t auto DataSet\Elevation\*.dt2 public.elevation_data | psql -U username -d databasename
Now I want to export this table to a .dt2 file, so I can exchange it. How can I export the table in the raster format?
EDIT:
I've looking documentation and I've tried following query:
COPY(SELECT ST_AsGDALRaster(rast, 'DTED') FROM public.elevation_data) TO 'd:\dteddata.dt2' (FORMAT binary);
It creates a very big file (over 7Gb) when the table was created by importing two files of about 50Mb in total. When I try to open this file, for example in QGIS, it says me that the file is not supported. The same if I try to save it as GeoTiff with the command:
COPY(SELECT ST_AsGDALRaster(rast, 'GTiff') FROM public.elevation_data) TO 'd:\dteddata.tiff' (FORMAT binary);
even if in this case the file has a size of about 51Mb, that seems more correct to me.
I've followed instruction from this page for retrieving DTED data, and joining them with this other one, because ST_AsGDALRaster
returns a bytea
, and the second links explains how to save it to a file, but I'm doing it the wrong way of course...