我需要找到距离船只到海岸最短的距离。 我只了解纬度和长度。 是否有任何图书馆或法典这样做?
from shapely.geometry import Point
from shapely.ops import nearest_points
from geopy.distance import geodesic
import geopandas as gpd
# Read coastline data
coastline_data = gpd.read_file( ./ne_10m_coastline.shp )
coastline = coastline_data.geometry.unary_union
# Define target coordinate
target_coordinate = Point(36.20972222, 125.7061111)
# Find nearest point on coastline
nearest_point = nearest_points(target_coordinate, coastline)[0]
# Calculate distance
distance = geodesic((target_coordinate.x, target_coordinate.y), (nearest_point.x, nearest_point.y)).kilometers
print(f"The closest point to the coast is at {nearest_point} and the distance is {distance} kilometers.")
但是,我尝试了这一法典,但距离最接近,距离是零。 这里有什么错误?