: deg = str2angle (txt)
: deg = str2angle (txt, verbose)

Convert string type angular coordinates into numerical decimal degrees.

txt can be a txt string or cellstr array containing one or more strings each representing an angular coordinate (latitude and/or longitude). str2angle is quite picky as regards input formats, see below.

If optional input argument verbose is set to 1 or true, str2angle will warn if the input cntains strings that couldn’t be converted. The default value is false (no warnings).

Output argument deg contains an 1xN array of numerical degree value(s. Unrecognizable input strings are either ignored or, if looking almost recognizable, set to NaN in the output.

The angular strings should look like:

  • an integer number comprising one to three leading digits (degrees), maybe preceded by a plus or minus character;
  • one of a ’degree’ character or even a ’D’, ’E’, ’W’, ’N’ or ’S’ (capitalization ignored) optionally followed by a space. In case of a ’W’, ’w’, ’S’ or ’s’ character (western or southern hemisphere, resp.) the corresponding output value will be negated;
  • a positive integer number comprising exactly two digits (minutes) immediately followed by either an apostroph (’) or ’M’ or ’m’ character, optionally followed by a space;
  • a positive integer or real number (seconds), immediately followed by either a ’"’ character (double quote), or an ’s’ or ’S’ character, or two consecutive single quote characters (”);
  • optionally, a character ’E’, ’N’, ’S’ or ’W’ indicating the hemisphere.

So-called packed DMS and degrees/minutes/seconds separated by hyphens or minus signs are not accepted.

So, angular degree strings may look like e.g.:

191E21'3.1",      12e 22'33.24",    13E 23' 33.344",
14w24' 33.4444",  15S25'33.544",    -16W26'33.644444'',
17s27'33.74444",  18N28'33.844",    +19d29m33.944444s,
20D20M33.0444Se,  21°51'4.1",       22°52'44.25",
23° 53'33.34",    24°54' 33.44N",    25° 55' 33.544",
26°56'33.644''S,   27°57' 33.744'',  28°58'33844"w.

Note: the regular expression used to parse the input strings can be fooled. In particularly bad cases it may loose track completely and give up, angle2str returns an empty scalar Inf value then to distinguish from partly convertible inputs.

See also: angl2str.

Package: mapping