'LineString' object has no attribute 'exterior'
时间: 2023-11-09 09:09:31 浏览: 49
这个错误通常是因为你正在尝试从一个 LineString 对象中获取 exterior 属性,但是 LineString 对象没有 exterior 属性。exterior 属性只存在于 Polygon 对象中,表示多边形的外部边界。
如果你想获取 LineString 对象的端点坐标,可以使用 coords 属性。例如,假设你有一个名为 line 的 LineString 对象,你可以使用以下代码获取其起点和终点坐标:
```
start_point = line.coords[0]
end_point = line.coords[-1]
```
相关问题
LineString' object has no attribute 'exterior
引用\[1\]中提到,LineString对象没有exterior属性。因此,无法在LineString对象中访问exterior属性。 LineString对象只有一个线段,没有内部和外部区域。它只是由一系列坐标点组成的线段。所以,无法在LineString对象中找到exterior属性。
#### 引用[.reference_title]
- *1* *2* [python之shapely库的使用](https://blog.csdn.net/weixin_48127633/article/details/121792011)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Shapely地理空间几何库,使用手册(英)](https://blog.csdn.net/weixin_39726044/article/details/110911035)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
AttributeError: 'LineString' object has no attribute 'exterior'
这个错误通常发生在使用 shapely 库中的 LineString 对象时。在 shapely 中,exterior 属性只适用于 Polygon 对象,而不适用于 LineString 对象。
如果你正在尝试访问 LineString 对象的外部边界,可以尝试使用 bounds 属性来获取最小外接矩形的边界框。示例如下:
```python
line = LineString([(0, 0), (1, 1), (2, 2)])
bounds = line.bounds
print(bounds)
```
这将输出边界框的最小和最大坐标值。如果你需要其他操作,请提供更多的上下文信息,以便我能够更好地帮助你解决问题。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)