作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在使用 smopy 时生成 osm 贴图,但我一直收到禁止的错误,这是代码集:
box = (lat[region].min(), lon[region].min(),
lat[region].max(), lon[region].max())
m = smopy.Map(box, z=12)
m.show_ipython()
然后我得到以下错误:
HTTPError Traceback (most recent call last)
<ipython-input-48-1060c6eba6aa> in <module>
1 box = (lat[region].min(), lon[region].min(),
2 lat[region].max(), lon[region].max())
----> 3 m = smopy.Map(box, z=12)
4 m.show_ipython()
~\AppData\Roaming\Python\Python37\site-packages\smopy.py in __init__(self, *args, **kwargs)
290 self.ymin = min(self.box_tile[1], self.box_tile[3])
291 self.img = None
--> 292 self.fetch()
293
294 def to_pixels(self, lat, lon=None):
~\AppData\Roaming\Python\Python37\site-packages\smopy.py in fetch(self)
322 """Fetch the image from OSM's servers."""
323 if self.img is None:
--> 324 self.img = fetch_map(self.box_tile, self.z)
325 self.w, self.h = self.img.size
326 return self.img
~\AppData\Roaming\Python\Python37\site-packages\smopy.py in fetch_map(box, z)
63 for y in range(y0, y1 + 1):
64 px, py = TILE_SIZE * (x - x0), TILE_SIZE * (y - y0)
---> 65 img.paste(fetch_tile(x, y, z), (px, py))
66 return img
67
~\AppData\Roaming\Python\Python37\site-packages\smopy.py in fetch_tile(x, y, z)
43 """
44 url = get_url(x, y, z)
---> 45 png = BytesIO(urlopen(url).read())
46 img = Image.open(png)
47 img.load()
~\Anaconda31\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):
~\Anaconda31\lib\urllib\request.py in open(self, fullurl, data, timeout)
529 for processor in self.process_response.get(protocol, []):
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532
533 return response
~\Anaconda31\lib\urllib\request.py in http_response(self, request, response)
639 if not (200 <= code < 300):
640 response = self.parent.error(
--> 641 'http', request, response, code, msg, hdrs)
642
643 return response
~\Anaconda31\lib\urllib\request.py in error(self, proto, *args)
567 if http_err:
568 args = (dict, 'default', 'http_error_default') + orig_args
--> 569 return self._call_chain(*args)
570
571 # XXX probably also want an abstract factory that knows when it makes
~\Anaconda31\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
501 for handler in handlers:
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
505 return result
~\Anaconda31\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs)
647 class HTTPDefaultErrorHandler(BaseHandler):
648 def http_error_default(self, req, fp, code, msg, hdrs):
--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
650
651 class HTTPRedirectHandler(BaseHandler):
之前知道代码可以完美运行,我删除了浏览器 cookie 但没有运行,我使用的是最新版本的 python 和 anaconda
最佳答案
重新安装 smopy(获取最新版本),他们已经更改了 tileserver url。那应该工作。
关于python-3.x - HTTP错误 : HTTP Error 403: urlib3 while using smopy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56412237/
我正在尝试在 jupyter 中使用 smopy 和 matplotlib 创建一个动画 map ,但是当我运行代码时,我得到了两个数字而不是一个。第一个数字显示在 map 上方并且是空的。谁能告诉我
我试图在使用 smopy 时生成 osm 贴图,但我一直收到禁止的错误,这是代码集: box = (lat[region].min(), lon[region].min(), lat[r
我是一名优秀的程序员,十分优秀!