I have imported a point shapefile called site_locations.shp into a personal geodatabase. Now I'm trying to retrieve the data from the database using SQL:
dbpath = os.path.normpath(r'../geodata/site_locations.mdb') #<br> msacon = pypyodbc.win_connect_mdb(dbpath) #<br> msacur = msacon.cursor() #<br> sqlstr = "SELECT ID, Shape, Notes FROM site_locations" #<br> msacur.execute(sqlstr) #<br> rows = msacur.fetchall() #<br>
I did the same with a sqlite database and I got the geometry in the so-called well known binary format (WKB). I was able to convert that WKB to well known text (WKT) and then to objects with x and y values. Apparently the field Shape does not contain data in WKB format, but in GeomSHP format. Is there a way in Python to convert this GeomSHP to WKB or so? I understand that some spatial databases have a function called CGeomWKB. Is there a Python implementation?