[postgis-tickets] [PostGIS] #2248: ST_AsGDALRaster Missing Spatial Reference
PostGIS
trac at osgeo.org
Tue Mar 26 07:09:45 PDT 2013
#2248: ST_AsGDALRaster Missing Spatial Reference
-----------------------+----------------------------------------------------
Reporter: digimap2k | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone:
Component: postgis | Version: 2.0.x
Keywords: |
-----------------------+----------------------------------------------------
Comment(by digimap2k):
OK so for anyone reading this looking for a solution my conclusion are the
following:
It looks like the construction of output files from rasters through
ST_AsPng|Tiff|GDALRaster don't include the spatial reference system. This
in itself is perhaps not that suprising as most folk would most likely be
constructing some sort of transformed image as the endpoint in the
processing, perhaps for a map server. The information is clearly in there
as gdalinfo on the entire table does correctly extract and report the
PROJ_CS.
So the workaround:
First up if you don't care about the PROJ_CS then do nothing. If you want
to pull rasters as GeoTiffs for input into another GIS processing stage
then you need to push these into the files manually. What I do to
workaround this is in Qt C++ using GDAL/OGR is...
1) Grab the files using ST_AsGDALRaster(rast,'GTiff')
2) Grab the SRID of the raster in it's EPSG integer code from the database
using ST_SRID.
3) Make the WKT for the spatial reference using OGR, I guess you could
also do this using the spatial ref sys table in postgres.
4) Construct a GDALDatasetH from the binary raster data.
5) Apply the WKT spatial reference.
6) Save to file to check it and gdalinfo is all as should be.
Clearly the fix needed in postGIS is to push the spatial reference
directly into the file in the first place. Pretty sure it's not me and
generally failing to do this as gdalinfo on the bzipped results from the
postgis test runs also shows no valid PROJ_CS in any of the test files.
Hope that helps someone ;-)
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2248#comment:5>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list