When attempting to use Cartopy to plot rivers, I'm getting a URL error. I'm not even sure the rivers feature will plot what I want...I'm attempting to get the Galveston Ship Channel to show on my map.
Here's the error I get:
C:ProgramDataAnaconda3libsite-packagescartopyio\__init__.py:260: DownloadWarning: Downloading: https://naciscdn.org/naturalearth/10m/physical/ne_10m_rivers_lake_centerlines.zip
warnings.warn('Downloading: {}'.format(url), DownloadWarning)
Traceback (most recent call last):
File "C:ProgramDataAnaconda3liburllib
equest.py", line 1354, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:ProgramDataAnaconda3libhttpclient.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:ProgramDataAnaconda3libhttpclient.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:ProgramDataAnaconda3libhttpclient.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:ProgramDataAnaconda3libhttpclient.py", line 1010, in _send_output
self.send(msg)
File "C:ProgramDataAnaconda3libhttpclient.py", line 950, in send
self.connect()
File "C:ProgramDataAnaconda3libhttpclient.py", line 1417, in connect
super().connect()
File "C:ProgramDataAnaconda3libhttpclient.py", line 921, in connect
self.sock = self._create_connection(
File "C:ProgramDataAnaconda3libsocket.py", line 787, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:ProgramDataAnaconda3libsocket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
And here's the code:
import matplotlib.pyplot as plt
import datetime as dt
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
import cartopy.feature as cfeature
from metpy.plots import USCOUNTIES
ship_lon, ship_lat = -94.80234, 29.31221
ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extent([-95.5, -94.1, 28.8, 29.8])
ax.add_feature(USCOUNTIES.with_scale('500k'),facecolor='none', edgecolor='gray',linewidth=0.5)
ax.add_feature(cfeature.NaturalEarthFeature('physical', 'land', '10m', edgecolor='black', facecolor='#d4d4d4'))
ax.add_feature(cfeature.NaturalEarthFeature('physical', 'ocean', '10m', facecolor='lightblue'))
ax.add_feature(cfeature.NaturalEarthFeature('physical', 'rivers_lake_centerlines', '10m', facecolor='lightblue'))
ax.set_title('Hunter-T Approximate Location at Time of Incident',loc='left',fontsize=10,fontweight='bold')
plt.scatter(ship_lon, ship_lat, marker='*', color='black',s=12, zorder=10)
plt.text(ship_lon, ship_lat+.03, 'Vessel Location', fontsize=5, fontweight='bold',horizontalalignment='center')
plt.savefig(fname='vessel_location.png',bbox_inches='tight', dpi=600)
plt.close()
If I leave the rivers line out, this is my output. The marker with the vessel location is actually a ship channel. I'm trying to get that body of water to display. I tried searching for a shapefile, but I'm unsure of what shapefile might plot that feature. Or is there a better way to go about plotting a high-res map of this area?
See Question&Answers more detail:
os