GeoPandas 0.8 implements support for different projections assigned to different geometry columns of the same GeoDataFrame. The projection is now stored together with geometries per column (directly on the GeometryArray level).
GeoPandas 0.8 实现了对分配给同一 GeoDataFrame 的不同几何列的不同投影的支持。投影现在与每列的几何图形一起存储(直接在 GeometryArray 级别)。
Note that if GeometryArray has an assigned projection, it cannot be overridden by an another inconsistent projection during the creation of a GeoSeries or GeoDataFrame:
请注意,如果 GeometryArray 具有分配的投影,则在创建 GeoSeries 或 GeoDataFrame 期间它不能被另一个不一致的投影覆盖:
>>> array.crs
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
...
>>> GeoSeries(array, crs=4326) # crs=4326 is okay, as it matches the existing CRS
>>> GeoSeries(array, crs=3395) # crs=3395 is forbidden as array already has CRS
ValueError: CRS mismatch between CRS of the passed geometries and 'crs'. Use 'GeoSeries.set_crs(crs, allow_override=True)' to overwrite CRS or 'GeoSeries.to_crs(crs)' to reproject geometries.
GeoSeries(array, crs=3395).crs
If you want to overwrite the projection, you can then assign it to the GeoSeries manually or re-project geometries to the target projection using either GeoSeries.set_crs(epsg=3395, allow_override=True)
or GeoSeries.to_crs(epsg=3395)
.
如果要覆盖投影,则可以手动将其分配给 GeoSeries 或使用 GeoSeries.set_crs(epsg=3395, allow_override=True) 或 GeoSeries.to_crs(epsg=3395) 将几何重新投影到目标投影。
All GeometryArray-based operations preserve projection; however, if you loop over a column containing geometry, this information might be lost.
所有基于 GeometryArray 的操作都保留投影;但是,如果您遍历包含几何的列,则此信息可能会丢失。