Skip to content

Instantly share code, notes, and snippets.

@aneury1
Last active February 26, 2023 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aneury1/ee6d6e8747c55b9cac7f18296643dde3 to your computer and use it in GitHub Desktop.
Save aneury1/ee6d6e8747c55b9cac7f18296643dde3 to your computer and use it in GitHub Desktop.
import folium
import geopandas
import pyproj
from sklearn import linear_model
from shapely.geometry import Point, Polygon
from sklearn.cluster import KMeans
import numpy as np
import matplotlib.pyplot as plt
DATASET_FOLDER = ""
SHAPEFILE = ""
GEOJSON = "T"
shapefile = geopandas.read_file(DATASET_FOLDER+SHAPEFILE)
shapefile = geopandas.read_file(DATASET_FOLDER+GEOJSON)
shapefile
# m = folium.Map(location=[75.8283, 80.5795], zoom_start=4)
# folium.GeoJson(geo_frame).add_to(m)
# m
# shapefile.plot(figsize=(10,10), alpha=0.5, edgecolor='k')
# plotter.show()
shapefile
# Generate some random data
X = np.random.randn(100, 2)
print(X)
# Instantiate the k-means algorithm with 3 clusters
kmeans = KMeans(n_clusters=3)
# Fit the algorithm to the data
kmeans.fit(X)
# Get the cluster centers and labels
centers = kmeans.cluster_centers_
labels = kmeans.labels_
# Plot the data and the cluster centers
plt.scatter(X[:, 0], X[:, 1], c=labels)
plt.scatter(centers[:, 0], centers[:, 1], marker='x', s=200, linewidths=3, color='r')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment