[postgis-users] Problem with postgis raster

Rémi Cura remi.cura at gmail.com
Tue May 20 02:53:30 PDT 2014


I'm afraid the only way to visualyze raster fast enough in GQIs I found is
to export the raster as tif :-(
Of course using gdal is not an option because it is very slow,
so I use the Pierre Racine trick with plpythonu (I lost the source but all
credits to him of course).
This is order of magnitude faster.
Cheers,
Rémi-C

----------------------------------------
 CREATE OR REPLACE FUNCTION write_file (param_bytes bytea, param_filepath
text, chmod character varying (4))
RETURNS text
AS $$
import os
f = open(param_filepath, 'wb')
chmod_oct = int(chmod,8) # new addition (converts chmod octal code to
associated integer value)
os.chmod(param_filepath,chmod_oct) # new addition (changes read/write
permissions)
f.write(param_bytes)
f.close() # new addition (ensures file is closed after writing)
return param_filepath
$$ LANGUAGE plpythonu;

DROP FUNCTION IF EXISTS write_file_texte (param_bytes bytea, param_filepath
text, chmod character varying (4));
 CREATE OR REPLACE FUNCTION write_file_texte (param_bytes text,
param_filepath text, chmod character varying (4))
RETURNS text
AS $$
import os
f = open(param_filepath, 'w')
chmod_oct = int(chmod,8) # new addition (converts chmod octal code to
associated integer value)
os.chmod(param_filepath,chmod_oct) # new addition (changes read/write
permissions)
f.write(param_bytes)
f.close() # new addition (ensures file is closed after writing)
return param_filepath
$$ LANGUAGE plpythonu;


--Here’s an example of how to use this function:

SELECT write_file(ST_AsTIFF(ST_SetSRID(ST_Transform(rast,931008),931008)),
'/tmp/rast_' || rid || '.tif','777')
FROM test_raster.temp_test_interpolation ;

----------------------------------------


2014-05-20 11:29 GMT+02:00 dandrigo <lcelati at latitude-geosystems.com>:

> It's ok. Thanks. I succeed in displaying pg raster via qgis. in order to
> display pg raster data, you're obliged to specified the host value.
>
> Remi, indeed, the displaying is slow. According to you, it would be usefull
> to import raster with -t option (tiles) in order to speed up the
> displaying?
>
> With qgis 2.2, the gdal version is 10.1.
>
>
>
>
>
> --
> View this message in context:
> http://postgis.17.x6.nabble.com/Problem-with-postgis-raster-tp5006344p5006363.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140520/3742f2a2/attachment.html>


More information about the postgis-users mailing list