我试图使用geopandas和python从postgis绘制几何图形,但我没有得到任何东西(没有错误,没有结果)。 这是我正在使用的代码,我错过了什么吗?
import psycopg2
import geopandas as gpd
import matplotlib.pyplot as plt
try:
conn = psycopg2.connect("dbname='strokes' user='postgres' host='localhost' password='admin'")
except:
print "I am unable to connect to the database"
ba = gpd.GeoDataFrame.from_postgis("SELECT ST_AsText(geom) AS wkt, fid_limite, nombassin FROM bassin", conn, geom_col ='geometry', crs={'init': 'epsg:4326'}, coerce_float=True)
conn.commit()
conn.close()
ba.head
ba.plot(column='nombassin', categorical=True, legend=True, figsize=(14,6));
plt.show()