Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
/ wkbheader Public archive

Python project for manipulating Well Known Binary geometry headers

License

Notifications You must be signed in to change notification settings

MazeMap/wkbheader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated

This repository is no longer maintained and is deprecated. Please be aware that it may not work with the latest versions of its dependencies.


wkbheader

The focus of this library is to facilitate transfer of data between postgis and python geometry libraries that don't support postgis's ewkb (extended well known binary) standard. Specifically it can add and reomve srid values from the wkb header.

Installation

Install via pip

$ pip install wkbheader

or download source and run

$ python setup.py install

Usage

Example usage with shapely

>>> import wkbheader
>>> import psycopg2
>>> import codecs
>>> from shapely.geometry import Point
>>> #Connect to some database and create a geometry table
>>> conn = psycopg2.connect('...')
>>> cursor = conn.cursor()
>>> cursor.execute("CREATE TABLE points (point_geom GEOMETRY(POINT, 4326))")
>>> #Create a point and insert it into table
>>> p = Point(3, 4)
>>> ewkb = wkbheader.set_srid(p.wkb, 4326)
>>> wkbheader.get_srid(ewkb)
4326
>>> hexewkb = codecs.encode(ewkb, 'hex_codec')
>>> cursor.execute("INSERT INTO points (point_geom) values (%s)", (hexewkb, ))

About

Python project for manipulating Well Known Binary geometry headers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages