Want more features on Pastebin? Sign Up, it's FREE!
Guest

geogIssue

By: jakc13 on Nov 15th, 2012  |  syntax: None  |  size: 1.92 KB  |  views: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # some code (missing parts):
  2. conn = pymssql.connect(host='localhost', user='sa', password='xx', database='xx')
  3. conn.autocommit(True)
  4. cur = conn.cursor()
  5.  
  6. # assign some variables like lat and lon
  7.  
  8. geog_type = "geography::STGeomFromText('POINT(%s %s)', 4326))" % (lat, lon)
  9. print geog_type
  10. print type(geog_type)
  11.  
  12. cur.execute("INSERT INTO tweets (x, y, date, geog) VALUES(%s, %s, %s, %s)", \
  13.     (lat, lon, d, geog_type))
  14.  
  15.     conn.close()
  16.  
  17.  
  18. Get the below exception:
  19.  
  20. Error:
  21. geography::STGeomFromText('POINT(144.92037314 -37.74735705)', 4326))
  22. <type 'str'>
  23. Traceback (most recent call last):
  24.   File "C:\Users\sjackson\Dropbox\TwitterWorkings\tweetsucker_SJ_SQLServer.py", line 106, in <module>
  25.     parse_tweet(tweet)
  26.   File "C:\Users\sjackson\Dropbox\TwitterWorkings\tweetsucker_SJ_SQLServer.py", line 66, in parse_tweet
  27.     (clean_text, lat, lon, lan, d, int(swearing), geog_type))
  28.   File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
  29.     raise OperationalError, e[0]
  30. OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
  31. A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
  32. System.FormatException: 24114: The label geography::STGeomFro in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only).
  33. System.FormatException:
  34.    at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
  35.    at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
  36.    at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
  37.    at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
  38.    at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
clone this paste RAW Paste Data