Importing the Command Area Creation Module¶
Note: This module should be used only when boundary data for the command areas is unavailable. The generated command areas are estimations and may not be fully accurate; use the results with caution.
In [1]:
Copied!
from sdrips.cmd_area_creation import create_cmd_area
import geopandas as gpd
import warnings
warnings.filterwarnings("ignore")
from sdrips.cmd_area_creation import create_cmd_area
import geopandas as gpd
import warnings
warnings.filterwarnings("ignore")
Checking docstrings to see the input parameters¶
In [2]:
Copied!
create_cmd_area?
create_cmd_area?
Signature: create_cmd_area( shape_path: Union[str, pathlib.Path], column_name: str, output_path: Union[str, pathlib.Path], ) -> None Docstring: Apply iterative buffering to each feature and write polygon output. This function reads the input dataset, computes a per-row buffer distance so that each feature's buffered area approaches the value in the ``column_name``, replaces the geometry with the buffered polygon, and writes the result to the given ``output_path``. Note: Use this function only when command area boundaries are not available, as the output command areas from this function is an estimation, and may not be accurate. Hence, it should be used with caution. Parameters ---------- shape_path : str or pathlib.Path Path to the irrigation canal network dataset readable by GeoPandas. column_name : str Name of the column containing the target area for each feature. Should be in m2. output_path : str or pathlib.Path Path to the output shapefile (including .shp extension) created by this function. Returns ------- pathlib.Path Path to the created command area shapefile. File: c:\users\skhan7\onedrive - uw\desktop\research\phd\chapter2\github\sdrips\src\sdrips\cmd_area_creation.py Type: function
In [3]:
Copied!
shp_path = '../../Shapefiles/canal_network/Irrigation_Canal_Networks.shp'
f = gpd.read_file(shp_path)
f.head()
shp_path = '../../Shapefiles/canal_network/Irrigation_Canal_Networks.shp'
f = gpd.read_file(shp_path)
f.head()
Out[3]:
Canal_ID | Type | Length | CMD_Ar_m2 | geometry | |
---|---|---|---|---|---|
0 | Teesta Canal A | Primary Canal | 12.17 | 8890000 | LINESTRING Z (404805.823 894587.89 0, 403992.9... |
1 | Teesta Canal B | Primary Canal | 20.88 | 9110000 | LINESTRING Z (399184.245 884776.258 0, 399107.... |
2 | Dinajpur Canal | Primary Canal | 41.22 | 29250000 | LINESTRING Z (399908.857 880258.192 0, 399802.... |
3 | Rangpur Canal | Primary Canal | 28.90 | 19850000 | LINESTRING Z (403560.15 865043.327 0, 403608.8... |
4 | S9D | Secondary Canal | 8.05 | 11930000 | LINESTRING Z (384879.543 850013.711 0, 384880.... |
In [4]:
Copied!
f.explore()
f.explore()
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Notice the geometry type in the above geodataframe. It is LINESTRING
.
In [5]:
Copied!
ca_path = create_cmd_area(shape_path = shp_path, column_name= 'CMD_Ar_m2',output_path='../Data/created_cmd_area/created_cmd_area.shp')
ca_path = create_cmd_area(shape_path = shp_path, column_name= 'CMD_Ar_m2',output_path='../Data/created_cmd_area/created_cmd_area.shp')
In [6]:
Copied!
g = gpd.read_file('../Data/created_cmd_area/created_cmd_area.shp')
g.head()
g = gpd.read_file('../Data/created_cmd_area/created_cmd_area.shp')
g.head()
Out[6]:
Canal_ID | Type | Length | CMD_Ar_m2 | buffer_dis | geometry | |
---|---|---|---|---|---|---|
0 | Teesta Canal A | Primary Canal | 12.17 | 8890000 | 349.822640 | POLYGON ((399666.159 886326.994, 399667.731 88... |
1 | Teesta Canal B | Primary Canal | 20.88 | 9110000 | 214.663893 | POLYGON ((399292.637 884537.027, 399225.209 88... |
2 | Dinajpur Canal | Primary Canal | 41.22 | 29250000 | 349.822640 | POLYGON ((382430.669 861838.846, 382440.518 86... |
3 | Rangpur Canal | Primary Canal | 28.90 | 19850000 | 337.101817 | POLYGON ((403473.767 865373.482, 403504.395 86... |
4 | S9D | Secondary Canal | 8.05 | 11930000 | 655.122399 | POLYGON ((382483.384 844769.913, 382484.988 84... |
In [7]:
Copied!
g.explore()
g.explore()
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
This process generates command areas by iteratively buffering the canal network until the target area is reached, as shown above