I am trying to learn the Vector Tile Map, and got one pbf file for one tile. I can load it into QGIS, but how can I know the CRS?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
The (mapbox) vector tile specification states that:
A Vector Tile represents data based on a square extent within a projection. A Vector Tile SHOULD NOT contain information about its bounds and projection. The file format assumes that the decoder knows the bounds and projection of a Vector Tile before decoding it.
So if there is no vendor specific information included in the file there is no way to know which is the CRS.
But it can be safely assumed for most cases, that the EPSG identifier is EPSG:3857 as the specs also say:
Web Mercator is the projection of reference, and the Google tile scheme is the tile extent convention of reference
In the example you provide, look at this line, the original gemetry is transformed to 3857, and all the transformations between the xyz scheme to the tile bounds/envelope is done assuming the web mercator projection (aka, spherical mercator or epsg:3857).
Also note that some of the python code in that example is no needed for the next Postgis version as a new function can make the transformation from xyz to an envelope. If that function can not be used and you want to work with other projections the python mercantile library can be used, instead of making your own calculations.
As a side note, remember that PBF (Google Protobufs) is the format used to encode/serialize vector tiles, but .pbf does not have to know about its content. Or sayed in another way: Vector Tiles are encoded as .pbf (usually using the extensions .mvt instead of .pbf to make it clear). But a .pbf does not have to contain data in the (MapBox) Vector Tile Specification.