def ParseLatLonFromNedFile(fname):
  """Parses the latitude and longitude from a NED DEM tile.

  Currently two different formats exist on the server. They look like the
  following examples:
    floatn34w086_xxx          Filename format used prior to 2015
    usgs_ned_1_n34w086_xxx    Filename format used since 2015

  Inputs:
    fname: filename of a NED DEM tile.

  Returns:
    a tuple of (lat, lon) being the North-West corner of that tile.
  """
  if fname[0].lower() == 'f':
    lat = int(fname[6:8])
    lon = int(fname[9:12])
    if fname[5].lower() == 's':
      lat = -lat
    if fname[8].lower() == 'w':
      lon = -lon
  elif fname[0].lower() == 'u':
    lat = int(fname[12:14])
    lon = int(fname[15:18])
    if fname[11].lower() == 's':
      lat = -lat
    if fname[14].lower() == 'w':
      lon = -lon
  else:
    lat = 0
    lon = 0

  return lat, lon