Opened 13 years ago
Closed 12 years ago
#1902 closed defect (invalid)
[raster] GDAL Surfer export creates files with minY and maxY swapped in header.
Reported by: | febi | Owned by: | pracine |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.2 |
Component: | raster | Version: | 2.0.x |
Keywords: | raster GSBG GSAG | Cc: |
Description
When you try to export Golden Software Binary/ASCII grid data from PostGIS 2.0.X with ST_AsGDALRaster function the maxY and minY are swapped in the header.
In ASCII or Binary version, it should be in order of minY maxY but it is recorded as maxY minY. This cause problem on some software like Mathematica which checks these value and report as error.
Change History (7)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
comment:3 by , 13 years ago
The C code underlying ST_AsGDALRaster passes along your desired format and the PostGIS raster converted to a GDAL MEM dataset to GDALCreateCopy(). GDALCreateCopy calls the appropriate format's CreateCopy function to do the actual conversion.
Is the scale along the Y-axis positive or negative? The values for minY and maxY may be flipped because the scale along the Y-axis is positive. Calling ST_ScaleY() on the raster will tell you the answer.
comment:4 by , 13 years ago
From looking at frmts/gsg/gsagdataset.cpp around line 1568, the GSAG/GSBG formats expect a top-down (negative scale on Y-axis) orientation.
comment:5 by , 13 years ago
What I do is I chop a region from my raster with [ST_Clip(ST_Transform(… ] and scale it to 100m (lets say) with ST_Scale. Then I write out. I expect left to right and top to bottom is the positive direction. What shall I do if the GSG driver expects the other way around?
comment:6 by , 13 years ago
PostGIS Raster (and most other raster tools I've used) follows the definitions of the World File…
http://en.wikipedia.org/wiki/World_file
So, top to bottom is expected to be negative (negative Y scale) and left to right is expected to be positive (positive X scale). I'm guessing that your raster's Y scale is positive and the upper-left corner of the raster is really the raster's lower-left corner. So, you need to swap the Y coordinates of the lower-left and upper-left and make the Y scale negative. I think that's right…
comment:7 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Which version of GDAL are you running? Also, is the value for scale Y negative or positive? Typically, scale Y is negative thereby having the Y coordinate of upper-left corner be maxY. If scale Y is positive, the Y coordinate of the upper-left corner would be minY.
ST_AsGDALRaster is pretty bare and acts only as a pass-through function to GDAL's CreateCopy() of the requested format.