You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current extract_centroid method works well for most polygons but may return points outside the boundary. Adding a method to extract the point on surface using GeoPandas' representative_point() would make sure the point lies within the polygon.
Proposed Functionality to be added in the utility and for drainage database lat long coordinates:
def extract_point_on_surface(gdf, obj_id, epsg=4326):
if not gdf.crs:
gdf.set_crs(epsg=4326)
point_on_surface = gdf.geometry.representative_point()
if gdf.crs.to_epsg() != epsg:
point_on_surface = gdf.to_crs(epsg=epsg).geometry.representative_point()
coords_df = pd.DataFrame({
obj_id: gdf[obj_id],
'lat': point_on_surface.y,
'lon': point_on_surface.x
})
return coords_df
This will make sures extracted points always lie within the polygon boundary.
Provides users an alternative to centroid-based coordinates.
This would be a great addition to complement the existing functionality.
The text was updated successfully, but these errors were encountered:
we need to enhance this for gauge locations as we talked before. Gauges at the outlets are not always mapped to the correct subbasin as the centroid of another subbasin maybe closer to the gauge. Can we supply polygon outlets (intersection of river and subbasin shape) instead of centroids?
@mee067 Thank you for pointing that out. The enhancement to flag stations or use polygon outlets (intersection of river and subbasin shape) is indeed another development we are working on. For now, this update ensures that the centroid is correctly placed within the polygon and improves the default streamflow station identification function. The additional improvement you mentioned will be implemented as an alternative option alongside the default method in future updates.
The current extract_centroid method works well for most polygons but may return points outside the boundary. Adding a method to extract the point on surface using GeoPandas' representative_point() would make sure the point lies within the polygon.
Proposed Functionality to be added in the utility and for drainage database lat long coordinates:
This will make sures extracted points always lie within the polygon boundary.
Provides users an alternative to centroid-based coordinates.
This would be a great addition to complement the existing functionality.
The text was updated successfully, but these errors were encountered: