2

What can I do with the given information: I don't know where I am in the World having some particular tile. It's only an ocean (or sea).

"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/14/5210/8141"

I know, the viewing scale is 36111.909643 and current zoom is 14. Am I able, using the naming convention to guess what would be it's absolute coordinates? I'm not sure about the projection but may choose something later if only I knew what's the region of these waters. It's a guess game.

How to take this approach? How to calculate it? Here I have info about the systematics of this "World_Topo_Map" service.

https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer

How can I get to lon/lat for center of a particular tile?

Here's similar for google: Calculate lat lon bounds for individual tile generated from gdal2tiles but where to put the tile IDs in that formula?

EDIT

I've found a formula for R (and many other languages) but how can I be sure the precision is correct for this particular service? Looking at the globe it's quite there.

# tile formula
rad2deg <- function(rad) {(rad * 180) / (pi)}
num2deg <- function(xtile, ytile, zoom) {
  n = 2.0 ** zoom
  lon_deg = xtile / n * 360.0 - 180.0
  lat_rad = atan(sinh(pi * (1 - 2 * ytile / n)))
  lat_deg = rad2deg(lat_rad)
  return (list(lat=lat_deg, lon=lon_deg))
}

num2deg(8141,5210,14)

I mean I'd need to have a chance of including the projection Spatial Reference: 102100 (3857) for this service in some way.

alphabetasoup
  • 8,718
  • 4
  • 38
  • 78
Peter.k
  • 477
  • 1
  • 5
  • 14

1 Answers1

3

Tile services typically (not always, but almost always) use the Web Mercator projection (3857), because it has nice properties for tiling. It's a safe assumption.

In this case, you don't need to assume, since it's in the metadata for the service: https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/

This tile pattern (z/x/y) is deliberate, and the formula in your question is correct. There are utility libraries in many languages for getting latitude/longitude coordinates for tiles and vice versa, as well as doing things like getting parent/child tiles. Example: https://github.com/mapbox/mercantile

The main "gotcha" is that there are two ways to give the y-tile value (TMS or XYZ), e.g. https://github.com/mapbox/node-mbtiles/issues/1

alphabetasoup
  • 8,718
  • 4
  • 38
  • 78
  • Thanks for response. I've managed to check corner coordinates and it's really ok in degrees, so this projection is ok as well. I've found the pattern here is z/y/x but no issue I guess. Not quite sure yet what's around this y-tile value but will get my answers later probably. – Peter.k Jun 05 '19 at 21:20