[postgis-users] pyshapelib + PostGIS

Richard Taylor r.taylor at bcs.org.uk
Mon Jun 7 00:18:15 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have not used the shapelib package but... 

You might find the GeoTypes package (http://people.initd.org/rjt/) in 
partnership with the psycopg database adapter 
(http://www.initd.org/software/initd/psycopg) could provide a good framework 
for what you are trying to do.

GeoTypes contains parsers for both the WKT and WKB formats. Psycopg supports 
customizable type maps.

Regards

Richard

On Friday 28 May 2004 21:04, Daryl Herzmann wrote:
> Hiya,
>
> A bit of information here for those wanting to get PostGIS geometries into
> something pyshapelib can use.  This is a hack and probably the wrong way
> of doing it, but it works for me :)
>
> First I grabbed the wellknowntext.py library from Thuban.
>
> http://www.intevation.de/cgi-bin/viewcvs-thuban.cgi/thuban/Thuban/Model/wel
>lknowntext.py
>
> Then in my python code, I can do this
>
> import wellknowntext, shapelib, pg
> mydb = pg.connect("postgis")
>
> rs = mydb.query("SELECT geom from my_fancy_geometry_table").dictresult()
> for i in range(len(rs)):
>   geom = rs[i]["geom"]
>   pts = wellknowntext.convert_well_known_text(geom)
>   # Assuming we have a polygon!
>   obj = shapelib.SHPObject(shapelib.SHPT_POLYGON, 1, pts)
>
>
> And that seems to work.  I am sure others have better ways, but googling
> around, I didn't seem to find anything for my question "How to get WKT
> into pyshapelib?"  <-- Find this google!  :)
>
> Have a good weekend all!
>
> later,
>   daryl
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

- -- 
Jabber: RichardTaylor at jabber.org
PGPKey: http://search.keyserver.net:11371/pks/lookup?op=get&search=0xA7DA9FD9
Key fingerprint = D051 A121 E7C3 485F 3C0E  1593 ED9E D868 A7DA 9FD9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAxBa87Z7YaKfan9kRAiPrAJ9K3pGc5cVqXUm63YZTmfXCiMiDWQCcDqSQ
SS42zmwxAEV+4qTMKAGv/TA=
=+uqI
-----END PGP SIGNATURE-----



More information about the postgis-users mailing list