geopandas.GeoSeries.to_crs#
- GeoSeries.to_crs(crs=None, epsg=None)[来源]#
返回一个
GeoSeries,其中所有几何体都转换为新的坐标参考系统。将GeoSeries中的所有几何体转换为不同的坐标参考系统。当前GeoSeries的
crs属性必须设置。可以为输出指定crs或epsg。该方法将转换所有对象中的所有点。它没有投影整个几何体的概念。所有连接点的线段被假定为当前投影中的直线,而不是测地线。跨越日期变更线(或其他投影边界)的对象将会出现不良行为。
- Parameters:
- crspyproj.CRS, optional if epsg is specified
值可以是任何被
pyproj.CRS.from_user_input()接受的内容,例如一个授权字符串(例如“EPSG:4326”)或一个WKT字符串。- epsgint, optional if crs is specified
指定输出投影的EPSG代码。
- Returns:
- 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 1) 1 POINT (2 2) 2 POINT (3 3) 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