In most cases if a company has a set of equipment located inside a “container” – such as an electric substation or gas regulator station – then there is already a representation of the station boundary present in their mapping database. And with good reason.
The container polygon can be useful for indicating the presence of equipment without showing all the details as you zoom out. It may also be the case that this acts as a grouping mechanism for reporting purposes, or it may act as a link to a corresponding container record in an asset management system. Whatever the case these polygon features can be quite useful to your organization.
But… what if your don’t have but need them? Or if you have them but the polygon geometry does not fit the contained features the way you would like? That’s what this case study is about – creating (or updating) container polygons.
Example of a Gas Regulator Station
We’ll consider the case of gas regulator stations comprised of a set of pipes, fittings, valves and regulators. The pipes within a station are distinguished by a non-null “StationName” field. Further, we don’t want to perform this operation for a single station (we could do that by hand) but for many stations. An external table provides us a list of all stations. (If we did not have this table then we could use the IDataStatistics interface to quickly find the set of unique station names among all pipes.)
So, first we want to iterate over the set of stations and get all pipes within each. Since point devices are network features connected to pipes we would not expect any point geometries to fall beyond the extent of our pipes. Next we create a combined polyline geometry of all pipes, then use the ITopologicalOperator ConvexHull method to return a minimum bounding polygon surrounding our station.
Here is the specific code to assemble all points from all pipe polylines found in the station.
As a result we’ve got a polygon surrounding the pipes and other equipment in our station. If desired, we could use the ITopologicalOperator.Buffer method to expand the bounding polygon feature by a fixed amount.
In practice, of course, as with other code we would add error handing in the form of try/catch blocks in each of the above routines. We may also choose to use this opportunity add additional attribute values to the new station polygon — or to features we’ve found within the polygon. For example, this would be a great opportunity to assign the station name as an attribute to each of the contained features — if that were important to our implementation.
We’ve used the example of a gas regulator station, but a similar approach could be used for other, non-station equipment depending on the circumstances of our source data. Potential applications could include underground structure floors in a downtown electric distribution network, or equipment housed in a building or any number of others.