0

I'm trying to execute the following to get all buildings within Manhattan in Python on Google Colab

tags = {
    'building': True
}

# Geocode the location to get its geometries
ft = ox.geocode_to_gdf('Manhattan Island')

# Extract the polygon geometry from the GeoDataFrame
polygon_geometry = ft.geometry.iloc[0]

# Retrieve features within the polygon with specified tags
buildings_net = ox.features_from_polygon(polygon_geometry, tags=tags)

for some reason, I get this error

TimeoutError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length) 536 try: --> 537 response = conn.getresponse() 538 except (BaseSSLError, OSError) as e:

23 frames TimeoutError: The read operation timed out

The above exception was the direct cause of the following exception:

ReadTimeoutError Traceback (most recent call last) ReadTimeoutError: HTTPSConnectionPool(host='overpass-api.de', port=443): Read timed out. (read timeout=180)

During handling of the above exception, another exception occurred:

ReadTimeout Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 530 raise SSLError(e, request=request) 531 elif isinstance(e, ReadTimeoutError): --> 532 raise ReadTimeout(e, request=request) 533 elif isinstance(e, _InvalidHeader): 534 raise InvalidHeader(e, request=request)

ReadTimeout: HTTPSConnectionPool(host='overpass-api.de', port=443): Read timed out. (read timeout=180)

I was initially trying to do the following (which does work), you need to specify the distance since it seems to only get by default a 100. I just was to get all the buildings in the region by itself without needing to specify a distance.

tags = {
    'building': True
}
# need to change this distance to capture the entire city
building_network = ox.features_from_address('Manhattan Island', tags, dist=3000)

Is there a way to go around this timeout error?

1 Answer 1

0

You'll want to adjust the requests_timeout setting. See the docs: https://osmnx.readthedocs.io/en/stable/user-reference.html#module-osmnx.settings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.