scrollbar |
---|
Exercise
...
outline
...
We
...
want
...
to
...
create
...
a
...
station
...
class
...
(data
...
structure)
...
that
...
can
...
hold
...
the
...
data
...
of
...
one
...
station.
...
Then
...
we
...
make
...
a
...
list
...
containing
...
all
...
the
...
stations
...
in
...
the
...
NetCdf
...
file
...
and
...
fill
...
it
...
with
...
the
...
data
...
of
...
the
...
NetCdf
...
file.
...
Add
...
monitoring
...
points
...
for
...
stations
...
in
...
envelope
...
Add
...
the
...
following
...
import
...
statements
...
to
...
the
...
region
...
Import
...
libs:
Code Block | ||
---|---|---|
| ||
{color}:
{code:language=python}
# DeltaShell libs
from DelftTools.Hydro2D.Features import Feature2DPoint
from DeltaShell.Plugins.FMSuite.FlowFM.Layers import UnstructuredGridLayer
|
And add this code to the end of the script :
Code Block | ||
---|---|---|
| ||
{code} \\ And add this code to the end of the script : {code:language=python} #region Add monitoring points for stations in envelope # Get bounding box of grid gridLayer = UnstructuredGridLayer() gridLayer.Grid = fmModel.Grid envelope = gridLayer.Envelope # Get stations in envelope stationsInEvelope = [] for station in stationList: if (gridLayer.Envelope.Contains(station.geometry.Coordinate)): stationsInEvelope.append(station) print "Nr of stations in grid extend : " + str(len(stationsInEvelope)) # Add monitoring point at station locations for station in stationsInEvelope: observationPoint = Feature2DPoint() observationPoint.Name = station.name observationPoint.Geometry = station.geometry fmModel.Area.ObservationPoints.Add(observationPoint) print "Added : " + station.name + " to observation points" #endregion {code} \\ we start by getting the bounds of the grid. We do this by creating a grid layer (UnstructuredGridLayer) and get the Envelope property: {code:language=python |
we start by getting the bounds of the grid. We do this by creating a grid layer (UnstructuredGridLayer) and get the Envelope property:
Code Block | ||
---|---|---|
| ||
} # Get bounding box of grid gridLayer = UnstructuredGridLayer() gridLayer.Grid = fmModel.Grid envelope = gridLayer.Envelope {code} \\ Now we create a new list for the stations that are in the grid envelope, and loop through all the stations to see if they are in the envelope: {code:language=python} |
Now we create a new list for the stations that are in the grid envelope, and loop through all the stations to see if they are in the envelope:
Code Block | ||
---|---|---|
| ||
# Get stations in envelope
stationsInEvelope = []
for station in stationList:
if (gridLayer.Envelope.Contains(station.geometry.Coordinate)):
stationsInEvelope.append(station)
print "Nr of stations in grid extend : " + str(len(stationsInEvelope))
{code}
\\
We can now use these stations to create observation points |
We can now use these stations to create observation points (Feature2DPoint)
...
using
...
the
...
name
...
and
...
geometry
...
of
...
the
...
stations
Code Block | ||||
---|---|---|---|---|
| =
| |||
} # Add monitoring point at station locations for station in stationsInEvelope: observationPoint = Feature2DPoint() observationPoint.Name = station.name observationPoint.Geometry = station.geometry fmModel.Area.ObservationPoints.Add(observationPoint) print "Added : " + station.name + " to observation points" {code} \\ \\ |
scrollbar |
---|