question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How could I get right tile (WGS 84 / Lat-lon / Geographic / EPSG:4326) by long, lat and zoom?

See original GitHub issue

I’m trying to get tile by long, lat and zoom by formula:

row = int((90 - lat) / 180 * 2 ** zoom)
col = int((180 + lon) / 180 * 2 ** zoom)

but it doesn’t work. Here is related question https://gis.stackexchange.com/questions/239496/how-to-convert-long-lat-to-a-tile-of-nasa-gibs-wgs-84-lat-lon-geographic

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
lucianplscommented, May 7, 2017

For GIBS GCS, the level 0 resolution is 288 deg / tile, not 180 deg/tile. It was chosen to approximate the full resolution of the MODIS images, avoiding oversampling or undersampling, while still having full width tiles at most levels (2 and up).

Making this adjustment, the formula to use is:

row = ((90 - lat) * (2 ** level)) // 288
col = ((180 + lon) * (2 ** level)) // 288
1reaction
lucianplscommented, May 8, 2017

Web Mercator assumes the world map fits in a square tile of 256x256, then keeps subdividing. There is also a GCS grid where the whole world fits in two tiles side by side at top level, the way your original formula works. There are no partial content tiles ever. Those are the most common tiling schemes.

You might want to look at GDAL, it has python bindings and knows how to fetch the data from GIBS, using the GDAL WMS, hiding the tiling aspect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Converting long, lat to tile of NASA GIBS - WGS 84 / Lat-lon ...
I've gotten comment from Lucian member of NASA team. For GIBS GCS, the level 0 resolution is 288 deg / tile, not 180...
Read more >
Map and Tile Coordinates | Maps JavaScript API
Tile coordinates, which reference a specific tile on the map at a specific zoom level.
Read more >
Zoom levels and tile grid - Azure Maps
Learn how to set zoom levels in Azure Maps. See how to convert geographic coordinates into pixel coordinates, tile coordinates, and quadkeys ...
Read more >
Spatial references | Documentation - ArcGIS Developers
A spatial reference defines the coordinate system used to locate the geometry for a ... Typically GCSs use latitude and longitude specified in...
Read more >
Tiles à la Google Maps: Coordinates, Tile Bounds and ...
Convert coordinates for using global map tiles. Map of Earth. Degrees Geodetic coordinates WGS84 (EPSG:4326). Longitude and latitude coordinates ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found