The GeoJSON specification for the type "Polygon" requires its coordinates to be an array of linear rings (see the spec here).
So we must make geometry like this:
{
"type": "Polygon",
"coordinates":
[ <--- this array is an array of linear rings
[ <--- this array is a linear ring
[long0, lat0], <--- this array is a point
...,
[longN, latN]
]
]
}
GeoJSON requires this so that Polygons can be Donuts, ie. so that they can have holes. For example, to make a Polygon that looks like this:
4 ___________
|/ /_/_/_/ /| <--- the shaded areas are part of the polygon
| /| |/ |
|/ |_____| /|
|_/_/_/_/_/_|
0 4
We would make a GeoJSON polygon like this:
{
"type": "Polygon",
"coordinates": [
[ [0,0], [4,0], [4,4], [0,4], [0,0] ], <--- first ring is exterior
[ [1,1], [1,3], [3,3], [3,1], [1,1] ] <--- next ring is interior
]
}
Maybe if you are just trying to access the exterior ring, then your JavaScript can be something like:
if (geometry.coordinates.length > 0) {
var exterior_ring = geometry.coordinates[0];
// do something with ring...
}
The GeoJSON specification for the type "Polygon" requires its coordinates to be an array of linear rings (see the spec here).
So we must make geometry like this:
{
"type": "Polygon",
"coordinates":
[ <--- this array is an array of linear rings
[ <--- this array is a linear ring
[long0, lat0], <--- this array is a point
...,
[longN, latN]
]
]
}
GeoJSON requires this so that Polygons can be Donuts, ie. so that they can have holes. For example, to make a Polygon that looks like this:
4 ___________
|/ /_/_/_/ /| <--- the shaded areas are part of the polygon
| /| |/ |
|/ |_____| /|
|_/_/_/_/_/_|
0 4
We would make a GeoJSON polygon like this:
{
"type": "Polygon",
"coordinates": [
[ [0,0], [4,0], [4,4], [0,4], [0,0] ], <--- first ring is exterior
[ [1,1], [1,3], [3,3], [3,1], [1,1] ] <--- next ring is interior
]
}
Maybe if you are just trying to access the exterior ring, then your JavaScript can be something like:
if (geometry.coordinates.length > 0) {
var exterior_ring = geometry.coordinates[0];
// do something with ring...
}
Hi @jakemolnar, we are not using JavaScript. Is there any workaround please?
Hi @jakemolnar, we are not using JavaScript. Is there any workaround please?
Hey @fmeuser_gc, then what are you using to access the Polygon data?
Anyway, one workaround I can think of is to convert your polygons to lines (
https://knowledge.safe.com/questions/4730/how-to-convert-polygons-to-lines-and-vice-versa.html), since lines have the representation you are looking for:
{
"type": "LineString",
"coordinates": [
[ long0, lat0 ],
...,
[ longN, latN ]
]
}