SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.38k stars 361 forks source link

How to use TDT wmts in the cartopy? #1601

Open xpbliss opened 4 years ago

xpbliss commented 4 years ago

I use the TDT wmts in the cartopy. as the following:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

ax = plt.axes(projection=ccrs.epsg(3413))
ax.add_wmts('http://t0.tianditu.gov.cn/img_w/wmts?request=GetCapabilities&service=wmts?tk=mykey',layer_name='img_w')
plt.show()

there are always an error:

  File "<string>", line 1 lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: span line 1 and p, line 1, column 1929

the wmts response is:

 This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
<ows:ServiceIdentification>
<ows:Title>在线地图服务</ows:Title>
<ows:Abstract>基于OGC标准的地图服务</ows:Abstract>
<ows:Keywords>
<ows:Keyword>OGC</ows:Keyword>
</ows:Keywords>
<ows:ServiceType codeSpace="wmts"/>
<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
<ows:Fees>none</ows:Fees>
<ows:AccessConstraints>none</ows:AccessConstraints>
</ows:ServiceIdentification>
<ows:ServiceProvider>
<ows:ProviderName>天地图有限公司</ows:ProviderName>
<ows:ProviderSite>http://www.tianditu.com</ows:ProviderSite>
<ows:ServiceContact>
<ows:IndividualName>Mr Liu</ows:IndividualName>
<ows:PositionName>Software Engineer</ows:PositionName>
<ows:ContactInfo>
<ows:Phone>
<ows:Voice>010-88187700</ows:Voice>
<ows:Facsimile>010-88187700</ows:Facsimile>
</ows:Phone>
<ows:Address>
<ows:DeliveryPoint>北京市顺义区国家地理信息科技产业园天地图大厦(机场东路与龙塘路交叉口)</ows:DeliveryPoint>
<ows:City>北京市</ows:City>
<ows:AdministrativeArea>北京市</ows:AdministrativeArea>
<ows:Country>中国</ows:Country>
<ows:PostalCode>101399</ows:PostalCode>
<ows:ElectronicMailAddress>tianditu.com</ows:ElectronicMailAddress>
</ows:Address>
<ows:OnlineResource xlink:type="simple" xlink:href="http://www.tianditu.com"/>
</ows:ContactInfo>
</ows:ServiceContact>
</ows:ServiceProvider>
<ows:OperationsMetadata>
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://t0.tianditu.gov.cn/img_w/wmts?">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>KVP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetTile">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://t0.tianditu.gov.cn/img_w/wmts?">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>KVP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
</ows:OperationsMetadata>
<Contents>
<Layer>
<ows:Title>img</ows:Title>
<ows:Abstract>img</ows:Abstract>
<ows:Identifier>img</ows:Identifier>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-20037508.3427892 -20037508.3427892</ows:LowerCorner>
<ows:UpperCorner>20037508.3427892 20037508.3427892</ows:UpperCorner>
</ows:WGS84BoundingBox>
<ows:BoundingBox>
<ows:LowerCorner>-20037508.3427892 -20037508.3427892</ows:LowerCorner>
<ows:UpperCorner>20037508.3427892 20037508.3427892</ows:UpperCorner>
</ows:BoundingBox>
<Style>
<ows:Identifier>default</ows:Identifier>
</Style>
<Format>tiles</Format>
<TileMatrixSetLink>
<TileMatrixSet>w</TileMatrixSet>
</TileMatrixSetLink>
</Layer>
<TileMatrixSet>
<ows:Identifier>w</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:EPSG::900913</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>1</ows:Identifier>
<ScaleDenominator>2.958293554545656E8</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>2</MatrixWidth>
<MatrixHeight>2</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>2</ows:Identifier>
<ScaleDenominator>1.479146777272828E8</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>4</MatrixWidth>
<MatrixHeight>4</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>3</ows:Identifier>
<ScaleDenominator>7.39573388636414E7</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>8</MatrixWidth>
<MatrixHeight>8</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>4</ows:Identifier>
<ScaleDenominator>3.69786694318207E7</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>16</MatrixWidth>
<MatrixHeight>16</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>5</ows:Identifier>
<ScaleDenominator>1.848933471591035E7</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>32</MatrixWidth>
<MatrixHeight>32</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>6</ows:Identifier>
<ScaleDenominator>9244667.357955175</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>64</MatrixWidth>
<MatrixHeight>64</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>7</ows:Identifier>
<ScaleDenominator>4622333.678977588</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>128</MatrixWidth>
<MatrixHeight>128</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>8</ows:Identifier>
<ScaleDenominator>2311166.839488794</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>256</MatrixWidth>
<MatrixHeight>256</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>9</ows:Identifier>
<ScaleDenominator>1155583.419744397</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>512</MatrixWidth>
<MatrixHeight>512</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>10</ows:Identifier>
<ScaleDenominator>577791.7098721985</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>1024</MatrixWidth>
<MatrixHeight>1024</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>11</ows:Identifier>
<ScaleDenominator>288895.85493609926</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>2048</MatrixWidth>
<MatrixHeight>2048</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>12</ows:Identifier>
<ScaleDenominator>144447.92746804963</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>4096</MatrixWidth>
<MatrixHeight>4096</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>13</ows:Identifier>
<ScaleDenominator>72223.96373402482</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>8192</MatrixWidth>
<MatrixHeight>8192</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>14</ows:Identifier>
<ScaleDenominator>36111.98186701241</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>16384</MatrixWidth>
<MatrixHeight>16384</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>15</ows:Identifier>
<ScaleDenominator>18055.990933506204</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>32768</MatrixWidth>
<MatrixHeight>32768</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>16</ows:Identifier>
<ScaleDenominator>9027.995466753102</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>65536</MatrixWidth>
<MatrixHeight>65536</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>17</ows:Identifier>
<ScaleDenominator>4513.997733376551</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>131072</MatrixWidth>
<MatrixHeight>131072</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>18</ows:Identifier>
<ScaleDenominator>2256.998866688275</ScaleDenominator>
<TopLeftCorner>20037508.3427892 -20037508.3427892</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>262144</MatrixWidth>
<MatrixHeight>262144</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
</Contents>
</Capabilities>
QuLogic commented 4 years ago

Did you replace mykey with an actual key? Because if you go to the URL you specified, it gives a 418 page, which would be consistent with the error that's referring to p and span.

smartlixx commented 4 years ago

You can check the following jupyter notebook:

https://nbviewer.jupyter.org/github/smartlixx/AS213_Python_in_Atmos_Sciences/blob/master/cartopy/Cartopy_2.ipynb

smartlixx commented 3 years ago

I just want to get a feed back here: is it a good idea to have TDT wmts available in cartopy? It's from China's official survey department, and provides map in vector, image, terrain format and English/Chinese labels (separate, transparent layer).

greglucas commented 3 years ago

I don't see an issue with adding something like that to the io section, we already have several tile resources and that seems like it would be useful.