2

I am trying to get elevations from a raster file and add to the road network. I am getting module 'osmnx.elevation' has no attribute 'add_node_elevations_raster' error.

Following this notebook: https://github.com/gboeing/osmnx-examples/blob/main/notebooks/12-node-elevations-edge-grades.ipynb

My osmnx version is '0.16.0' and all other functions have been working.

enter image description here

I don't want to use the add_node_elevations function because requires a google api key and I am looking for a free option.

2 Answers2

0

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

Sercan
  • 4,739
  • 3
  • 17
  • 36
0

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.

gboeing
  • 5,691
  • 2
  • 15
  • 41