I am working on a solution to download map tiles based on given location:(latitude, longitude) and zoom level

Followed https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

The key concept is to convert (latitude, longitude) to tile reference, eg. javascript code:

function long2tileX(lon,zoom) { return (Math.floor((lon+180)/360*Math.pow(2,zoom))); }

function lat2tileY(lat,zoom) { return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom))); }

For sample location (63.433772, 10.393456) and zoom level (17) this formulas return (69320, 35421) which is exactly what's needed to get the tile:


Now I am struggling to achieve the same with ArcGIS maps. The following CRS object is supplied:

{ "Name":"Geocache Basis", "Crs":{ "Resolutions":[ 21674.7100160867, 10837.355008043351, 5418.6775040216753, 2709.3387520108377, 1354.6693760054188, 677.33468800270941, 338.66734400135471, 169.33367200067735, 84.666836000338677, 42.333418000169338, 21.166709000084669, 10.583354500042335, 5.2916772500211673, 2.6458386250105836, 1.3229193125052918, 0.66145965625264591, 0.33072982812632296, 0.16536491406316148 ], "OriginX":-2500000.0, "OriginY":9045984.0, "Srid":"EPSG:32633", "Definition":"+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" }, "Attribution":"Kartverket, Geovekst og kommuner - Geodata AS", "MapProvider":"arcgis" }

Tried to use proj4 and define EPSG:32633 with 'Definition' field value, then do a projection, but that didn't get me anywhere close to calculating the respective tile coordinates, which I experimentally determined to be (47333, 65439) https://services.geodataonline.no/arcgis/rest/services/Geocache_UTM33_WGS84/GeocacheBasis/MapServer/tile/17/47333/65439

What mathematical formula can I apply to follow the same scenario and get an accurate result?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.