Spherical mercator coordinate and tile utilities
The mercantile module provides ul(xtile, ytile, zoom) and bounds(xtile, ytile, zoom) functions that return longitudes and latitudes for XYZ tiles, and a xy(lon, lat) function that returns spherical mercator x and y coordinates.
>>> import mercantile
>>> mercantile.ul(486, 332, 10)
(-9.140625, 53.33087298301705)
>>> mercantile.bounds(486, 332, 10)
(-9.140625, 53.12040528310657, -8.7890625, 53.33087298301705)
>>> mercantile.xy(*mercantile.ul(486, 332, 10))
(-1017529.7205322663, 7044436.526761846)
mercantile.tool
Mercantile includes a script that writes the extent of an XYZ tile out as GeoJSON.
$ python -mmercantile.tool 20,35,6 --pretty
{
"features": [
{
"geometry": {
"coordinates": [
[
[
-67.5,
-21.943046
],
[
-67.5,
-16.636192
],
[
-61.875,
-16.636192
],
[
-61.875,
-21.943046
],
[
-67.5,
-21.943046
]
]
],
"type": "Polygon"
},
"id": "20,35,6",
"properties": {
"title": "XYZ tile 20,35,6"
},
"type": "Feature"
}
],
"type": "FeatureCollection"
}
If you have geojsonio-cli installed, you can shoot this GeoJSON straight to geojson.io for lightning-fast visualization and editing.
$ python -mmercantile.tool 20,35,6 --compact | geojsonio
Metadata
Release files for mercantile 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mercantile-0.1.tar.gz | 3.2 kB | Without provenance | Details for mercantile-0.1.tar.gz |
Release files / mercantile-0.1.tar.gz
| Download URL | mercantile-0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
641a4e88ed94dc36d4f0a3961144abecfb1d2af51217bdae24c1771bc66ee81f
|
|
BLAKE2b-256 checksum How to use checksums |
0836bd720df1a42911926a0fa31587f0fea7807388095307ae0fafc452b0098f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for mercantile 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.