Parse coordinate strings in various formats (MGRS, UTM/UPS, DMS, decimal) and return latitude/longitude.

geocoords_parse(x)

Arguments

x

Character vector of coordinate strings to parse

Value

Data frame with columns:

  • lat - Latitude in degrees

  • lon - Longitude in degrees

  • zone - UTM/UPS zone number

  • northp - Logical, TRUE if in northern hemisphere

  • easting - UTM/UPS easting in meters

  • northing - UTM/UPS northing in meters

Details

Accepts coordinates in multiple formats:

  • MGRS: "33TWN0500049000"

  • UTM/UPS: "33N 505000 4900000"

  • DMS: "40d26'47\"N 74d0'21\"W"

  • Decimal: "40.446 -74.006"

Examples

# Parse MGRS
geocoords_parse("33TWN0500049000")
#>        lat      lon zone northp  easting northing
#> 1 47.39444 15.06626   33   TRUE 505000.5  5249000

# Parse UTM
geocoords_parse("33N 505000 4900000")
#>        lat      lon zone northp easting northing
#> 1 44.25322 15.06263   33   TRUE  505000  4900000

# Parse DMS
geocoords_parse("40d26'47\"N 74d0'21\"W")
#>        lat       lon zone northp  easting northing
#> 1 40.44639 -74.00583   18   TRUE 584307.3  4477778

# Parse decimal
geocoords_parse("40.446 -74.006")
#>      lat     lon zone northp  easting northing
#> 1 40.446 -74.006   18   TRUE 584293.6  4477735

# Vectorized
geocoords_parse(c("33TWN0500049000", "40.446 -74.006"))
#>        lat       lon zone northp  easting northing
#> 1 47.39444  15.06626   33   TRUE 505000.5  5249000
#> 2 40.44600 -74.00600   18   TRUE 584293.6  4477735