geopandas.GeoSeries.to_crs#
- GeoSeries.to_crs(crs=None, epsg=None)#
返回一个
GeoSeries
将所有几何图形转换到新的坐标参考系。将GeoSeries中的所有几何图形转换到不同的坐标参考系。这个
crs
必须设置当前GeoSeries的属性。要么crs
或epsg
可以为输出指定。此方法将变换所有对象中的所有点。它没有概念,也没有投影整个几何图形。假定所有连接点的线段都是当前投影中的直线,而不是测地线。穿过日期线(或其他投影边界)的对象将具有不受欢迎的行为。
- 参数
- crs :pyproj.crs,如果是可选的 epsg 是指定的Pyproj.crs,可选,如果
该值可以是接受的任何值
pyproj.CRS.from_user_input()
例如,授权字符串(例如“EPSG:4326”)或WKT字符串。- epsg :int,在以下情况下可选 crs 是指定的Int,如果是可选的
指定输出投影的EPSG代码。
- 退货
- GeoSeries
参见
GeoSeries.set_crs
分配CRS
示例
>>> from shapely.geometry import Point >>> s = geopandas.GeoSeries([Point(1, 1), Point(2, 2), Point(3, 3)], crs=4326) >>> s 0 POINT (1.00000 1.00000) 1 POINT (2.00000 2.00000) 2 POINT (3.00000 3.00000) dtype: geometry >>> s.crs <Geographic 2D CRS: EPSG:4326> Name: WGS 84 Axis Info [ellipsoidal]: - Lat[north]: Geodetic latitude (degree) - Lon[east]: Geodetic longitude (degree) Area of Use: - name: World - bounds: (-180.0, -90.0, 180.0, 90.0) Datum: World Geodetic System 1984 - Ellipsoid: WGS 84 - Prime Meridian: Greenwich
>>> s = s.to_crs(3857) >>> s 0 POINT (111319.491 111325.143) 1 POINT (222638.982 222684.209) 2 POINT (333958.472 334111.171) dtype: geometry >>> s.crs <Projected CRS: EPSG:3857> Name: WGS 84 / Pseudo-Mercator Axis Info [cartesian]: - X[east]: Easting (metre) - Y[north]: Northing (metre) Area of Use: - name: World - 85°S to 85°N - bounds: (-180.0, -85.06, 180.0, 85.06) Coordinate Operation: - name: Popular Visualisation Pseudo-Mercator - method: Popular Visualisation Pseudo Mercator Datum: World Geodetic System 1984 - Ellipsoid: WGS 84 - Prime Meridian: Greenwich