Are you able to assist me to for connecting to my postgresql database with python? I have to create graphic interface with python that will visualize shapefile data from the database (i've about 50 polygons in shapefile format for the reason that database). Are you able to assist me to with creating such application? I'm begginer in python.
For interacting using the database, use psycopg2. It's quick, simple and easy , efficient if you're acquainted with fundamental DB concepts.
There are several options came from here. You should use shpUtils, which is designed to be considered a nice package for parsing shapefiles. After that you can visualize the information using numerous python graphics packages, like pil.
Every option suits another need, based on that which you define as "create graphic interface". If you want to produce a simple graphics output, build the polygons from text using among the graphics utilities pointed out above. If you want to produce a professional-searching image, use mapnik (pointed out in certain other solutions), which easily reads shapefiles. If you want to produce a completely functional GUI, it's most likely not really a beginner's task - you can start with programming fundamental GUI programs before diving into shapefiles and polygons.
If, however, you need to simply see the polygons - skip python and merely use qgis, that will effortlessly visualize your polygons. Additionally, it has a number of other nice features, like colors, zooms and so forth.
I'd approach this by breaking up into more compact problems and fixing all of them
a) How do you connect with a postgresql database with python?
http://stackoverflow.com/search?q=postgresql+database+python - Appears like psycopg2 is a great option as Adam Matan recommended.
b) Drawing shapefile data in python
I cant use any software like quantum gis, and that i cant use mapnik, too. It's work for my college. I did not learn how to draw individuals shapefiles in python. I attached to database:
import psycopg2 conn = psycopg2.connect("dbname='***' user='***' host='***' password='***'") print 'Succesfully connected' cur = conn.cursor() cur.execute("""SELECT astext(the_geom) from buildings;""") listpoly = cur.fetchall() conn.close()
I dont understand how to continue. I must use matplotlib.