dtoolkit.geoaccessor.geoseries.cncrs_offset#

dtoolkit.geoaccessor.geoseries.cncrs_offset(s: GeoSeries, /, from_crs: Literal['wgs84', 'gcj02', 'bd09'], to_crs: Literal['wgs84', 'gcj02', 'bd09']) GeoSeries[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 to GCJ-02.

  • WGS-84 to BD-09.

  • GCJ-02 to WGS-84.

  • GCJ-02 to BD-09.

  • BD-09 to WGS-84.

  • BD-09 to GCJ-02.

Parameters:
from_crs, to_crs{‘wgs84’, ‘gcj02’, ‘bd09’}

The CRS of the input and output.

Returns:
GeoSeries

Replaced original geometry.

Raises:
ValueError

If the CRS is not ESGP:4326.

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)