ошибка: для распаковки требуется буфер в 16 байт - PullRequest
0 голосов
/ 26 июня 2019

Следующий код дает мне ошибку: «ошибка: для распаковки требуется буфер в 16 байт»

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
import cartopy
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader

# Reading the data from shapefiles .shp
basin = Reader('C:\\...\\BasinCOL2014.shp')

fig = plt.figure (figsize = (10,5))
ax = fig.add_subplot (1, 1, 1, projection = ccrs.PlateCarree(central_longitude=0, globe=None))
ax.set_extent ([-66.0, -80.0, -5.0, 13.0])
ax.gridlines (draw_labels = True)

# Aditional elements to display in map
ax.coastlines  (resolution = '10m')
ax.add_feature (cartopy.feature.RIVERS, linewidth=4)
ax.add_geometries (basin.geometries(),     crs = ccrs.Geodetic(), edgecolor = 't', facecolor = 'none')

Я ожидаю, что результатом будет карта со всеми тремя элементами: Береговые линии, Реки и Бассейн. Я получил только два из них (см. Изображение ниже).

Частичные результаты я получаю из кода выше

В настоящее время установлен Anaconda Navigator 1.9.7
- Блокнот Jupyter 5.7.8
- Cartopy 0.17.0

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-6-628330e4110c> in <module>
     12 ax.coastlines  (resolution = '10m')
     13 ax.add_feature (cartopy.feature.RIVERS, linewidth=4)
---> 14 ax.add_geometries (basin.geometries(),     crs = ccrs.Geodetic(), edgecolor = 't', facecolor = 'none')

C:\ProgramData\Anaconda3\lib\site-packages\cartopy\mpl\geoaxes.py in add_geometries(self, geoms, crs, **kwargs)
    586         """
    587         styler = kwargs.pop('styler', None)
--> 588         feature = cartopy.feature.ShapelyFeature(geoms, crs, **kwargs)
    589         return self.add_feature(feature, styler=styler)
    590 

C:\ProgramData\Anaconda3\lib\site-packages\cartopy\feature\__init__.py in __init__(self, geometries, crs, **kwargs)
    229         """
    230         super(ShapelyFeature, self).__init__(crs, **kwargs)
--> 231         self._geoms = tuple(geometries)
    232 
    233     def geometries(self):

C:\ProgramData\Anaconda3\lib\site-packages\cartopy\io\shapereader.py in geometries(self)
    234         geometry_factory = self._geometry_factory
    235         for i in range(self._reader.numRecords):
--> 236             shape = self._reader.shape(i)
    237             yield _make_geometry(geometry_factory, shape)
    238 

C:\ProgramData\Anaconda3\lib\site-packages\shapefile.py in shape(self, i)
    811                     return k
    812         shp.seek(offset)
--> 813         return self.__shape()
    814 
    815     def shapes(self):

C:\ProgramData\Anaconda3\lib\site-packages\shapefile.py in __shape(self)
    749         # Read m extremes and values
    750         if shapeType in (13,15,18,23,25,28,31):
--> 751             (mmin, mmax) = unpack("<2d", f.read(16))
    752             # Measure values less than -10e38 are nodata values according to the spec
    753             record.m = []

error: unpack requires a buffer of 16 bytes
...