splashblot / dronedb

Location Intelligence & Data Visualization tool
http://carto.com
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Exporting raster data as tif #107

Open ivanprado opened 6 years ago

ivanprado commented 6 years ago

Current export for raster data exports it as CSV. That is not useful as cannot be imported back properly (all information about coordinates as been lose).

Explore the usage of postgis https://postgis.net/docs/RT_ST_AsTIFF.html to perform the export. Have in mind that generated raster can be quite big.

apercas commented 6 years ago

Currently using POSTGIS="2.3.3 r15473 but still having this issue: https://dba.stackexchange.com/questions/98067/rt-raster-to-gdal-could-not-load-the-output-gdal-driver Checking the setup.

apercas commented 6 years ago

From inside postgresql-cli inside dronedb's docker container, run:

postgres=# SET postgis.enable_outdb_rasters = True;
SET
postgres=# SET postgis.gdal_enabled_drivers = 'ENABLE_ALL';
SET
postgres=# SET postgis.gdal_enabled_drivers TO 'GTiff PNG JPEG';
SET
postgres=# ALTER SYSTEM SET postgis.gdal_enabled_drivers TO 'GTiff PNG JPEG';
ALTER SYSTEM
postgres=# SELECT pg_reload_conf();
 pg_reload_conf 
----------------
 t
(1 row)

postgres=# 

Now it 'works' for queries such as http://dev.localhost.lan/api/v2/sql?api_key=5c0a2ae3e4e30def2796fb1f85a03a3ace00f05e&q=SELECT ST_AsTIFF(the_raster_webmercator) as rastiff from pegados_raster