7

enter image description hereenter image description here

I'm new to QGIS and having a little trouble understanding why my vector lines in QGIS look sharp and accurate but when I export and then import into MapBox, the line accuracy is reduced.

Vector end points shift a little and don't meet correctly anymore. There seems to be some vector simplification happening during export?

I've tried multiple export formats and they all provide the same result. Any ideas?

enter image description here

5
  • 1
    Can you Screenshot an example of what is happening?
    – JonasV
    Commented Sep 9, 2020 at 6:23
  • 1
    Also please provide the CRS you're exporting from/to, and the exact export settings.
    – Erik
    Commented Sep 9, 2020 at 6:42
  • Thanks... I've tried exporting as CRS, EPSG:3857 and 4326... in both GeoJSON and ShapeFile formats. Not sure which CRS MapBox accepts? But when I try exporting in 3857, I get errors from MapBox about unacceptable bounding values.
    – Ryan
    Commented Sep 9, 2020 at 7:04
  • Don't have an answer, but have your tried re-importing the GeoJSON and the vector tiles into QGIS (need 3.14+ for vector tiles)? Would let you pinpoint where the loss of precision is happening. And what's your scale, i.e. how big is the loss of precision?
    – Houska
    Commented Sep 9, 2020 at 10:30
  • Thanks, I tried re-importing the exported GeoJSON file back in QGIS and there was no loss of precision. So I guess that tells me the loss is occurring during the import to MapBox.
    – Ryan
    Commented Sep 9, 2020 at 11:05

1 Answer 1

5

First off: Mapbox GL accepts EPSG:4326 - WGS84 referenced coordinates only, and transforms to either EPSG:3857 - Spherical (Web) Mercator directly, or into Vector Tile space.

Then: Mapbox GL internally scales down precision to 6 decimal digits for the use in GeoJSON based sources (the GeoJSON specs continues to suggest to reduce precision to 6 decimal places), or for their Vector Tiles.

And eventually: Vector Tile geometries are usually generalized for different zoom level presentations, their vertices reduced and simplified, and coordinates rounded to Vector Tile space ordinates. Note that GeoJSON sources are also simplified and transformed (see their geojson-vt library) to Vector Tile space internally.

It seems to be one needs to expect reduced precision, considering the operations performed on the source geometries. This is the price for the overall performance gain needed to serve arbitrary large geo-datasets in real-time to a client WebGL renderer.

1
  • Thanks, you may be right and I'll have to accept the difference. But it's interesting that I can display the exact same vector lines in MapBox, from the pre-loaded MapBox Streets v8, which look accurate and precise (see image above). Yet that same data when imported in to MapBox manually as a GeoJSON layer, there is a noticeable loss of precision. Only reason I'm not using the data from the MapBox Streets v8, is the lack of control over zoom-levels from the OSM source.
    – Ryan
    Commented Sep 9, 2020 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.