[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Problem with postgis raster
From:       Rémi_Cura <remi.cura () gmail ! com>
Date:       2014-05-20 9:53:30
Message-ID: CAJvUf_tsD-t9Cboqx2-Z2igj6=TS13Mj5i1ME7inPda_PUgYtA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>

[Attachment #5 (text/html)]

<div dir="ltr"><div>I&#39;m afraid the only way to visualyze raster fast enough in \
GQIs I found is to export the raster as tif :-(<br></div><div>Of course using gdal is \
not an option because it is very slow, <br>so I use the Pierre Racine trick with \
plpythonu (I lost the source but all credits to him of course).<br> </div><div>This \
is order of magnitude \
faster.<br></div>Cheers,<br>Rémi-C<br><br>----------------------------------------<br> \
CREATE OR REPLACE FUNCTION write_file (param_bytes bytea, param_filepath text, chmod \
character varying (4))<br> RETURNS text<br>AS $$<br>import os<br>f = \
open(param_filepath, &#39;wb&#39;)<br>chmod_oct = int(chmod,8) # new addition \
(converts chmod octal code to associated integer \
value)<br>os.chmod(param_filepath,chmod_oct) # new addition (changes read/write \
permissions)<br> f.write(param_bytes)<br>f.close() # new addition (ensures file is \
closed after writing)<br>return param_filepath<br>$$ LANGUAGE plpythonu;<br><br>DROP \
FUNCTION IF EXISTS write_file_texte (param_bytes bytea, param_filepath text, chmod \
character varying (4));<br>  CREATE OR REPLACE FUNCTION write_file_texte (param_bytes \
text, param_filepath text, chmod character varying (4))<br>RETURNS text<br>AS \
$$<br>import os<br>f = open(param_filepath, &#39;w&#39;)<br>chmod_oct = int(chmod,8) \
# new addition (converts chmod octal code to associated integer value)<br> \
os.chmod(param_filepath,chmod_oct) # new addition (changes read/write \
permissions)<br>f.write(param_bytes)<br>f.close() # new addition (ensures file is \
closed after writing)<br>return param_filepath<br>$$ LANGUAGE plpythonu;<br> \
<br><br>--Here's an example of how to use this function:<br><br>SELECT \
write_file(ST_AsTIFF(ST_SetSRID(ST_Transform(rast,931008),931008)), \
&#39;/tmp/rast_&#39; || rid || &#39;.tif&#39;,&#39;777&#39;)<br>FROM \
test_raster.temp_test_interpolation ;<br>  \
<br>----------------------------------------<br></div><div \
class="gmail_extra"><br><br><div class="gmail_quote">2014-05-20 11:29 GMT+02:00 \
dandrigo <span dir="ltr">&lt;<a href="mailto:lcelati@latitude-geosystems.com" \
target="_blank">lcelati@latitude-geosystems.com</a>&gt;</span>:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">It&#39;s ok. Thanks. I succeed in displaying pg raster via \
qgis. in order to<br> display pg raster data, you&#39;re obliged to specified the \
host value.<br> <br>
Remi, indeed, the displaying is slow. According to you, it would be usefull<br>
to import raster with -t option (tiles) in order to speed up the displaying?<br>
<br>
With qgis 2.2, the gdal version is 10.1.<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a \
href="http://postgis.17.x6.nabble.com/Problem-with-postgis-raster-tp5006344p5006363.html" \
target="_blank">http://postgis.17.x6.nabble.com/Problem-with-postgis-raster-tp5006344p5006363.html</a><br>


<div class="HOEnZb"><div class="h5">Sent from the PostGIS - User mailing list archive \
at Nabble.com.<br> _______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" \
target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br> \
</div></div></blockquote></div><br></div>



_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic