hyriver / py3dep

A part of HyRiver software stack for getting topography data within the US through 3D Elevation Program (3DEP)
https://docs.hyriver.io
Other
42 stars 7 forks source link

slope function returns integer #70

Closed gutabeshu closed 5 months ago

gutabeshu commented 5 months ago

What happened?

when extracting slope with huc12 geometry, slope_ = py3dep.get_map("Slope Degrees", geometry, resolution=30) returns only in integers. see attached plot (please ignore the red dots on the plot, they are quantile values and intended for unrelated purposes) slope_hs

What did you expect to happen?

expected a float

Minimal Complete Verifiable Example

No response

MVCE confirmation

Relevant log output

No response

Anything else we need to know?

No response

Environment

<py3dep 0.16.2>

cheginit commented 5 months ago

Can you please try this and compare with what you have?

import py3dep
import xrspatial

dem10 = py3dep.get_dem(geom, 10, gem_crs)
slope30 = xrspatial.slope(dem10).coarsen(x=3, y=3, boundary="trim").mean()

Note: You can install xrspatial with micromamba install -c conda-forge xarray-spatial

gutabeshu commented 5 months ago

This produces slope as expected, in this case the returned 2d data format isdtype=float32. In the earlier case it was dtype=uint8. slope

cheginit commented 5 months ago

Ok, the values are in the same range. The issue is most likely due to using 30 m resolution. I think the underlying data source at 30 m resolution does not have enough accuracy to require saving the results in float. So, since integers take much less storage, the data is usually stored in int format.

I typically get the DEM at 10 m resolution, even if I don't need that much accuracy, then upscale it (coarsen) to the desired resolution. If your area of interest is huge, you can try using py3dep.get_dem_vrt function. You can then compute other topo features using xrspatial.