Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert an angle into a customizable degree-minute-second string
ResourceFunction["GeneralizedDMSString"][θ] converts the angle θ in decimal degrees to a DMS string. | |
ResourceFunction["GeneralizedDMSString"][θ,form] converts the angle θ in decimal degrees to a form string. | |
ResourceFunction["GeneralizedDMSString"][{lat,lon}] converts latitude lat and longitude lon in decimal degrees to a DMS latitude-longitude string. | |
ResourceFunction["GeneralizedDMSString"][{lat,lon},form] converts latitude lat and longitude lon in decimal degrees to a form latitude-longitude string. | |
ResourceFunction["GeneralizedDMSString"][GeoPosition[{lat,lon}],form] converts a GeoPosition to a form latitude-longitude string. |
"DegreeMinuteSecond" or "DMS" or Automatic | forms a string with degrees, minutes and seconds |
"DegreeMinute" or "DM" | forms a string with degrees and minutes |
"Degree" or "D" | forms a string with degrees |
"DMSSymbols" | Automatic | symbols to use for degree, minute and seconds |
"CardinalSymbols" | "NESW" | cardinal symbols to use |
"CardinalPosition" | After | location of the cardinal symbols with respect to the numbers |
"LeadingDigits" | None | number of digits before the period, padded with zeros on the left |
"Precision" | Automatic | number of digits after the period for the last number |
"Separators" | Automatic | separators to use between degrees, minutes and seconds parts and between the latitude and longitude parts |
Automatic or True | uses ° for degrees, ' for minute and " for seconds |
s | uses s for degrees, minutes and seconds |
{d} | uses d for degrees and nothing for minutes and seconds |
{d,m} | uses d for degrees, m for minutes and nothing for seconds |
{d,m,s} | uses d for degrees, m for minutes and s for seconds |
None or False | uses no symbols |
"NESW" or Automatic or True | "N" for north, "E" for east, "S" for south, "W" for west |
"NorthEastSouthWest" | "North" for north, "East" for east, "South" for south, "West" for west |
"NE" | "N" for latitude, "E" for longitude; signs are used to indicate south and west |
"NorthEast" | "North" for latitude, "East" for longitude; signs are used to indicate south and west |
{n,e} | uses n for latitude, and e for longitude; signs are used to indicate south and west |
{{n,s},{e,w}} | uses n for north, s for south, e for east, w for west |
None or False | uses no cardinal symbols; signs are used to indicate the hemispheres |
Before | cardinal symbols are placed before the degrees, minutes and seconds |
After | cardinal symbols are placed after the degrees, minutes and seconds |
n | uses n digits for the degrees in the latitude and the longitude |
{n} | uses n digits for the degrees in the latitude and the longitude |
{n,m} | uses n digits for the degrees and m for the minutes |
{n,m,o} | uses n digits for the degrees, m for the minutes and o for the seconds |
False or None | uses no leading zeros |
True or Automatic | uses two digits for the degree part of the latitude and three for the degree part of the longitude |
{{nlat,nlon},{mlat,mlon},{olat,olon}} | specification for the general case for the degrees, minutes and seconds for both the latitude and the longitude |
Automatic or True | uses six digits for the form "Degree", four digits for the form "DegreeMinute" and three for the form "DegreeMinuteSecond" |
n | uses n digits for the last number of both the latitude and the longitude |
{nlat,nlon} | uses nlat digits for the last number of the latitude and nlon for the last number of the longitude |
Automatic or True | uses no separator for degree, minute and seconds and a space to separate the latitude and longitude |
s | uses s to separate the degree, minute and seconds and the latitude and longitude parts |
{s} | uses s to separate the degree, minute and seconds and the latitude and longitude parts |
{s1,s2} | uses s1to separate the degree, minute and seconds and s2 for the latitude and longitude parts |
None or False | uses no separators |
Convert an angle in a DMS string:
In[1]:= | ![]() |
Out[1]= | ![]() |
Convert a latitude-longitude pair:
In[2]:= | ![]() |
Out[2]= | ![]() |
Convert to a string with degrees and minutes:
In[3]:= | ![]() |
Out[3]= | ![]() |
Convert to a string with only degrees:
In[4]:= | ![]() |
Out[4]= | ![]() |
Use a GeoPosition:
In[5]:= | ![]() |
Out[5]= | ![]() |
Convert only a latitude into a DMS string:
In[6]:= | ![]() |
Out[6]= | ![]() |
Convert only a longitude into a DMS string:
In[7]:= | ![]() |
Out[7]= | ![]() |
Use different symbols for degrees, minutes and seconds:
In[8]:= | ![]() |
Out[8]= | ![]() |
Use no symbols for degrees, minutes and seconds:
In[9]:= | ![]() |
Out[9]= | ![]() |
Use the default symbols for degrees, minutes and seconds:
In[10]:= | ![]() |
Out[10]= | ![]() |
Use no cardinal indicators:
In[11]:= | ![]() |
Out[11]= | ![]() |
Use N for the latitude and E for the longitude; signs indicate the hemisphere:
In[12]:= | ![]() |
Out[12]= | ![]() |
Signs are removed and replaced by the proper cardinal direction:
In[13]:= | ![]() |
Out[13]= | ![]() |
Use the standard four cardinal directions written fully out:
In[14]:= | ![]() |
Out[14]= | ![]() |
Use custom cardinal directions:
In[15]:= | ![]() |
Out[15]= | ![]() |
Use a custom specification where the sign is retained:
In[16]:= | ![]() |
Out[16]= | ![]() |
Place the cardinal symbols before the degrees, minutes and seconds:
In[17]:= | ![]() |
Out[17]= | ![]() |
Place the cardinal symbols after the degrees, minutes and seconds:
In[18]:= | ![]() |
Out[18]= | ![]() |
Use 3 digits for degrees:
In[19]:= | ![]() |
Out[19]= | ![]() |
Use 3 digits for degrees and 2 for minutes:
In[20]:= | ![]() |
Out[20]= | ![]() |
Use 3 digits for degrees, 2 for minutes and 2 for seconds:
In[21]:= | ![]() |
Out[21]= | ![]() |
Use different specifications for the latitude and longitude:
In[22]:= | ![]() |
Out[22]= | ![]() |
Use 5 digits for the last number (in this case, the seconds):
In[23]:= | ![]() |
Out[23]= | ![]() |
Use 3 digits for the last number (in this case, the minutes):
In[24]:= | ![]() |
Out[24]= | ![]() |
Use underscores between degrees, minutes, seconds, latitude and longitude:
In[25]:= | ![]() |
Out[25]= | ![]() |
Use commas between degrees, minutes and seconds, and an underscore between the latitude and longitude:
In[26]:= | ![]() |
Out[26]= | ![]() |
Use no separators:
In[27]:= | ![]() |
Out[27]= | ![]() |
Make a function that produces a string generally used in geocaching:
In[28]:= | ![]() |
Apply this function to a location:
In[29]:= | ![]() |
Out[29]= | ![]() |
For a latitude-longitude pair, and without any options, GeneralizedDMSString gives the same output as DMSString:
In[30]:= | ![]() |
Out[31]= | ![]() |
In[32]:= | ![]() |
Out[32]= | ![]() |
GeneralizedDMSString keeps the sign, as opposed to DMSString:
In[33]:= | ![]() |
Out[33]= | ![]() |
In[34]:= | ![]() |
Out[34]= | ![]() |
Exact values are approximated using N:
In[35]:= | ![]() |
Out[35]= | ![]() |
Do not show the zeros behind the period:
In[36]:= | ![]() |
Out[36]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License