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[0]).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.

closed as unclear what you're asking by PolyGeo Jun 17 '17 at 10:41

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. – Midavalo May 31 '17 at 17:10
  • 1
    Could you please edit your question to include a bit more of your code around the line wkt = (df.loc[1]... - what is it looking at, is it a list or dictionary containing the values you show above? Also what is your entire error message? – Midavalo May 31 '17 at 17:12
  • Are you able to present the data for a triangle located in Somalia, and a code snippet that applies your process to it successfully or otherwise? I suggest using a triangle because three points should be something you can use to show us the data for an entire feature. – PolyGeo Jun 17 '17 at 10:41

Browse other questions tagged or ask your own question.