[postgis-users] POSTGIS DTED...

David Blasby dblasby at refractions.net
Tue May 13 15:06:48 PDT 2003


Jan Hartmann wrote:

>
> Dave, if you have time, could you give some more information on this 
> CHIP type. I never heard of it.

[PAUL - please add this documentation to the website]

It is fairly simple.  I created it when we did TerrainServer 
 (http://www.refractions.net/terrainserver/) to 3D-ify WMS and mapserver 
webmaps.  Currently our TerrainServer database contains the entire USA 
DEM at 30m, and large chunks at 10m.  We also have the British Columbia 
DEM at 25m.

The CHIP structure looks like this (postgis.h):

typedef struct chiptag
{
        int     size; //unused (for use by postgresql)

        int     endian_hint;  // the number 1 in the endian of this 
datastruct

        BOX3D    bvol;
        int      SRID;
        char     future[4];
        float  factor;           //usually 1.0.  Integer values are 
multiplied by this number
                              //to get the actual height value (for 
sub-meter accuracy
                                        //height data).

        int     datatype;        // 1 = float32, 5 = 24bit integer, 6 = 
16bit integer (short)
                                 // 101 = float32 (NDR), 105 = 24bit 
integer (NDR), 106=16bit int (NDR)
        int     height;
        int     width;
        int   compression;      //# 0 = no compression, 1 = differencer
                                                                //     
0x80 = new value
                                                                //     
0x7F = nodata

                // this is provided for convenience, it should be set to
                //  sizeof(chip) bytes into the struct because the 
serialized form is:
                //    <header><data>
                // NULL when serialized
        void  *data;            // data[0] = bottum left, data[width] = 
1st pixel, 2nd row (uncompressed
)
} CHIP;

So its basically a little header and the actual raser data - as simple 
as can be.

The functions in postgis_chip.c are used to manipulate this structure:

CHIP_in() -- ASCII to internal binary. Required by Postgresql for SQL 
representation
CHIP_out() -- internal binary to  ASCII.  Required by Postgresql for  
SQL representation
CHIP_to_geom() -- creates a polygon based on the bvol of the grid
srid_chip() -- get the SRID of the grid
factor_chip() - get the multiplication factor of the chip
datatype_chip() - get the datatype number of the chip
compression_chip() - get the compression type of the chip
height_chip() - get the height of the chip
width_chip() - get the width of the chip
setsrid_chip() - create a new chip with a new SRID
setfactor_chip() - create a new chip with the factor multiplication 
changed (usefull for changing the units of the data)

The ASCII representation is like the WKB representation - a direct HEX 
dump of a chip.

The functions provided in PostGIS are very simple - its basically a bit 
bucket.  The actual manipulation of the CHIP is usually preformed by an 
external program.

The CHIP doesnt have a direct way of  indexing.  The easiest way to do 
this create a table like this:

CREATE TABLE myRaster (mychip chip, mybox geometry);

Then put all your chips in, and run this to fill in the mybox column:

UPDATE myRaster SET mybox = geometry(mychip);

And build an index:

CREATE INDEX myspatial_index ON myRaster USING GIST mybox 
GIST_GEOMETRY_OPS);

Then use the mybox column to do index-supported spatial queries.

dave







More information about the postgis-users mailing list