Building a same application both on Linux and Windows I noticed that the geometry is handled differently after transferring the dataframe from WGS84 projection to OSM.

The results of the program below are different when run on Windows or when run on Linux with the x and y values interchanged:

import geopandas as gpd
from shapely.geometry import Point

EPSG_OSM = 3857
EPSG_WGS84 = 4326

longitude = 45
latitude = 0
my_location = gpd.GeoDataFrame(geometry=[Point(longitude, latitude)])

geom = my_location.loc[0].geometry
print(f'long: {geom.x:15.4f}, lat: {geom.y:15.4f}')

my_location.crs = EPSG_WGS84
my_location = my_location.to_crs(epsg=EPSG_OSM)

geom = my_location.loc[0].geometry
print(f'x   : {geom.x:15.4f}, y  : {geom.y:15.4f}')

Linux answer:

long:          0.0000, lat:        -45.0000
x   :          0.0000, y  :   -5621521.4862

long:         45.0000, lat:          0.0000
x   :    5009377.0857, y  :          0.0000

Windows answer:

long:          0.0000, lat:        -45.0000
x   :   -5009377.0857, y  :          0.0000

long:         45.0000, lat:          0.0000
x   :          0.0000, y  :    5621521.4862

Is this correct behaviour? The Windows results seem incorrect.

I can resolve the matter by switching the latitude and longitude in Windows..., but looks to me there is something not right!

  • A point should be created with X;Y coordinates, so longitude first, then latitude. It is swapped in your code. While this mistake does not explain the observed behavior, could it be that one of the 2 scripts has the proper coordinates order?
    – JGH
    Nov 30, 2019 at 21:04
  • It is probably not a sign issue but rather an entire XY swap. Try it again with latitude = 0 and longitude = -45
    – JGH
    Nov 30, 2019 at 21:05
  • @JGH, thanks for the response I have updated the question to better explain the issue. It clearly shows the values of x and y are interchanged when run on Windows (python 3.7.3 geopandas 0.5.1), while the Linux version (python 3.8.0 geopandas 0.6.2) shows the correct behavior with x associated with the longitude and y with the latitude. Dec 1, 2019 at 3:06
  • Benchmarking on different Pythons with different GeoPandas on different operating systems reduces the basis for expecting identical behavior.
    – Vince
    Dec 1, 2019 at 17:40

1 Answer 1


Geopandas changelog for v0.6 has under bug fixes:

The to_crs method now uses always_xy=True to ensure correct lon/lat order handling for pyproj>=2.2.0 (#1122).

You say that the Windows tests is done under v0.5.1 and the Linux test under 0.6.2, so the entire test is affect by this bug/bug fix.

==> update Geopandas under Windows

  • Done and 0.6.2 on windows now runs correctly. Dec 1, 2019 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.