Forum

RE: Python scripting of sewer network geometry

Sebastian Schoeller, modified 6 Years ago.

Python scripting of sewer network geometry

Youngling Posts: 2 Join Date: 6/8/18 Recent Posts

Dear all,

 

I have started exploring python scriptability of Sobek 3. I am importing from a SHP-file to generate a network. First I have created nodes and channel objects as well as added that to branches and the network itself. Everything has worked and is correct in plan view.

 

When trying to define branch geometries I run in to difficulties though. I first add a cross-section to the branch and then try to set the geometry type which I cannot get my head around:

    # checking for egg-shape channel
    elif int(feature.Attributes.TryGetValue("Profilart")[1][:2]) == 1:
        crossSection = CreateBranchObjectOnBranchUsingChainage(BranchObjectType.Culvert, str(feature.Attributes.TryGetValue("Profilart")), channel, 7)
        crossSection.GeometryType.Egg

 

Setting GeometryType throws an error. The following import statements have been included in the header:

from Libraries.MapFunctions import CreateLineGeometry, CreatePointGeometry
from Libraries.MapFunctions import GetShapeFileFeatures, GetShapeFileCoordinateSystem
from Libraries.StandardFunctions import *
from Libraries.NetworkFunctions import *
from Libraries.SobekWaterFlowFunctions import *
from Libraries.StandardFunctions import *

 

Any advise is highly welcome.

 

Best regards

 

Sebastian

Sebastian Schoeller, modified 6 Years ago.

RE: Python scripting of sewer network geometry

Youngling Posts: 2 Join Date: 6/8/18 Recent Posts

After reconsulting the documentation I have managed to import the correct library and to attached a culvert object to a channel as follows:

 

from DelftTools.Hydro import CulvertGeometryType

 

    # create cross section for channel
    # checking for circular channel
    if int(feature.Attributes.TryGetValue("Profilart")[1][:2]) == 0:
        diameter = float(feature.Attributes.TryGetValue("ProfBreite")[1])/1000
        inlet = float(feature.Attributes.TryGetValue("SohleZu")[1])
        outlet = float(feature.Attributes.TryGetValue("SohleAb")[1])
        id = str(feature.Attributes.TryGetValue("ProfBez")[1])
        name = str(startNode.Id) + "-" + str(endNode.Id) + "_Round"
        culvert = CreateBranchObjectOnBranchUsingChainage(BranchObjectType.Culvert, id, channel, channel.Length/2)
        culvert.GeometryType = CulvertGeometryType.Round
        culvert.Diameter = diameter
        configureCulvert( culvert, channel.Length, inlet, outlet)

 

Unfortunately when trying to test run, Sobek 3 is complaining that channel objects do not have a cross-section attached to it. My current setup is that a network has branches and each branch has a channel. Since I want to simulate a closed sewer system and I cannot find any closed cross-sections I attached conduits between nodes. It does not work though. My ultimate goal is to test

 

RainfallRunoff->2D area->lateral inflow into->1D sewer network->outlet to 2D area

 

Any assistance is highly appreciated.

 

Best regards