Example Polygon Regions
GeoJSON complexity can impact on server calculation time and client display time. We recommend that regions are as simple as possible to aid performance.
To understand how to create a polygon region in Geo SCADA Expert you need to understand the GeoJSON format for encoding geographic data structures. A GeoJSON object can represent a geometry, a feature, or a collection of features, for example, a Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
In Geo SCADA Expert we are primarily concerned with the Polygon object in the context of regions (for information about other types of GeoJSON objects refer to the GeoJSON Specification. A polygon region consists of a set of coordinates, which are defined by real world latitude and longitude values.
The basic element of a polygon is a point (position), to make a polygon you need at least 3 points to enclose an area.
Coordinates in GeoJSON are formatted in simple decimal format, you can not use the degrees, minutes, seconds notation.
Latitude 52° 23' 4.1" Longitude 1° 33' 33.2" West
is expressed as:
52.38446667, -1.5592217
where - is west and + is east.
Position
A position is an array of coordinates and is the smallest unit that we can really consider ‘a place’ since it can represent a point on earth. GeoJSON describes an order for coordinates: they should go, in order:
[longitude, latitude, elevation]
We do not require elevation for the definition of regions in Geo SCADA Expert, so this can be ignored.
Historically, the order of world coordinates is usually “latitude, longitude” but, data formats usually use the longitude, latitude order as they match the X, Y order of math.
Display Properties
You can include polygon regions on maps. As such, consider including settings to specify properties such as the region's display name, fill opacity, and stroke (line) width.
Due to the nature of projecting the globe onto a 2D map, the lines drawn to represent a Polygon Region are an approximation. The closer to the pole and the longer any given line (that is not exactly orientated north-south), the greater the degree of inaccuracy.
The following example comprises various properties that define a Polygon Region's appearance and name on a map.
"properties": {
"stroke": "#9148db",
"stroke-width": 20,
"stroke-opacity": 0.5,
"fill": "#57dba2",
"fill-opacity": 0.25
"name": "Region Display Name"
},
-
"stroke"
is the color of the surrounding line of the region, in hex format. -
"stroke-width"
is the width of the surrounding line. This should be a number. -
"stroke-opacity"
is the level of opacity (transparency) of the surrounding line. This is a number from 0 to 1. -
"fill"
is the color of the region's area, in hex format. -
"fill-opacity"
is the level of opacity (transparency) of the region's area. This is a number from 0 to 1. -
"name"
is the name that is displayed for the region on a map's Layer menu. If you omit this property, the Full Name of the Region database item (which includes its path in the database) is shown instead.
Geometry
Geometries are shapes. All simple geometries in GeoJSON consist of a type and a collection of coordinates.
Polygons
Polygons are complex GeoJSON geometries, as they have area, so they have insides and outsides.
The following is an example of a simple three sided polygon. There are four position coordinates, the first and last coordinates must be the same to form a closed polygon.
{
"type": "Polygon",
"coordinates": [
[
[0, 0], [10, 10], [10, 0], [0, 0]
]
]
}
This code is sufficient to create a basic region within Geo SCADA Expert. The coordinates shown are list on one line, for larger polygon it is useful to list each set of coordinates on a separate line.
[
[0, 0],
[10, 10],
[10, 0],
[0, 0]
]
This example shows a clockwise sequence creating a six sided polygon. All the following examples of code assume that a polygon is drawn in a clockwise direction.
The definition for the polygon illustrated is shown below, if you reversed the sequence of coordinates the polygon would be created in the counter-clockwise direction:
{
"type": "Polygon",
"coordinates": [
[
[
-1.557210087776184,
52.38930571124421
],
[
-1.5563786029815674,
52.38897177555134
],
[
-1.5565073490142822,
52.38842503224716
],
[
-1.5572261810302734,
52.388258061385244
],
[
-1.5579664707183838,
52.38851997618108
],
[
-1.5579879283905027,
52.38898814500695
],
[
-1.557210087776184,
52.38930571124421
]
]
]
}
Polygons within Polygons
It is possible to create polygons within polygons (regions within regions), in situations where you want to subdivide an region and be able to work with the whole region as well.
The code listed below creates a polygon within a polygon in it similar to the example shown previously.
{"type": "FeatureCollection",
"features": [
{"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-1.5571832656860352,
52.38961345366551
],
[
-1.5558099746704102,
52.38886701089179
],
[
-1.5563678741455078,
52.38808126801956
],
[
-1.557633876800537,
52.387937213642495
],
[
-1.558535099029541,
52.38868367213927
],
[
-1.5581488609313965,
52.389286068038096
],
[
-1.5571832656860352,
52.38961345366551
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-1.5572047233581543,
52.389125648194245
],
[
-1.5576767921447754,
52.38903725333729
],
[
-1.557853817939758,
52.388709863436254
],
[
-1.5575748682022095,
52.388421758314756
],
[
-1.557038426399231,
52.38839884078118
],
[
-1.5566951036453247,
52.38863456341556
],
[
-1.5567058324813843,
52.388863736992185
],
[
-1.5572047233581543,
52.389125648194245
]
]
]
}
}
]
}
Polygons with holes
Polygons are not just enclosed areas, but can have cut-outs or holes. To understand how to construct polygons with cut-outs we need to introduce a new term: the LinearRing. LinearRings are a set of positions that define a line that encloses a space (a polygon), however, you can have an exterior LinearRing and none, one or more interior LinearRing. For Polygons with multiple rings:
- The first described ring must be the exterior ring.
- The exterior ring cannot self-intersect.
- Any interior ring must be entirely contained by the outer ring.
- Interior rings cannot intersect or overlap each other and interior rings cannot share an edge.
We recommend that exterior rings are always defined in the clockwise direction and interior rings are defined in the counter-clockwise direction.
The code listed below creates a polygon with a hole in it similar to the example shown. The interior ring is defined in the counter-clockwise direction.
{
"type": "Polygon",
"coordinates": [
[
[
-1.557210087776184,
52.38930571124421
],
[
-1.5563786029815674,
52.38897177555134
],
[
-1.5565073490142822,
52.38842503224716
],
[
-1.5572261810302734,
52.388258061385244
],
[
-1.5579664707183838,
52.38851997618108
],
[
-1.5579879283905027,
52.38898814500695
],
[
-1.557210087776184,
52.38930571124421
]
],
[
[
-1.557210087776184,
52.38900778834563
],
[
-1.556839942932129,
52.38886701089179
],
[
-1.5568453073501587,
52.38862146774666
],
[
-1.557210087776184,
52.38846431941698
],
[
-1.557537317276001,
52.388605098155104
],
[
-1.5575426816940308,
52.3888506413913
],
[
-1.557210087776184,
52.38900778834563
]
]
]
}
Further Information
For additional information on how to work with GeoJSON refer to the GeoJSON Specification, also the website geojson.io can be used as an aid in creating polygons.