Cartopy调用天地图API,在服务器端实现。并解决调用出现的:418问题


使用python 的 Cartopy 绘制底图时,其自带的 .stock_img()分辨率较低,不能满足小区域绘制需求,因此调用天地图api实现清晰底图绘制。

获取天地图api

官网注册并申请地图api

api

编辑所需代码

新建文本,复制如下代码,其中

*天地图地图服务二级域名包括t0-t7,您可以随机选择使用,如http://t2.tianditu.gov.cn/vec_c/wmts?tk=您的密钥
参考http://lbs.tianditu.gov.cn/server/MapService.html

并替换自己的key

# 矢量底图-经纬度
class MAP_vec_c(GoogleWTS):
    def _image_url(self, tile):
        x, y, z = tile
        key = '**********'
        url = 'http://t0.tianditu.gov.cn/DataServer?T=vec_c&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, key)
        return url

# 矢量底图-墨卡托
class MAP_vec_w(GoogleWTS):
    def _image_url(self, tile):
        x, y, z = tile
        key = '**********'
        url = 'http://t0.tianditu.gov.cn/DataServer?T=vec_w&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, key)
        return url

# 矢量注记-经纬度
class MAP_cva_c(GoogleWTS):
    def _image_url(self, tile):
        x, y, z = tile
        key = '**********'
        url = 'http://t0.tianditu.gov.cn/DataServer?T=cva_c&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, key)
        return url

# 矢量注记-墨卡托
class MAP_cva_w(GoogleWTS):
    def _image_url(self, tile):
        x, y, z = tile
        key = '**********'
        url = 'http://t0.tianditu.gov.cn/DataServer?T=cva_w&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, key)
        return url

# 影像底图-经纬度
class MAP_img_c(GoogleWTS):
    def _image_url(self, tile):
        x, y, z = tile
        key = '**********'
        url = 'http://t0.tianditu.gov.cn/DataServer?T=img_c&x=%s&y=%s&l=%s&tk=%s' % (x, y, z, key)
        return url

# 影像底图-墨卡托
class MAP_img_w(GoogleWTS
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

longjs17

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值