# Calculating terrain slope

Having a set of elevation measurements along with coordinates, I am looking for a way to calculate the slope (the main goal is to determine the locations where the precipitation water might be accumulating).

Below is the spatial representation of elevation measurements.

Currently, the data is stored in geopandas geodataframe:

``````geometry   elevation
0  POINT (444074.373 5015092.886)  115.878394
1  POINT (444077.429 5015096.181)  115.882280
2  POINT (444080.462 5015099.465)  115.884228
3  POINT (444083.479 5015102.716)  115.884434
4  POINT (444086.449 5015105.989)  115.882674
....
``````

I have tried to manually calculate the differences between the neighboring points but the logic that has to take into account the azimuth between the nearest point is quite complex. Therefore, I am looking for a simpler way to implement the logic, possibly using any existing function or library.

Can you suggest a library or approach to calculate the terrain slope given the elevation measurements?

OPTION 1: Use GDAL + shell

``````gdaldem slope input.tif output.tif -compute_edges
``````

OPTION2: GDAL + Python + Shell

``````from osgeo import gdal
import subprocess
code = "gdaldem slope input.tif output.tif -compute_edges"
subprocess.call(code.split())
``````

OPTION 3: GDAL + Python

``````from osgeo import gdal
dem_input = gdal.Open("input.tif)
gdal.DEMProcessing('output.tif', dem_input, "slope", computeEdges=True)
``````