[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Formatting strings to coordinates



Simon de Vet wrote:
> 
> The data analysis adventure continues... I have read in the data, and am
> now working on the various plots.
> 
> I have a string array, taken from the text file, of coordinates.
> However, they are in the form "43.92°S" ,and "176.50°W".
> 
> I would like to be able to take this array of strings and convert it to
> a numerical array or real latitudes and longitudes, from -90 to 90 and 0
> to 360 so that they can eventually be plotted onto a globe.
> 
> I've figured out how to use strings to generate numerical values (ie:
> 'Jan' -> 1, 'Feb' -> 2, etc..), but not how to handle parts of strings
> to modify the other parts.
> 
> Any suggestions? This group has been a major help so far!
> 
> Thanks,
> 
> Simon


For example...

   lat1 = ['43.92°S', '43.92°N', '43.92°S', '43.92°N'] 
   lat2 = (-2 * (strpos(lat1, 'S') ge 0) + 1) * float(lat1)


-- 

Andrew Loughe **********************************************************
NOAA/FSL/AD   Mailstop: R/FS5  *              Email: loughe@fsl.noaa.gov
325 Broadway                   *  Web: www-ad.fsl.noaa.gov/users/loughe/
Boulder, CO  80303             *  Phn/Fax: (303)497-6211 / (303)497-6301