I have a 4000 lines dataframe composed of 2 columns : latitude and longitude. I realized a DBSCAN clustering (python code) based on harvesine distance to group points within a radius of 3km (code below).
I obtained 51 clusters, for each of theses cluster (regouping 1 or many points) I would like to obtain its geographic coordinates perimeter (rectangle shape) with 100m distance from the cluster's points. Ideally, the solution should work in the case where a cluster contains only 1 point.
Is it possible to obtain a such result ?
import pandas as pd, numpy as np, matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
from geopy.distance import great_circle
from shapely.geometry import MultiPoint
coords = data_al.iloc[:, 4:6].values
# epsilon is max distance that points can be from each other to be considered a cluster
kms_per_radian = 6371.0088
epsilon = 3 / kms_per_radian
db = DBSCAN(eps=epsilon, min_samples=1, algorithm='ball_tree', metric='haversine').fit(np.radians(coords))
cluster_labels = db.labels_
num_clusters = len(set(cluster_labels))
clusters = pd.Series([coords[cluster_labels == n] for n in range(num_clusters)])
print('Number of clusters: {}'.format(num_clusters))