关于GIS中Scale和Resolution的那些事儿

       在ArcMap或各类前端地图框架(Leaflet.js、OpenLayers.js、ArcGIS Javascript等)中都需要加载WMTS或ArcGIS Rest服务,但所有的地图显示的原理基本上都是通过坐标和每张瓦片的分辨率来计算行列号的,但WMTS服务标准中其实是没有分辨率Resolution这个参数的,他只给出了比例尺“ScaleDenominator”这个值,需要用户根据这个比例尺自己计算出分辨率。(参考下图,为同一个瓦片服务的Rest服务和WMTS服务)

REST:http://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer

WMTS:https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/WMTS/1.0.0/WMTSCapabilities.xml

同一份瓦片在ArcGIS Rest和WMTS中不一样的比例尺表示

       但在ArcGIS Rest服务中你会发现服务的Lod信息里是同时给出了比例尺“Scale”和分辨率“Resolution”值了的。有心读者读到这里和看到下面的图片时,应该会有两个疑惑。

  1. Resolution和Scale的计算公式是什么?
  2. 为什么同一份已经切好了的瓦片,在ArcGIS Rest服务和WMTS服务的比例尺不一样?

 

一、Scale和 Resolution的计算公示

案例一:如果地图的坐标单位是米,dpi为96

 参考: https://blog.csdn.net/redsky200905/article/details/84369213

 

1英寸=2.54厘米;

1英寸=96像素;

最终换算的单位是米;

如果当前地图比例尺为1:125000000,则代表图上1米实地125000000米;

米和像素间的换算公式:

1英寸=0.0254米=96像素

1像素=0.0254/96 米

则根据1:125000000比例尺,图上1像素代表实地距离是 125000000*0.0254/96 = 33072.9166666667米。

 

以上图第0级为例,比例尺为 Scale=591657527.591555,Resolution=156543.03392800014

 

591657527.591555*0.0254/96 =156,542.7208419323

591657527.591555*0.0254000508/96 =156,543.0339273739

 

我们这个换算结果和切片的结果略微有0.07米的误差。这个误差产生的原因是英寸换算厘米的参数决定的,server使用的换算参数1英寸约等于0.0254000508米。

 

       关于1英寸单位换算有以下文献说明

 

参考:http://scienceworld.wolfram.com/physics/Inch.html

        An nonmetric unit of length, originally defined as the lengths of three "average size" barleycorns laid end-to-end, but now more rationally defined as 2.54 cm. An older definition no longer used was 1 meter= 39.37 inches, giving 2.54000508 cm/inch.

12 inches are called 1 foot.

 

案例二:如果地理坐标系是wgs84,地图的单位是度,dpi为96

 经纬度坐标系的比例尺和分辨率

       Server中度和米之间的换算参数: 1 度约等于 111194.872221777 米

接下来就需要进行度和像素间的换算:

当比例尺为1:64000000米时,相当于1像素 = 64000000*0.0254000508/96 = 16933.3672米,再将米转换为度 16933.3672/ 111194.872221777 = 0.1522855043731385 度

 

       因此当地图单位为度时,近似计算在1:64000000 对应的Resolution为0.1522855043731385度。

 

 二、WMTS服务中的Scale和ArcGIS Rest服务中不一样的原因

       最核心的原因是因为DPI计算方式不一样!!!

WMTS assumes a DPI 90.7 instead of 96 as is clearly documented in the WMTSCapabilities document which states,

        "The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel)."

0.28 mm per pixel = 0.0110236 inches per pixel or 90.71446714322 pixels per inch.

       If you replace 96 in the equation above with 90.71428571429 you'll get the ScaleDenominator value so ESRI used a different conversion constant. After a little research I learned that

        1 in = 2.54 cm (I thought this was an approximation but it's by definition)

Since there are 25.4 mm in one inch then 25.4 / .28 = 90.71428571429 DPI which is the value we're after for DPI. Here is a site which confirms this calculation.

 

       继续以第一图为例:

 

559082264.0285016 * 0.00028 = 156,543.0339279804,这样计算的结果就和ArcGIS Rest中的差不多保持一致了。

 

 

参考文献:

https://blog.csdn.net/redsky200905/article/details/84369213

https://gis.stackexchange.com/questions/123195/why-are-rest-lod-scales-different-to-the-wmts-capabilities-xml

 https://gis.stackexchange.com/questions/29671/mathematics-behind-converting-scale-to-resolution/29733#29733

posted @ 2019-06-05 10:04  cehui0303  阅读(3916)  评论(0编辑  收藏  举报