<div dir="ltr">Hello<div><br></div><div>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.</div><div><div><br></div><div><div>WITH projection as</div><div>(</div><div>SELECT ST_SRID(rast) as srid</div><div>FROM gis_rasters.apricothar</div><div>Limit 1</div><div>),polygon as</div><div>(</div><div>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,</div><div>gi.code as geog_instance_code, ST_Transform(bound.geog::geometry, prj.srid) as geom</div><div>FROM projection prj, sample_geog_levels sgl</div><div>inner join geog_instances gi on <a href="http://sgl.id">sgl.id</a> = gi.sample_geog_level_id</div><div>inner join boundaries bound on bound.geog_instance_id = <a href="http://gi.id">gi.id</a></div><div>WHERE <a href="http://sgl.id">sgl.id</a> = 226</div><div>),raster_clip as</div><div>(</div><div>SELECT ST_Clip(r.rast, 1, p.geom, TRUE) AS rast </div><div>FROM polygon p inner join gis_rasters.apricothar  r on ST_Intersects(r.rast,p.geom)</div><div>)</div><div>select ST_AsJPEG(ST_Colormap(rast, 1, 'greyscale'))  as img<br></div><div>from raster_clip, projection prj</div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">David Haynes, Ph.D.<div>Research Associate Terra Populus</div><div>Minnesota Population Center</div><div>612-626-3933</div><div><a href="http://www.terrapop.org" target="_blank">www.terrapop.org</a></div></div></div></div></div>
</div></div>