Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 27th, 2012  |  syntax: None  |  size: 0.45 KB  |  hits: 7  |  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. Splitting a GPS Point into Latitude and Longitude Regular
  2. (40.714353, -74.005973)
  3.        
  4. >>> str = "(40.714353, -74.005973)"
  5. >>> tuple(float(x) for x in str.strip('()').split(','))
  6. (40.714353, -74.005973)
  7.        
  8. >>> import re
  9. >>> m = re.match(r"^(([-d.]+), ([-d.]+))$", str)
  10. >>> m.group(1)
  11. '40.714353'
  12. >>> m.group(2)
  13. '-74.005973'
  14.        
  15. >>> import ast
  16. >>> coord = "(40.714353, -74.005973)"
  17. >>> ast.literal_eval(coord)
  18. (40.714353000000003, -74.005972999999997)