Раньше я использовал shapely, чтобы создать круг и построить его на ранее заполненном графике. Раньше это работало отлично. Недавно я получаю ошибку индекса. Я разбил свой код даже на самые простые операции, и он не может выполнить даже самый простой круг.
import descartes
import shapely.geometry as sg
import matplotlib.pyplot as plt
circle = sg.Point((0,0)).buffer(1)
# Plot the cricle
fig = plt.figure()
ax = fig.add_subplot(111)
patch = descartes.PolygonPatch(circle)
ax.add_patch(patch)
plt.show()
Ниже приведена ошибка, которую я получаю сейчас. Я чувствую, что это может быть несоответствие новой версии тому, что могло произойти. Я попробовал удалить и переустановить последнюю известную стабильную версию, но это тоже не помогло
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[20], line 6
4 fig = plt.figure()
5 ax = fig.add_subplot(111)
----> 6 patch = descartes.PolygonPatch(circle)
7 ax.add_patch(patch)
8 plt.show()
File ~/env/lib/python3.8/site-packages/descartes/patch.py:87, in PolygonPatch(polygon, **kwargs)
73 def PolygonPatch(polygon, **kwargs):
74 """Constructs a matplotlib patch from a geometric object
75
76 The `polygon` may be a Shapely or GeoJSON-like object with or without holes.
(...)
85
86 """
---> 87 return PathPatch(PolygonPath(polygon), **kwargs)
File ~/env/lib/python3.8/site-packages/descartes/patch.py:62, in PolygonPath(polygon)
58 else:
59 raise ValueError(
60 "A polygon or multi-polygon representation is required")
---> 62 vertices = concatenate([
63 concatenate([asarray(t.exterior)[:, :2]] +
64 [asarray(r)[:, :2] for r in t.interiors])
65 for t in polygon])
66 codes = concatenate([
67 concatenate([coding(t.exterior)] +
68 [coding(r) for r in t.interiors]) for t in polygon])
70 return Path(vertices, codes)
File ~/env/lib/python3.8/site-packages/descartes/patch.py:63, in (.0)
58 else:
59 raise ValueError(
60 "A polygon or multi-polygon representation is required")
62 vertices = concatenate([
---> 63 concatenate([asarray(t.exterior)[:, :2]] +
64 [asarray(r)[:, :2] for r in t.interiors])
65 for t in polygon])
66 codes = concatenate([
67 concatenate([coding(t.exterior)] +
68 [coding(r) for r in t.interiors]) for t in polygon])
70 return Path(vertices, codes)
IndexError: too many indices for array: array is 0-dimensional, but 2 were indexed
Подробнее здесь: https://stackoverflow.com/questions/752 ... ih-shapely
IndexError - Декартовый PolygonPatch с стройной ⇐ Python
Программы на Python
-
Anonymous
1735029955
Anonymous
Раньше я использовал shapely, чтобы создать круг и построить его на ранее заполненном графике. Раньше это работало отлично. Недавно я получаю ошибку индекса. Я разбил свой код даже на самые простые операции, и он не может выполнить даже самый простой круг.
import descartes
import shapely.geometry as sg
import matplotlib.pyplot as plt
circle = sg.Point((0,0)).buffer(1)
# Plot the cricle
fig = plt.figure()
ax = fig.add_subplot(111)
patch = descartes.PolygonPatch(circle)
ax.add_patch(patch)
plt.show()
Ниже приведена ошибка, которую я получаю сейчас. Я чувствую, что это может быть несоответствие новой версии тому, что могло произойти. Я попробовал удалить и переустановить последнюю известную стабильную версию, но это тоже не помогло
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[20], line 6
4 fig = plt.figure()
5 ax = fig.add_subplot(111)
----> 6 patch = descartes.PolygonPatch(circle)
7 ax.add_patch(patch)
8 plt.show()
File ~/env/lib/python3.8/site-packages/descartes/patch.py:87, in PolygonPatch(polygon, **kwargs)
73 def PolygonPatch(polygon, **kwargs):
74 """Constructs a matplotlib patch from a geometric object
75
76 The `polygon` may be a Shapely or GeoJSON-like object with or without holes.
(...)
85
86 """
---> 87 return PathPatch(PolygonPath(polygon), **kwargs)
File ~/env/lib/python3.8/site-packages/descartes/patch.py:62, in PolygonPath(polygon)
58 else:
59 raise ValueError(
60 "A polygon or multi-polygon representation is required")
---> 62 vertices = concatenate([
63 concatenate([asarray(t.exterior)[:, :2]] +
64 [asarray(r)[:, :2] for r in t.interiors])
65 for t in polygon])
66 codes = concatenate([
67 concatenate([coding(t.exterior)] +
68 [coding(r) for r in t.interiors]) for t in polygon])
70 return Path(vertices, codes)
File ~/env/lib/python3.8/site-packages/descartes/patch.py:63, in (.0)
58 else:
59 raise ValueError(
60 "A polygon or multi-polygon representation is required")
62 vertices = concatenate([
---> 63 concatenate([asarray(t.exterior)[:, :2]] +
64 [asarray(r)[:, :2] for r in t.interiors])
65 for t in polygon])
66 codes = concatenate([
67 concatenate([coding(t.exterior)] +
68 [coding(r) for r in t.interiors]) for t in polygon])
70 return Path(vertices, codes)
IndexError: too many indices for array: array is 0-dimensional, but 2 were indexed
Подробнее здесь: [url]https://stackoverflow.com/questions/75287534/indexerror-descartes-polygonpatch-wtih-shapely[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия