Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_map("Slope Degrees") returns all 90's unless projected crs is specified #73

Open
3 tasks done
speleophysics opened this issue Nov 15, 2024 · 1 comment
Open
3 tasks done
Labels
bug Something isn't working

Comments

@speleophysics
Copy link

speleophysics commented Nov 15, 2024

What happened?

When I retrieve the Slope Degrees map for a specified bounding box, it returns all 90 (or 255/nan) values. This seems to be fixed if I specify a crs of 5070.

What did you expect to happen?

I expected to get the correct slope values, regardless of crs.

Minimal Complete Verifiable Example

import matplotlib.pyplot as plt
import py3dep

xmin = -92.66 #Longitude of southwest corner of the box
ymin = 36.07  #Latitude of southwest corner of the box
xmax = -92.53 #Longitude of northeast corner of the box
ymax = 36.21  #Latitude of northeast corner of the box
bbox = (xmin,ymin,xmax,ymax)

rush_creek_area_slope = py3dep.get_map("Slope Degrees", bbox, resolution=10)
rush_creek_area_slope.plot(cmap = 'magma')
plt.axis('equal')
plt.title('Slope')
plt.show()

plt.hist(rush_creek_area_slope.data.ravel())

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

No response

Anything else we need to know?

Note that this behavior is new compared to one year ago, when my code worked (this code is used in a class lab exercise).

I pasted outputs of the plots created by code above here, as I wasn't sure they would work in the log output cell.

download

download

Environment

SYS INFO -------- commit: None python: 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 16:05:46) [GCC 13.3.0] python-bits: 64 OS: Linux OS-release: 5.15.0-122-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8')

PACKAGE VERSION

async-retriever 0.18.0
pygeoogc 0.18.0
pygeoutils 0.18.0
py3dep 0.18.0
pynhd 0.18.0
pygridmet 0.18.0
pydaymet 0.18.0
hydrosignatures 0.18.0
pynldas2 0.18.0
pygeohydro 0.18.0
aiohttp 3.10.10
aiohttp-client-cache 0.12.4
aiosqlite 0.20.0
cytoolz 1.0.0
ujson 5.10.0
defusedxml 0.7.1
joblib 1.4.2
multidict 6.1.0
owslib 0.32.0
pyproj 3.7.0
requests 2.32.3
requests-cache 1.2.1
shapely 2.0.6
url-normalize 1.4.3
urllib3 2.2.3
yarl 1.17.1
geopandas 1.0.1
netcdf4 1.7.1
numpy 2.0.2
rasterio 1.4.2
rioxarray 0.17.0
scipy 1.14.1
xarray 2024.10.0
click 8.1.7
pyflwdir N/A
networkx 3.4.2
pyarrow 18.0.0
folium 0.18.0
h5netcdf 1.4.1
matplotlib 3.9.2
pandas 2.2.2
numba 0.60.0
bottleneck N/A
py7zr 0.22.0
pyogrio 0.10.0

@speleophysics speleophysics added the bug Something isn't working label Nov 15, 2024
@cheginit
Copy link
Collaborator

Thanks for reporting the issue! I can confirm that this is a server side issue. I will reach out to the USGS's 3DEP team and let them know. In the meanwhile, I recommend using xarray-spatial or pywbt for computing slope.

import matplotlib.pyplot as plt
import py3dep
import xrspatial as xrs

xmin = -92.66 #Longitude of southwest corner of the box
ymin = 36.07  #Latitude of southwest corner of the box
xmax = -92.53 #Longitude of northeast corner of the box
ymax = 36.21  #Latitude of northeast corner of the box
bbox = (xmin,ymin,xmax,ymax)

s = xrs.slope(py3dep.get_dem(bbox, 10).rio.reproject(5070))
s.plot(cmap = 'magma')
plt.axis('equal')
plt.title('Slope')

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants