Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
agiratech-mani opened this issue Sep 20, 2024 · 4 comments
Open

Comments

@agiratech-mani
Copy link

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
Copy link
Collaborator

e-n-f commented Sep 20, 2024

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
Copy link
Author

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

@e-n-f
Copy link
Collaborator

e-n-f commented Sep 20, 2024

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

@mani-mworks
Copy link

mani-mworks commented Sep 23, 2024

@e-n-f I checked the PBF data by decoding it using tippecanoe-decode. I noticed that the coordinates are truncated; my data has 8 decimal places, but the generated data only has 6 decimal places. Could you please suggest any fixes for this?

My data:

{
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [
            0.52058667,
            51.08886337
        ]
    },
    "properties": {
        "coverage": "",
        "uprn": "10090058889",
        "lat": 51.08886337,
        "long": 0.52058667
    }
}

Generated data:

{
    "type": "Feature",
    "properties": {
        "coverage": "",
        "uprn": "10090058889",
        "lat": 51.08886337,
        "long": 0.52058667
    },
    "geometry": {
        "type": "Point",
        "coordinates": [
            0.520477,
            51.088860
        ]
    }
}

Please help me to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants