DEV Community

Cover image for Solution: Polygons and MultiPolygons should follow the right-hand rule
vasubabu
vasubabu

Posted on

Solution: Polygons and MultiPolygons should follow the right-hand rule

I use OpenStreetMaps/Datahub.io to get the polygon data for an area.
For Country polygons, I prefer Datahub.io and others I prefer Open street maps.

Links:
https://nominatim.openstreetmap.org/search.php?q=liege&polygon_geojson=1&format=json
Note: Please change q=liege to your desired place and nominatim is the UI built on top of OSM.
Datahub.io

sometimes you may see the below error while validating a Geo-JSON data downloaded using https://geojsonlint.com

Line 1: Polygons and MultiPolygons should follow the right-hand rule

Alt Text

This is because the Geo-JSON data is not following the Right-Hand rule.

What is a Right-Hand rule?

When you construct a polygon, you can order the coordinates in one direction or another. If you’re drawing a circle, you might start on the left and go counter-clockwise around to meet the original point. Or, you might go clockwise.

Here is the specification:

A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

Source: mapster

Fix: Its very hard to convert the Geo-Json data according to Right hand rule, one way is use this tool to do that

http://mapster.me/right-hand-rule-geojson-fixer/

Alt Text

Geo-JSON Lint:
Alt Text

Top comments (0)