Search code examples
mapboxgeojsonqgismapbox-gl-jswkt

Geojson data causes mapbox to crash, tactics to isolate the error


I have downloaded shapefile boundary data from the UK ordnance survey and have converted it to geojson format, using QGIS. There were no errors reported during the conversion, and given the fact that the data came from a governmental organisation, I think it is a reasonable assumption that the data made available is correct, coherent and intact (which has an effect on how I narrow down the error source).

I use mapbox to display this data, and retrieve it through a webservice. When I load the data with mapbox, it causes mapbox to "bluescreen", i.e. completely crashes the browser tab and disconnects the development console (Chrome, FF and IE). There are far too many polygons/features for me to investigate "manually", and I can't contain the error - even try/catch doesn't help. I have started to systematically halve the data set, and it turns out that the error is contained somewhere in boundary areas beginning with letters a-m. I know that I could continue with this approach and at some point find the error(s), but I would like to know if you have some tips for me to

  1. Check WKT/geojson/polygonal integrity. Technology is unimportant to me (C#, Java, JS, whatever...) as long as it's a concise process. (Apparently, Postgres/Postgis has this but all my data resides in an object database, and if there is ANY other means to check, I'd prefer that :-))
  2. Check geodata integrity specifically with respect to mapbox consumption.

My assumption is that "correct" (i.e. error-free and correctly-formatted) geodata will render correctly in mapbox, but as my problem has shown: somewhere in between the official data set from a governmental website, error-free conversion using a well-established tool and rendering in mapbox using the latest version, it still goes wrong.

Thanks for your hints in solving this !

EDIT: amazingly, Firefox seems to handle this better than Chrome. Doesn't crash using the same data.


Solution

  • First of all I fear that there is no right or wrong answer to your question and I don't know how you want to accept an answer. This is normally a a bad sign for a question.

    Second I would not take a data set for "must be valid" even if it comes from a government. Exporting data into a format always can have some edge cases or they might not follow the geojson specification as tight as you would have liked them to.

    However this is what you can try to do:

    1. Often the data is too precise to work with (over fitting) and you should try to simplify your geojson data with a tool of your choice to reduce its size. You could use one of the following to do that task (there are more ofc.)

    2. See if you can load the simplified version into the browser

    3. You could try to validate geojson with an external tool like http://geojsonlint.com/ or http://geojson.io/ if your file is not too large.

    4. Try another browser to see if it can handle data better. Its strange that your browser crashes. If chrome runs out of memory it will normally notify you about that issue.

    Other than that I think it would stay a manual task to hunt down the problem.