dtoolkit.geoaccessor.geodataframe.cncrs_offset#
- dtoolkit.geoaccessor.geodataframe.cncrs_offset(df: GeoDataFrame, /, from_crs: Literal['wgs84', 'gcj02', 'bd09'], to_crs: Literal['wgs84', 'gcj02', 'bd09']) GeoDataFrame [source]#
Fix the offset of the coordinates in China.
Details see: Restrictions on geographic data in China.
The following CRS could be transformed:
WGS-84
toGCJ-02
.WGS-84
toBD-09
.GCJ-02
toWGS-84
.GCJ-02
toBD-09
.BD-09
toWGS-84
.BD-09
toGCJ-02
.
- Parameters:
- from_crs, to_crs{‘wgs84’, ‘gcj02’, ‘bd09’}
The CRS of the input and output.
- Returns:
- GeoDataFrame
Replaced original geometry.
- Raises:
- ValueError
If the CRS is not
ESGP:4326
.
See also
Examples
>>> import dtoolkit.geoaccessor >>> import pandas as pd >>> df = pd.DataFrame( ... { ... "x": [114.21892734521, 128.543, 1], ... "y": [29.575429778924, 37.065, 1], ... }, ... ).from_xy("x", "y", crs=4326) >>> df x y geometry 0 114.218927 29.57543 POINT (114.21893 29.57543) 1 128.543000 37.06500 POINT (128.54300 37.06500) 2 1.000000 1.00000 POINT (1.00000 1.00000) >>> df.cncrs_offset(from_crs="bd09", to_crs="gcj02") x y geometry 0 114.218927 29.57543 POINT (114.21243 29.56938) 1 128.543000 37.06500 POINT (128.53659 37.05875) 2 1.000000 1.00000 POINT (0.99349 0.99399)