Luke, Albert: Thanks.. yes I'm thinking re is what I need... and using negative values for west, and positive for east is our convention. The problem I have is that not all the data was provided in that format, so I'm in the process of converting...
There are a number of problems with my original post. For one, the conversion to decimal fails if given a negative number (i.e. -9 30' in my approach becomes 8.5 when it should be 9.5). So, to get around that I need to use abs, and add some if cases to convert it back to negative.. Anyway, still working through this... On 7/11/07, Albert Weiss <[EMAIL PROTECTED]> wrote:
John: One way to handle the situation of longitude is to make everything west of the Greenwich meridan a negative value until -180 degrees and everything east of Greenwich a positive value. HTH. Albert *John <[EMAIL PROTECTED]>* Sent by: [EMAIL PROTECTED] 07/10/2007 04:22 PM To tutor@python.org cc Subject [Tutor] An interesting case... of east vs. west I was trying to read in a tab delimited file i was given with lat and lon, the thing is I needed decimal lat, and decimal long... well, anyway I think you can see what my problem was: for i in range(0,344) y=d[i][2].split('\xb0') x=d[i][3].split('\xb0') ydeg,ymin=y[0].strip(),y[1].rstrip('\' N').rstrip("\' S") xdeg,xmin=x[0].strip(),x[1].rstrip("\' E").rstrip("\' W") if re.search('\ZW','x[1]') xmin=-1*xmin if re.search('\ZS','y[1]') ymin=-1*ymin declat=int(ydeg)+(float(ymin)/60) declon=int(xdeg)+(float(xmin)/60) The thing is, it isn't terribly robust (I'm not even positive it's working correctly!!). For instance, as you might have guessed I was given Lat and Lon in the following format: STNA 45° 49' N 08° 38' E STNB 46° 58' 19° 33' E STNC 53°33' -9°54' STND 51°32' N 12°54' W Some indicating north or some, and some not. This wasn't a concern, as I knew they were all North. However, the West / East issue is another story. Anyone have a more elegant solution? -john _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
-- Configuration `````````````````````````` Plone 2.5.3-final, CMF-1.6.4, Zope (Zope 2.9.7-final, python 2.4.4, linux2), Five 1.4.1, Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat 4.1.1-51)], PIL 1.1.6
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor