Defining Polygon Shapes in GeoJSON
--
In geometry, a polygon is a closed two-dimensional shape with straight sides. It is formed by connecting multiple line segments called edges. A polygon consists of vertices (corner points) and edges that connect these vertices. The edges do not cross each other, and the last vertex is connected to the first vertex, creating a closed shape. Polygons can have different numbers of sides, ranging from three to infinity.
A polygon shape represents a specific instance of a polygon. It defines the exact coordinates of its vertices, allowing for the precise representation of the polygon on a two-dimensional plane. Polygons are commonly used to represent various geographic features such as land boundaries, city boundaries, lakes, or countries.
The below image shows a polygon shape which represents the postal code area 3273 in the Netherlands visualized in kepler.gl
The above shape, when defined in a GeoJSON format looks, a bit, like the JSON structure below. the “a bit” part is because we did not show all coordinates pairs is a full set of 895 vertices, which is inconvient to display in a blogpost.
{
"type": "Feature",
"properties": {
"postalCode": "3273"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[4.437842656838879, 51.79863262764456],
[4.437848550343165, 51.79862818037955],
[4.437868732706398, 51.79863373688387],
[4.437871613175266, 51.79863466010348],
[4.437913219344028, 51.798655673919995],
[4.437950211385806, 51.79868923632547],
[4.437946762985248, 51.79871527842703],
[4.437925823323146, 51.798745675694846],
[4.438238242350044, 51.798782366694866],
[4.438307131180495, 51.79877315305338],
......
[4.437842656838879, 51.79863262764456]
]
]
}
}
This is a bit more of a detailed example which can come in handy when reading the blogpost about data visualization with postal codes. You can find the full GeoJSON example, with the removed lines included in this Github Gist.
About the author(s)
Johan Louwers is currently Chief Enterprise Architect within Oracle. Johan has a strong and long background in the field of Enterprise Architecture and complex system engineering. Having worked with enterprises in a diverse set of industries as (enterprise) architect, CTO and technical and strategic business advisor Johan brings both deep technical knowledge to the table as well as strong business oriented expertise. In addition to this Johan is a tech addict who tends to enjoy supporting open source initiatives and actively coding as a hobby. Views expressed in this post are personnel and do not necessarily reflect the views of Oracle.