Open shinbunya opened 1 year ago
Can't we leverage methods in geopandas to make this simpler?
import geopandas as gpd
from geopandas.tools import nearest_points
# Load the GeoDataFrame
gdf = gpd.read_file('my_data.shp')
# Get the nearest point for each point in the GeoDataFrame
# (assuming the points are stored in a column called "geometry")
gdf['nearest_point'] = gdf['geometry'].apply(lambda x: nearest_points(x, gdf['geometry'])[1])
# Calculate the distance between each point and its nearest point
gdf['distance_to_nearest_point'] = gdf.apply(lambda row: row['geometry'].distance(row['nearest_point']), axis=1)
@shinbunya thank you for helping extending adcircpy
functionalities. Can you please look into using what @krober10nd suggests and see if it helps getting the results you're looking for?
In any case it'd be great if you could please add an automated test case in the tests
directory for this functionality and start a pull request.
Thanks @krober10nd for the suggestion. I will update it accordingly. @SorooshMani-NOAA I will add a test case and do a pull request. Thanks.
I needed to find the indexes of the nodes nearest to specified locations. I wonder if there is a common need for this. I wrote the following Grd class instance method for my own purpose. I used this to extract values at the locations for water level timeseries plots. I'd like to know if this kind of additional functions would add any value to ADCIRCpy.