felt / tippecanoe

Build vector tilesets from large collections of GeoJSON features.
BSD 2-Clause "Simplified" License
918 stars 81 forks source link

Issue with Coordinate Precision in Tippecanoe-Generated Vector Tiles #270

Open agiratech-mani opened 12 hours ago

agiratech-mani commented 12 hours ago

I am using the following command in Tippecanoe to generate vector tiles, but the latitude and longitude coordinates in the output are slightly different from the original GeoJSON data. I am using Mapbox’s map.queryRenderedFeatures({ layers: ['households'] }) to retrieve the data, but I would like to get the original coordinates and properties from the GeoJSON without precision loss.

Tippecanoe Command:

tippecanoe --no-feature-limit --buffer=64 --no-tile-size-limit --force --force-feature-limit --no-tile-size-limit --include=uprn --attribute-type=uprn:string --minimum-zoom=5 --maximum-zoom=16 --drop-rate=0.5 --layer=layername --output-to-directory "tiles" .simple-zero.geojson

Input GeoJSON:

{
    "type": "Point",
    "coordinates": [0.70212426, 51.18327632],
    "properties": {
        "coverage": "",
        "uprn": "10003900456"
    }
}

Output from Mapbox queryRenderedFeatures:

{
    "type": "Point",
    "coordinates": [0.7020950317382812, 51.183324447610744],
    "properties": {
        "coverage": "",
        "uprn": "10003900456"
    }
}

As you can see, the coordinates have slightly changed, and I need the exact original coordinates from the GeoJSON to be preserved in the vector tiles. Could you help me understand how to achieve this, or suggest a way to get the original GeoJSON coordinates using queryRenderedFeatures?

Thank you!

e-n-f commented 11 hours ago

Vector tiles inherently do not have exact precision. You can increase the tile detail slightly with -d13 -D13, but Mapbox GL will not take advantage of tile detail higher than 13. If you want to preserve exact values, you will have to store them as properties rather than as geometry.

agiratech-mani commented 11 hours ago

@e-n-f Is there is anyway to check values in pdf file after convertion?

e-n-f commented 5 hours ago

I mostly use tippecanoe-decode to turn the pbf or mbtiles files into JSON so I can read them.