-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrivers.py
More file actions
46 lines (34 loc) · 1.15 KB
/
rivers.py
File metadata and controls
46 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
# Paths to shapefiles
india_shp = "./India Shapefile With Kashmir/India Shape/india_st.shp"
rivers_shp = "./NRLP/datasets/rivers.shp"
'''
CROP LAT/LONG
# Define the latitude and longitude range
min_lat, max_lat = 26.7, 27
min_lon, max_lon = 80.8, 81
# Crop the shapefile based on the latitude and longitude range
cropped_shapefile = rivers_gdf.cx[min_lon:max_lon, min_lat:max_lat]
# # Save the cropped shapefile
# cropped_shapefile.to_file('cropped_shapefile.shp')
'''
# Read shapefiles into GeoDataFrames
india_gdf = gpd.read_file(india_shp)
rivers_gdf = gpd.read_file(rivers_shp)
# Create a figure and axis object
fig, ax = plt.subplots(figsize=(12, 8))
# Plot India map
sns.set(style="whitegrid") # Set seaborn style
# sns.despine() # Remove spines
# Plot India
india_gdf.plot(ax=ax, color='lightyellow', edgecolor='gray', linewidth=0.5)
# Plot rivers
rivers_gdf.plot(ax=ax, color='blue', linewidth=1)
# Set plot title and labels
ax.set_title("Map of India with Rivers", fontsize=16)
ax.set_xlabel("Longitude", fontsize=12)
ax.set_ylabel("Latitude", fontsize=12)
# Show plot
plt.show()