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

Export an elevation profile from a Raster along a Vector line. #591

Open
Falawiss opened this issue Jul 3, 2024 · 2 comments
Open

Export an elevation profile from a Raster along a Vector line. #591

Falawiss opened this issue Jul 3, 2024 · 2 comments
Labels
enhancement Feature improvement or request

Comments

@Falawiss
Copy link

Falawiss commented Jul 3, 2024

Is your feature request related to a problem? Please describe.
This is not related to a problem, but it is a feature that I have developed for myself after searched for an existing solution in other libraries.

Describe the solution you'd like
I want to trace Line, Polyline or MultiLines on a Vector file. Then import this file (gu.Vector) and export all the encountered values where theses lines cross a Raster. Then we can plot theses profiles along a distance array. See this example :

import matplotlib.pyplot as plt
import geoutils as gu
profiles_axis = gu.Vector('profiles_axis.gpkg')
raster = gu.Raster('raster.tif')

distances, profiles = raster.extract_profile(profiles_axis)

for i in range(len(distances)) : 
    plt.plot(distances[i], profiles[i])
plt.show()

Describe alternatives you've considered
In my project I use start and end points, to select Rasters values over the segment delimited by these two points.

Additional context
An example of the profiles that I have traced on few DEMs along 2 tracks. These two tracks are defined by a starting and ending point, extracted from a gu.Vector file using

profiles_axis_gpkg = gu.Vector('profiles_axis.gpkg')
for line in profiles_axis_gpkg.ds.geometry :
        coords = list(line.coords)

See an example result :
Profils_fortes-pentes_Ossoue

@Falawiss Falawiss added the enhancement Feature improvement or request label Jul 3, 2024
@adehecq
Copy link
Member

adehecq commented Jul 3, 2024

Hi,
I agree, this would be a useful functionality that many people would use. This would not be too complicated to implement, using our point interpolation.

If you feel like making a contribution to the code, feel free to submit a pull request 😉 Otherwise, we'll look into this but don't expect anything before the end of summer!

@Falawiss
Copy link
Author

Falawiss commented Jul 3, 2024

Cool ! I will maybe give it a try in the summer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature improvement or request
Projects
None yet
Development

No branches or pull requests

2 participants