[postgis-users] Converting WKT or WKB

Brent Wood pcreso at pcreso.com
Sun Feb 6 10:38:26 PST 2005


--- Abe Gillespie <agillesp at vt.edu> wrote:

> Hello all.  I'm new to the list.
> 
> I've just started using PostGIS, I'm one from the MapServer crowd.  I'd 
> like to use PostGIS with some ESRI technologies and am hoping to find 
> an easy way to go from PostGIS objects to ESRI objects.

As you are using PostGIS I'm assuming that you are just interested in using
vector data?

There is a shp2pgsql program which turns a shpfile into a file of SQL commands
to load into PostGIS. The QGIS package has a plugin which allows you to click
on shapefiles and choose a PostGIS database to load them into. Also the ogr2ogr
program (part of the GDAL suite) converts between various vector formats, and
can convert to/from PostGIS tables, shape and Arc coverage (amongst others).

Then there is avce00 which works with e00 Arc export files, converting then
to/from coverages.

So these are several Open Source packages which support shapefiles and PostGIS,
as well as a way to turn e00 & coverages into shapefiles. 

The Postgres native spatial data types are not compatible AFAIK with PostGIS,
nor are there any conversion tools. I think I have seen this issue raised
before, so trawling the list archives might find you something.

Note that the shapefile spec necessarily loses some topology info, etc from
coverages, and that PostGIS does not really support topology, and only features
defined by coordinate pairs, so circles etc cannot be represented by a point &
radius, but must be renderedr into an arc of coords. Dynamic segmentation &
other capabilities can sort of be implemented with suitable table structures,
but depending on your Arc data you may lose something.  

I'm not expert in this area, but I believe geometries are stored as binary, but
can be extracted as WKT if required.


Brent Wood


> 
> My first idea is using Postgres native geometry types.  The .Net data 
> connector (Npgsql) has support for these built in types.  Are there any 
> PostGIS functions that will convert its types to Postgres geometry 
> types?  I imagine things working sort of like:
> 
> string sql = "SELECT as_native_postgres_box(extent(the_geom)) FROM 
> shape_table";
> NpgsqlCommand cmd = new NpgsqlCommand(sql, con);
> NpgsqlBox box = (NpgsqlBox)cmd.ExecuteScalar();
> 
> The second idea is to just use a third party library to do the parsing 
> for me.  I see there's a java one, but I'm looking for a .Net happy 
> library.
> 
> Also, and this is OT from the subject, but how do you specify to 
> PostGIS whether the geometries are stored as WKT or WKB?  Mine are all 
> WKT and I'm curious in case down the road I want to use WKB.
> 
> Thanks for any help.
> -Abe
> 
> _______________________________________________
> 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