Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new pyproj causes variations in projection results #67

Closed
jGaboardi opened this issue Feb 14, 2021 · 2 comments
Closed

new pyproj causes variations in projection results #67

jGaboardi opened this issue Feb 14, 2021 · 2 comments
Assignees
Labels
dependencies Pull requests that update a dependency file help wanted

Comments

@jGaboardi
Copy link
Owner

jGaboardi commented Feb 14, 2021

Something changed between pyproj 2.6.1.post1 and pyproj 3.0.0.post1 that is leading to small variations in projected coordinates, which is then propagated on to point snapping distance, cost matrices, etc. For now, pinning to 2.6.1.post1 is reasonable (#66). A longer term solution is either updating the tests to reflect the altered projection results or figuring out if this is an actual bug. The code chunk below demonstrates the output difference between pyproj 2.6.1.post1 (top) and pyproj 3.0.0.post1 (bottom) with an example through geopandas and a MWE with only pyproj.

@knaaptime @slumnitz @martinfleis Have any of you noticed this in your work?

import warnings
warnings.filterwarnings("ignore")
import geopandas
import numpy
import pyproj
import shapely

packages = [geopandas, numpy, pyproj, shapely]
for p in packages:
    print(f"{p.__name__}: {p.__version__}")

layer = "WeightedParcels_Leon_FL_2010"
fin = f"zip://{layer}.zip!{layer}.shp"
bbox = (-84.279, 30.480, -84.245, 30.505)
gdf = geopandas.read_file(fin, bbox=bbox)
TEST_PARCEL = "1117160000020"
gdf = gdf[gdf["PARCEL_ID"] == TEST_PARCEL].reset_index(drop=True)
point = gdf.geometry[0]
x, y = point.x, point.y

from_crs, to_crs = gdf.crs, "EPSG:2779"

print(f" -- {geopandas.__name__}/{shapely.__name__} --")
print(gdf.crs, point)
gdf = gdf.to_crs(to_crs)
point = gdf.geometry[0]
print(gdf.crs, point)

print(f" -- {pyproj.__name__} --")
transformer = pyproj.Transformer.from_crs(from_crs, to_crs)
print(from_crs, (x, y))
print(to_crs, transformer.transform(y, x))
geopandas: 0.8.1
numpy: 1.19.4
pyproj: 2.6.1.post1
shapely: 1.7.1
 -- geopandas/shapely --
epsg:4326 POINT (-84.25873245332716 30.48436516338524)
EPSG:2779 POINT (623164.270749338 164564.2000569425)
 -- pyproj --
epsg:4326 (-84.25873245332716, 30.48436516338524)
EPSG:2779 (623164.270749338, 164564.20005694253)
geopandas: 0.8.2
numpy: 1.20.1
pyproj: 3.0.0.post1
shapely: 1.7.1
 -- geopandas/shapely --
epsg:4326 POINT (-84.25873245332716 30.48436516338524)
EPSG:2779 POINT (623164.6468275142 164563.5686168194)
 -- pyproj --
epsg:4326 (-84.25873245332716, 30.48436516338524)
EPSG:2779 (623164.6468275142, 164563.56861681942)
@jGaboardi jGaboardi self-assigned this Feb 14, 2021
@jGaboardi jGaboardi added dependencies Pull requests that update a dependency file help wanted labels Feb 14, 2021
@jGaboardi
Copy link
Owner Author

jGaboardi commented Feb 14, 2021

See original issue in #65

This was referenced Feb 14, 2021
@martinfleis
Copy link
Collaborator

I think that this is a result of changes in how proj handles transformation grids. The new result should have the higher precision compared to the other one, so I would fix the tests. There was one issue of this kind in geopandas some time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file help wanted
Projects
None yet
Development

No branches or pull requests

2 participants