<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>David,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>I could be mistaken, but I always thought that for jpegs the spatial info is stored in a .jpegw file and since ST_ASJPEG only outputs the jpg part it wouldn't keep the spatial ref info.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Are you saying you loose it at the ST_ColorMap part or the ST_AsJPEG.  I would expect it maintained in ST_ColorMap and lost at ST_AsJPEG call.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Regina<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in'><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> postgis-devel [mailto:postgis-devel-bounces@lists.osgeo.org] <b>On Behalf Of </b>David Haynes II<br><b>Sent:</b> Friday, April 22, 2016 12:51 PM<br><b>To:</b> PostGIS Development Discussion <postgis-devel@lists.osgeo.org><br><b>Subject:</b> [postgis-devel] ST_Colormap<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p><div><p class=MsoNormal style='margin-left:.5in'>Hello<o:p></o:p></p><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>Working on an application for clipping rasters (<a href="http://data.terrapop.org/terraclip">data.terrapop.org/terraclip</a>) and running into an issue with the ST_Colormap function. It seems that whenever we run the ST_Colormap function we lose the spatial reference information for the image.This is the sample of the query that we are running. The query is successful, but the resulting images can be built into a vrt with gdal. I'm using PostgreSQL 9.3.7  and POSTGIS 2.1.7.<o:p></o:p></p></div><div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><div><p class=MsoNormal style='margin-left:.5in'>WITH projection as<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>(<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>SELECT ST_SRID(rast) as srid<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>FROM gis_rasters.apricothar<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>Limit 1<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>),polygon as<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>(<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>SELECT <a href="http://sgl.id">sgl.id</a> as sample_geog_level_id, <a href="http://gi.id">gi.id</a> as geog_instance_id, gi.label as geog_instance_label,<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>gi.code as geog_instance_code, ST_Transform(bound.geog::geometry, prj.srid) as geom<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>FROM projection prj, sample_geog_levels sgl<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>inner join geog_instances gi on <a href="http://sgl.id">sgl.id</a> = gi.sample_geog_level_id<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>inner join boundaries bound on bound.geog_instance_id = <a href="http://gi.id">gi.id</a><o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>WHERE <a href="http://sgl.id">sgl.id</a> = 226<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>),raster_clip as<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>(<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>SELECT ST_Clip(r.rast, 1, p.geom, TRUE) AS rast <o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>FROM polygon p inner join gis_rasters.apricothar  r on ST_Intersects(r.rast,p.geom)<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>)<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>select ST_AsJPEG(ST_Colormap(rast, 1, 'greyscale'))  as img<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>from raster_clip, projection prj<o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><p class=MsoNormal style='margin-left:.5in'>-- <o:p></o:p></p><div><div><div><div><p class=MsoNormal style='margin-left:.5in'>David Haynes, Ph.D.<o:p></o:p></p><div><p class=MsoNormal style='margin-left:.5in'>Research Associate Terra Populus<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>Minnesota Population Center<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>612-626-3933<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><a href="http://www.terrapop.org" target="_blank">www.terrapop.org</a><o:p></o:p></p></div></div></div></div></div></div></div></div></body></html>