English 中文(简体)
为什么世界妇女运动组织的文件例子不可行?
原标题:Why did the documentation example for OWSLib not work?
  • 时间:2023-08-26 02:16:46
  •  标签:
  • python
  • gis

我愿学习。 或具有以下想法的相当图书馆:我可以下载地理信息系统数据集,作为我的kedro的一部分。 数据处理管道。

我开始学习普惠制读物的例子:

>>> from owslib.wms import WebMapService
>>> wms = WebMapService( http://wms.jpl.nasa.gov/wms.cgi , version= 1.1.1 )
>>> wms.identification.type
 OGC:WMS 
>>> wms.identification.version
 1.1.1 
>>> wms.identification.title
 JPL Global Imagery Service 
>>> wms.identification.abstract
 WMS Server maintained by JPL, worldwide satellite imagery. 

Available layers::

    >>> list(wms.contents)
    [ us_landsat_wgs84 ,  modis ,  global_mosaic_base ,  huemapped_srtm ,
     srtm_mag ,  daily_terra ,  us_ned ,  us_elevation ,  global_mosaic ,
     daily_terra_ndvi ,  daily_aqua_ndvi ,  daily_aqua_721 ,  daily_planet ,
     BMNG ,  srtmplus ,  us_colordem , None,  daily_aqua ,  worldwind_dem ,
     daily_terra_721 ]

Details of a layer::

    >>> wms[ global_mosaic ].title
     WMS Global Mosaic, pan sharpened 
    >>> wms[ global_mosaic ].boundingBoxWGS84
    (-180.0, -60.0, 180.0, 84.0)
    >>> wms[ global_mosaic ].crsOptions
    [ EPSG:4326 ,  AUTO:42003 ]
    >>> wms[ global_mosaic ].styles
    { pseudo_bright : { title :  Pseudo-color image (Uses IR and Visual bands,
    542 mapping), gamma 1.5 },  pseudo : { title :  (default) Pseudo-color
    image, pan sharpened (Uses IR and Visual bands, 542 mapping), gamma 1.5 },
     visual : { title :  Real-color image, pan sharpened (Uses the visual
    bands, 321 mapping), gamma 1.5 },  pseudo_low : { title :  Pseudo-color
    image, pan sharpened (Uses IR and Visual bands, 542 mapping) },
     visual_low : { title :  Real-color image, pan sharpened (Uses the visual
    bands, 321 mapping) },  visual_bright : { title :  Real-color image (Uses
    the visual bands, 321 mapping), gamma 1.5 }}

Available methods, their URLs, and available formats::

    >>> [op.name for op in wms.operations]
    [ GetTileService ,  GetCapabilities ,  GetMap ]
    >>> wms.getOperationByName( GetMap ).methods
    { Get : { url :  http://wms.jpl.nasa.gov/wms.cgi? }}
    >>> wms.getOperationByName( GetMap ).formatOptions
    [ image/jpeg ,  image/png ,  image/geotiff ,  image/tiff ]

That s everything needed to make a request for imagery::

    >>> img = wms.getmap(   layers=[ global_mosaic ],
    ...                     styles=[ visual_bright ],
    ...                     srs= EPSG:4326 ,
    ...                     bbox=(-112, 36, -106, 41),
    ...                     size=(300, 250),
    ...                     format= image/jpeg ,
    ...                     transparent=True
    ...                     )
    >>> out = open( jpl_mosaic_visb.jpg ,  wb )
    >>> out.write(img.read())
    >>> out.close()

但我几乎立即陷入错误。

(vewnv) [galen@orcus Downloads]$ python
Python 3.11.3 (main, Jun  5 2023, 09:32:32) [GCC 13.1.1 20230429] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from owslib.wms import WebMapService
>>> wms = WebMapService( http://wms.jpl.nasa.gov/wms.cgi , version= 1.1.1 )
Traceback (most recent call last):
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connection.py", line 203, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 962, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connection.py", line 395, in request
    self.endheaders()
  File "/usr/lib/python3.11/http/client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1038, in _send_output
    self.send(msg)
  File "/usr/lib/python3.11/http/client.py", line 976, in send
    self.connect()
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connection.py", line 243, in connect
    self.sock = self._new_conn()
                ^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connection.py", line 210, in _new_conn
    raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPConnection object at 0x7f77cd407310>: Failed to resolve  wms.jpl.nasa.gov  ([Errno -2] Name or service not known)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host= wms.jpl.nasa.gov , port=80): Max retries exceeded with url: /wms.cgi?service=WMS&request=GetCapabilities&version=1.1.1 (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7f77cd407310>: Failed to resolve  wms.jpl.nasa.gov  ([Errno -2] Name or service not known)"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/owslib/wms.py", line 50, in WebMapService
    return wms111.WebMapService_1_1_1(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/owslib/map/wms111.py", line 75, in __init__
    self._capabilities = reader.read(self.url, timeout=self.timeout)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/owslib/map/common.py", line 65, in read
    u = openURL(spliturl[0], spliturl[1], method= Get ,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/owslib/util.py", line 209, in openURL
    req = requests.request(method.upper(), url_base, headers=headers, **rkwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/galen/Downloads/vewnv/lib/python3.11/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host= wms.jpl.nasa.gov , port=80): Max retries exceeded with url: /wms.cgi?service=WMS&request=GetCapabilities&version=1.1.1 (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7f77cd407310>: Failed to resolve  wms.jpl.nasa.gov  ([Errno -2] Name or service not known)"))
最佳回答

实例中使用的服务器(http://wms.jpl.nasa.gov)正在开始逐渐淘汰。 https://web.archive.org/web/20141109174905/http://wms.jpl.nasa.gov/“rel=“nofollow noreferer”>toward the end of2014,已不能再查阅。

该网站在退役前的电文指出,它将由地球科学数据和信息系统项目提供的“全球图像服务”取代:>。

A cursory clickthrough of the linked replacement site shows that NASA still provides a WMS service, albeit through different Service Endpoints listed on the Access Basics documentation page. Replacing the dead link in your code with a listed service endpoint best suiting your needs should get you back on the right track.

有趣的是,在README中,你引述的例子似乎将这一代码置于17年前<<<>em><<<<<<<<<<>>>>a>,因此其老旧且不令人惊讶。 我可能考虑提出一个问题,以便使其得到更有意义的更新。

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签