I am working with a database containing a geography field representing the Admin1 boundaries of countries. I would like to draw a map of the Admin1 boundaries of Somalia:
params = urllib.quote_plus(...) engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params) query = ("SELECT SimplifiedCoords.STAsText() FROM Adm1GeoBoundaries WHERE (Adm0Code = '226')") df = pd.read_sql(query,engine)
this returns a list of the 18 subdivisions, e.g.:
0 POLYGON ((44.661 3.2516, 44.611 3.2715, 44.410... 1 POLYGON ((49.0611 9.571, 48.561 9.541, 48.061 ... 2 POLYGON ((44.2362 10.4724, 44.2021 10.5066, 44...
Each row is a pandas series instance. My issue now is to convert these into json then shapefiles in order to map them (using arcpy). So far I have tried (I only focus on one polygon to test):
wkt = (df.loc).to_string() # as loads() expects integer or string adress g1 = loads(wkt)
But this throws : "ParseException: Expected number but encountered word: '44.410...' and the Error is "ReadingError: Could not create geometry because of errors while reading input.".
I also tried the following:
sr = arcpy.SpatialReference(4326) g1 = arcpy.FromWKT(wkt,sr)
But this has not led me anywhere yet.