You can download this code by clicking the button below.
This code is now available for download.
Calculates the distance between two geometric points.
Technology Stack : GeoPandas, Shapely, NumPy
Code Type : Function
Code Difficulty : Intermediate
def calculate_distance_between_points(geometry1, geometry2):
from geopandas import GeoDataFrame
from shapely.geometry import Point
import numpy as np
# Create GeoDataFrame
gdf = GeoDataFrame([geometry1, geometry2])
# Calculate the distance between the points
distances = gdf['geometry'].distance(gdf['geometry'])
return distances.iloc[0]