0

I have found code which returns a single lat long point, but it takes about 1s per point. I would like to get an altitude map of an area between 2 sets of lat/lon coords. Ideally not with the googleapi because that requires a key.

My code (which I stole from another post) that gets a single lat/lon point:

import requests
import urllib
import pandas as pd

# USGS Elevation Point Query Service
url = r'https://nationalmap.gov/epqs/pqs.php?'

# coordinates with known elevation 
lat = [48.633, 48.733, 45.1947]
lon = [-93.9667, -94.6167, -93.3257]

# create data frame
df = pd.DataFrame({
    'lat': lat,
    'lon': lon
})

def elevation_function(df, lat_column, lon_column):
      """Query service using lat, lon. add the elevation values as a new column."""
      elevations = []
      for lat, lon in zip(df[lat_column], df[lon_column]):

          # define rest query params
          params = {
              'output': 'json',
              'x': lon,
              'y': lat,
              'units': 'Meters'
          }

          # format query string and return query value
          result = requests.get((url + urllib.parse.urlencode(params)))
          elevations.append(result.json()['USGS_Elevation_Point_Query_Service']['Elevation_Query']['Elevation'])

      df['elev_meters'] = elevations

elevation_function(df, 'lat', 'lon')
print(df)
df.head()

Which returns:

       lat      lon  elev_meters
0  48.6330 -93.9667       341.14
1  48.7330 -94.6167       328.80
2  45.1947 -93.3257       262.68

How would I get an altitude map? Not using this because this takes way too long.

Yetiowner
  • 123
  • 8
  • 1
    This might be a better fit for gis.stackexchange.com. Google SRTM or, if you are in the EU, EU-DEM. – Ture Pålsson Feb 13 '22 at 17:56
  • Thx for the help! I have a couple of questions: 1: How close are the samples to each other? 2: How accurate is the elevation data? Ideally accurate to a meter. I am using this to recognize small buildings by their height, so it should be suitably accurate. – Yetiowner Feb 14 '22 at 11:40
  • 1
    I can't remember the sample density, but it's somewhere between ten and a hundred meters between samples, so I'm afraid you are not going to be recognising small buildings from either of those datasets. (Actually, the EU-DEM being, I think, mostly SRTM data, it's only really one dataset.) In some corners of the world, you can get laser-scan point clouds with a resolution down to the one-meter level. Judging by your coordinates, you're in the US and googling "USGS LIDAR" turns up [this](https://www.usgs.gov/faqs/what-lidar-data-and-where-can-i-download-it). – Ture Pålsson Feb 14 '22 at 12:41
  • Honsetly those coords came with the code. Mine will have to work with any coords. Honestly, might just use the cv2 stereo with 2 different satelite images. Thx for help tho! – Yetiowner Feb 14 '22 at 15:15

0 Answers0