You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

The fist thing we have to do is declare where the shape and csv files are located :

Declare paths
rootPath = r"D:\Workshop\data"

 

Then we continue with creating the basic network (consisting of branches and nodes) using the "network_Branches.shp" shape file. For this we will need to use a library called "SOBEKTutorialLibrary" in the "Libraries" folder of the toolbox. This is done by adding the following line (and running it).

Import "SOBEKTutorialLibrary" library
from Libraries.SOBEKTutorialLibrary import *

 

This will make all the functions (because of the *) in the "SOBEKTutorialLibrary" library available for use. All these functions will now also appear in the code completion dialog (when you use ctrl + space).

In this library we have a function called "CreateNetworkFromBranchShapeFile" which we will use to create the basic network.

Create basic network
network = CreateNetworkFromBranchShapeFile(rootPath + r"\network_Branches.shp")

 

After running this line the network will be created using the shape file and added to the variable "network" (if you to see how the network is created in more detail you can look at the CreateNetworkFromBranchShapeFile function in the SOBEKTutorialLibrary.py file in the libraries folder).

Now that we have a network with branches and nodes we can continue with the import of the cross-sections. This is done with the function "AddCrossSectionsToNetwork"

Add cross-sections to network
AddCrossSectionsToNetwork(rootPath + r"\network_Cross Sections.shp", rootPath + r"\CrossSectionProfiles.csv", network)

And AddBridgesToNetwork for bridges

Add bridges to network
AddBridgesToNetwork(rootPath + r"\network_Bridges.shp", rootPath + r"\BridgeProfiles.csv", network)

For the laterals and weirs we use the function :

Add lateral sources and weirs to network
from Libraries.NetworkFunctions import BranchObjectType

AddBranchObjectsFromShapeFile(BranchObjectType.LateralSource, rootPath + r"\network_Lateral Sources.shp", network)
AddBranchObjectsFromShapeFile(BranchObjectType.Weir , rootPath + r"\network_Weirs.shp", network)

 

Now that we have finished adding the structures to the network (for this tutorial), we can create a new waterflow model and add this network to it.

First we need to import two more libraries (SobekWaterFlowFunctions to be able to create a WaterFlowModel1D and StandardFunctions for adding the model to the project )

Create waterflow model and add network
flowModel = WaterFlowModel1D()
flowModel.Network = network
flowModel.Name = "Flow model"

AddToProject(flowModel)

 

  • No labels