Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Gjf – A tool to fix invalid GeoJSON objects (github.com/yazeed44)
42 points by alohaclient on June 20, 2021 | hide | past | favorite | 6 comments


Please don’t use assert for validation [1]. Just explicitly raise an exception instead, as Python can strip asserts and an AssertionError is a crap thing to have to catch.

In Python you almost never have to do “for i in range(len(…))”, just do “for path in file_path” [2].

1. https://github.com/yazeed44/gjf/blob/b85f4e58fe6ed84b5d2f813...

2. https://github.com/yazeed44/gjf/blob/b85f4e58fe6ed84b5d2f813...


I’ve been using GeoJSON for indoor robotics mapping efforts for about 9 years now and it is a fantastic fit. One thing that kind of sucks is technically the standard insists that the CRS is degrees on an ellipsoid. But I use metres on a flat land.

Luckily most, but not all, tools are okay with this.


This looks useful, the flipped coords is something that will come in handy. And validate too, sometimes I want to know what is wrong for one feature so I can fix the script that is fetching/generating.


https://github.com/mapbox/geojsonhint has a directory of bad geojson files to test against.


Looks useful. I ran into some invalid geojson some time ago. Apparently clock wise vs. counter clockwise direction of coordinates in outer polygons and their holes is a thing. So are self intersecting polygons. There are multiple issues that prevent some products to function properly. E.g. Elasticsearch is particularly picky when it comes to this. I had some polygons that rendered perfectly fine that it still found reason to reject. There is a lot of bad data out there.


Is it common to have corrupted objects?




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: