[postgis-devel] ST_Colormap

David Haynes II dahaynes at umn.edu
Fri Apr 22 09:51:19 PDT 2016


Hello

Working on an application for clipping rasters (data.terrapop.org/terraclip)
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.

WITH projection as
(
SELECT ST_SRID(rast) as srid
FROM gis_rasters.apricothar
Limit 1
),polygon as
(
SELECT sgl.id as sample_geog_level_id, gi.id as geog_instance_id, gi.label
as geog_instance_label,
gi.code as geog_instance_code, ST_Transform(bound.geog::geometry, prj.srid)
as geom
FROM projection prj, sample_geog_levels sgl
inner join geog_instances gi on sgl.id = gi.sample_geog_level_id
inner join boundaries bound on bound.geog_instance_id = gi.id
WHERE sgl.id = 226
),raster_clip as
(
SELECT ST_Clip(r.rast, 1, p.geom, TRUE) AS rast
FROM polygon p inner join gis_rasters.apricothar  r on
ST_Intersects(r.rast,p.geom)
)
select ST_AsJPEG(ST_Colormap(rast, 1, 'greyscale'))  as img
from raster_clip, projection prj

-- 
David Haynes, Ph.D.
Research Associate Terra Populus
Minnesota Population Center
612-626-3933
www.terrapop.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20160422/2a9942cc/attachment.html>


More information about the postgis-devel mailing list