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

Explicit "interpolation" along arclengths #210

Open
asinghvi17 opened this issue Sep 19, 2024 · 0 comments
Open

Explicit "interpolation" along arclengths #210

asinghvi17 opened this issue Sep 19, 2024 · 0 comments
Labels
geocompjl Methods needed for geocompjl

Comments

@asinghvi17
Copy link
Member

zion_transect_utm = gpd.GeoSeries(zion_transect, crs=4326).to_crs(32612)
zion_transect_utm = zion_transect_utm.iloc[0]

The printout of the new geometry shows this is still a straight line between two points, only with coordinates in a projected CRS.

print(zion_transect_utm)

Next, we need to calculate the distances, along the line, where points are going to be generated.
We do this using np.arange.
The result is a numeric sequence starting at 0, going up to line .length, in steps of 250 ($m$).

distances = np.arange(0, zion_transect_utm.length, 250)
distances[:7]  ## First 7 distance cutoff points

The distance cutoffs are used to sample ("interpolate") points along the line.
The shapely .interpolate method is used to generate the points, which then are reprojected back to the geographic CRS of the raster (EPSG:4326).

#| code-overflow: wrap
zion_transect_pnt = [zion_transect_utm.interpolate(d) for d in distances]
zion_transect_pnt = gpd.GeoSeries(zion_transect_pnt, crs=32612) \
    .to_crs(src_srtm.crs)
zion_transect_pnt

It would be useful to have this kind of function in GeometryOps. For now, I'm just going to use segmentize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
geocompjl Methods needed for geocompjl
Projects
None yet
Development

No branches or pull requests

1 participant