Osmnx error: module 'osmnx.elevation' has no attribute 'add_node_elevations_raster'

Viewed 197
2 Answers

You can include it in your project by reviewing the free Elevation APIs:

As far as I have examined, some of these APIs can work locally, while others serve over the internet. To use one of these APIs in your project, you must be able to create an HttpGet request with Python. If the OSMNX library is keeping you out of this process, you can learn how to make HttpGet request in python programming language by following this link.

For example, the return of the HttpGet request I made depending on a location on the Open Topo Data API is as follows:

import requests
import json

r = requests.get('https://api.opentopodata.org/v1/test-dataset?locations=56,123')

if r.status_code == 200:
   if r.headers['Content-Type'] == 'application/json':
      print(r.text)
      response = r.text.replace("'", '"')
      response = json.loads(response)
      for e in response['results']:
         print('Value of Elevation: ', e['elevation'])

enter image description here

You are using a very old version of OSMnx, released long before that function existed.. Just upgrade to the latest version of the package (v1.1.2 as of this writing) and you'll be good to go.

Related