question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Projection close to global bbox distorts geometries

See original GitHub issue

Hi,

I noticed that when I reproject a set of polygons in geopandas the polygons get distorted if they are close to the borders of the global coverage. I noticed this behavior when projecting to cylindrical equal area projection, not sure if this more general though. Here’s an example

from shapely.geometry import Point, Polygon
import geopandas as gpd
polys = gpd.GeoSeries([Point(-180,0), Point(0,0), Point(180,0), Point(-180, 90), Point(0, 90), Point(180, 90), Point(-160, 45)])
df = gpd.GeoDataFrame({'geometry': polys, 'df':range(len(polys))}, crs={'init': 'epsg:4326', 'no_defs': True})
df
df.crs
df.geometry = df.geometry.buffer(5)
df.plot()
wgs84 = {u'datum': u'WGS84', u'no_defs': True, u'proj': u'longlat'}
cea = {u'datum': u'WGS84', u'lat_ts': 0, u'lon_0': 0, u'no_defs': True, u'proj': u'cea',u'units': u'm',  u'x_0': 0, u'y_0': 0}
dfcea = df.to_crs(crs=cea).copy()
dfcea.crs
dfcea.plot()

Not sure if this is caused by the way the geometry is treated here or in shapely or geos. I imagine the solution would require an intersection with the global bbox first and then a reprojection. E.g.

bbox = gpd.GeoSeries([Polygon([(-180, 90), (180,90), (180, -90), (-180,-90)])])
dfbbox = gpd.GeoDataFrame({'geometry': bbox, 'gbbox':0}, crs={'init': 'epsg:4326', 'no_defs': True})
dfint = gpd.tools.overlay(df, dfbbox)
dfint.plot()
dfint.to_crs(crs=cea).plot()

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:20 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
snowman2commented, Feb 13, 2020

@Sieboldianus, what you have outlined in your example is similar to the internal logic of the to_crs() method in geopandas.

1reaction
snowman2commented, Feb 13, 2020

Yes, but when using gdf.to_crs(‘ESRI:54009’) I get the FutureWarning that the proj is initialized in old style (+init).

This is addressed in the master branch currently and will no longer be an issue in version 0.7.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Squashing the Globe | Bending Lines
Every projection distorts the original geometry of the curved, three-dimensional earth in some way. Since we're so used to seeing projected maps of...
Read more >
UserWarning when trying to get centroid from a polygon ...
The issue is that the different projections distort distances near the poles in different ways. The default centroid relies on math based on ......
Read more >
Choose the right projection | Learn ArcGIS
Learn how different projections distort the world in different ways. 5 minutes. Map global analysis results. Search for an equal area projection. 15...
Read more >
Managing Projections — GeoPandas 0.12.2+0.gefcb367.dirty ...
The Coordinate Reference System (CRS) is important because the geometric shapes in a GeoSeries or GeoDataFrame object are simply a collection of coordinates...
Read more >
ee.Geometry.BBox.bounds - Earth Engine - Google Developers
The maximum amount of error tolerated when performing any necessary reprojection. proj, Projection, default: null, If specified, the result will be in this ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found