[postgis-users] WKB Geometry Column

Stephen Woodbridge woodbri at swoodbridge.com
Thu Mar 17 13:50:54 PST 2005


Paul,

Great, explanation, as I'm sitting here about to start loading a bunch 
of shapefiles myself.

I have follow up questions.
What applications on the client side use the WKB format now?
Where is the WKB format documented?
As I think it would make sense to build a PHP and Perl Class the can 
parse the WKB into data structures if they don't already exist. Do these 
already exist?

-Steve

Paul Ramsey wrote:
> Sean,
> 
> You are confusing storage format with inout/output format. No matter how 
> you get data *into* postgis, it will be stored the same way, using the 
> same internal structure. You have three choices for getting data into 
> and out of postgis:
> 
> - Use the "canonical format". This is a string representation of the 
> internal format. It might change, if we want to change the internal 
> format. It currently looks a lot like WKB, but it is not. You can see 
> the canonical format by going "select geom_column from geom_table".
> - Use WKT. This is a human readable form of the geometry, using numbers 
> and brackets and whatnot.  You can see the WKT format by going "select 
> astext(geom_column) from geom_table".
> - Use WKB. This is a computer readable form of hte geometry, a 
> byte-stream.  You can see the canonical format by going "select 
> asbinary(geom_column) from geom_table".
> 
> The only thing that is "faster" about WKB is your handling of it on the 
> client side. It is much faster for client software to parse the 
> byte-stream than it for it to parse WKT. PostGIS itself will not have 
> noticably different performance if you use WKB or WKT on output.
> 
> Paul
> 
> Sean M. Montague wrote:
> 
>> I figured out how to insert GeomFromWKB, which makes me realize that I
>> may be misunderstanding WKB.  My interest in postGIS is for creating SVG
>> and I'm transitioning from an Avenue/ArcObjects background to web based
>> implementation utilizing SVG, PHP, and hopefully postGIS.  I admit my
>> knowledge of databases is lacking.  Previously I used MySQL, which is a
>> lot easier to find answers to questions that I, as a novice to
>> intermediate database user, have.  I try to avoid posting a question
>> unless my search for an answer has turned up nothing.  I have come a
>> long way, but I'm still trying to grasp conceptually what is going on in
>> PostGIS.  What I don't get is how to utilize the WKB ability of postGIS.
>> I read that shp2pgsql will insert as WKB, but after much searching, I
>> have failed in figuring out how.  Where I read this didn't say how.
>> Below is what I have figured out so far.  I extracted a poly from the
>> database asBinary(geom) and printed it out into my SVG file.  I then
>> viewed source and copied the poly binary string and placed it into the
>> insert statement which worked, but the resulting geom in the new table
>> is WKT, or what I believe to be WKT. 
>> INSERT INTO table1 (the_geom)
>> VALUES
>> (GeomFromWKB('01060000000100000001030000000100000005000000000000C0331E59
>> C100000080D0874DC1000000C0331E59C1000000C0D42D58410000000053085041000000
>> C0D42D5841000000005308504100000080D0874DC1000000C0331E59C100000080D0874D
>> C1',32767));
>>
>> In the database, the above Insert creates a table where the geom is
>> stored identically as if I had inserted with WKT.  What is it that I
>> don't know about WKB?  I understand that WKB is faster, which explains
>> my interest in it.  I thought that it would be stored as binary in the
>> database.  Any insight would help.
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> _______________________________________________
> 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