[postgis-users] POSTGIS DTED...

Nick Ton nton at photon.com
Fri May 16 10:06:19 PDT 2003


Hi David,

Thank you for your response about raster capabilities in PostGIS.
It seems though that the CHIP data structure is for external programs 
developed using C or C++. Is there an equivalent Java version of the CHIP
data structure? Also, I am a bit new to the GIS world, so I apologize
for asking these silly questions:

Your email states that we can create a table using the following SQL
command:
CREATE TABLE myRaster (mychip chip, mybox geometry);
a. Can I make this command call in the psql console enviroment once PostGis
is installed?
Or do I create a C program that first defines "mychip" data structure and
then
execute the SQL CREATE command in the same C program?
b. If the latter is true, does this imply that I would have to invoke
the update and query command from the same C Program. It's not clear to me
that once I define the "mychip" data structure that any other external
program
would know the "mychip" data structure without having to redefine it.


Thanks,
Nick


-----Original Message-----
From: David Blasby [mailto:dblasby at refractions.net]
Sent: Tuesday, May 13, 2003 6:07 PM
To: PostGIS Users Discussion; paul at refractions.net
Subject: Re: [postgis-users] POSTGIS DTED...


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





_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list