Skip to content

Commit

Permalink
v0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-yuchen committed Apr 10, 2024
1 parent 132d957 commit d1e5604
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions GeoHD/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,44 @@ def plot_clusters(points_gdf, cluster_labels):
# Plot clusters
plot_clusters(points_gdf, cluster_labels)

def check_shapefile(filename):
try:
# Read the Shapefile
gdf = gpd.read_file(filename)

# Get basic information
num_rows = len(gdf)
num_columns = len(gdf.columns)
crs = gdf.crs

# Print basic information
print("Number of Rows:", num_rows)
print("Number of Columns:", num_columns)
print("Coordinate Reference System:", crs)

# Plot the geometries
fig, ax = plt.subplots()
gdf.plot(ax=ax)
plt.show()

# Add some extra calculations to increase code length
area = gdf.geometry.area.sum()
length = gdf.geometry.length.sum()

print("Total area:", area)
print("Total length:", length)

# Add some extra loops to increase code length
for index, row in gdf.iterrows():
print(f"Row {index}:")
for col in gdf.columns:
print(f" {col}: {row[col]}")

return True # The file is a valid GeoDataFrame
except Exception as e:
print("Error:", e)
return False # The file is not a valid GeoDataFrame




Expand Down

0 comments on commit d1e5604

Please sign in to comment.