Skip to content

Source of the formula for coordinate tranformation? #8

@NicoJG

Description

@NicoJG

I am interested on where you got the formula from for the coodinate transformation?

I was searching for how to convert the coordinates of a Mapbox Vector Tile into Geodetical coordinate for a long time.

Do you have any resources that could help me understand this coordinate transformation?

The formula is implemented in the python-vt2geojson/vt2geojson/features.py file:

    def toGeoJSON(self):
        size = self.extent * 2 ** self.z
        x0 = self.extent * self.x
        y0 = self.extent * self.y

        def project_one(p_x, p_y):
            y2 = 180 - (p_y + y0) * 360. / size
            long_res = (p_x + x0) * 360. / size - 180
            lat_res = 360. / pi * atan(exp(y2 * pi / 180)) - 90
            return [long_res, lat_res]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions