Skip to content

antimeridian_cutting problem #801

@dzanaga

Description

@dzanaga

Following the discussion at geopandas/geopandas#448 I was trying the solution proposed by @snowman2 (based on fiona) to transform the Sentinel 2 epsg zone 32601 to lat lon:

epsg_number = 32601
epsg_gdf = load_epsg_gdf(epsg_number)

fig, ax = plt.subplots()

epsg_gdf.plot(ax=ax, facecolor='none', edgecolor='m')

Figure 13

Projecting it to lat lon using the solution proposed yields this:
Figure 12

which looks good overall, except for one tile (01RBK):
(zoom on the left side)
Figure 12 (1)

(zoom on the right)
Figure 12 (2)

There seems to be an issue with the projection of the bottom left point.

To reproduce:

from functools import partial

import geopandas
import fiona
from fiona.transform import transform_geom
from shapely.geometry import mapping, shape, box

%matplotlib inline

gdf = gpd.GeoDataFrame([{'tile': '01RBK', 'geometry': box(199980., 2890200.,  309780., 3000000.)}], crs={'init': 'epsg:32601'})

def base_transformer(geom, src_crs, dst_crs):
    return shape(
        transform_geom(
            src_crs=src_crs,
            dst_crs=dst_crs,
            geom=mapping(geom),
            antimeridian_cutting=True,
        )
    )

forward_transformer = partial(base_transformer, src_crs=gdf.crs, dst_crs="epsg:4326")
reverse_transformer = partial(base_transformer, src_crs="epsg:4326", dst_crs=gdf.crs)
with fiona.Env(OGR_ENABLE_PARTIAL_REPROJECTION="YES"):
    gdf2 = gdf.set_geometry(gdf.geometry.apply(forward_transformer))

Env info:

fiona                     1.8.6            py37hf242f0b_3    conda-forge
gdal                      2.4.1           py37h5f563d9_10    conda-forge
libgdal                   2.4.1               hc4f5fd6_10    conda-forge

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions