为什么是Geoseries.翻译不工作,即使是用geoandas给出的例子?



我使用Geoopandas提供的示例,但无法获得geoseries。翻译成工作

import os, geopandas
from shapely.geometry import Point, LineString, Polygon
test = geopandas.GeoSeries(
[
Point(1, 1),
LineString([(1, -1), (1, 0)]),
Polygon([(3, -1), (4, 0), (3, 1)]),
]
)
test.translate(2, 3)
print(test)

打印语句产生:

0 POINT (1.00000)

1 LINESTRING (100000 - 100000, 100000 0.00000)

2 POLYGON((3.00000 -1.00000, 4.00000 0.00000, 3…)dtype:几何

任何想法如何解决这个问题,所以我可以使用翻译函数?

translate不能正常工作,而是返回一个新的(已翻译的)GeoSeries。你需要将它赋值给一个新变量或替换原来的变量。

import os, geopandas
from shapely.geometry import Point, LineString, Polygon
test = geopandas.GeoSeries(
[
Point(1, 1),
LineString([(1, -1), (1, 0)]),
Polygon([(3, -1), (4, 0), (3, 1)]),
]
)
translated = test.translate(2, 3)
print(translated)
0                              POINT (3.00000 4.00000)
1        LINESTRING (3.00000 2.00000, 3.00000 3.00000)
2    POLYGON ((5.00000 2.00000, 6.00000 3.00000, 5....
dtype: geometry

相关内容

最新更新