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

REF: Remove network kwarg from Proj and Transformer #708

Merged
merged 2 commits into from
Sep 22, 2020

Conversation

snowman2
Copy link
Member

@snowman2 snowman2 commented Sep 20, 2020

This was originally added in #637. Since then, #675 and #695 were added. With those additions, I think it make sense to remove the network kwarg because:

  1. It adds consistency with how the network is enabled
  2. It likely will remove confusion with behavior when the global context is enabled versus when it is not
  3. It simplifies the code and removes checks applied every time a new context is created

@jorisvandenbossche
Copy link
Contributor

Question: do you then need to enable the network before creating the transformer object to have effect? Or can you switch back and forth for a single transformer object?

@snowman2
Copy link
Member Author

do you then need to enable the network before creating the transformer object to have effect? Or can you switch back and forth for a single transformer object?

Yes, you need to enable it before creating the transformer. It wouldn't be a good idea to allow toggling the network after it is enabled as it impacts how it is initialized.

@snowman2
Copy link
Member Author

Ref: #629 (comment)

@snowman2 snowman2 force-pushed the simplify branch 2 times, most recently from d8b9b46 to 6d2010e Compare September 21, 2020 00:10
@snowman2
Copy link
Member Author

Did some tests with the global context to see what the behavior changes would be with toggling the network on the context of a transformer and it seems like it doesn't change results when toggling after initialization.

Base script:

import logging

import pyproj
from pyproj import Transformer

logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.DEBUG)

pyproj.set_use_global_context(True)
lonlat = -74.9, 39.9
pyproj.network.set_network_enabled(True)
tr = Transformer.from_crs("epsg:4326", "esri:102003", always_xy=True)
albers_pt = tr.transform(*lonlat, errcheck=True)
print(f"Albers: {albers_pt}")
print(tr.is_network_enabled)
pyproj.network.set_network_enabled(False)
albers_pt = tr.transform(*lonlat, errcheck=True)
print(f"Albers: {albers_pt}")
print(tr.is_network_enabled)

Initialized enabled. enable result == disable result:

PROJ_DEBUG=2 python network_check.py 
DEBUG:PROJ_DEBUG: pj_open_lib(proj.ini): call fopen(/home/snowal/scripts/pyproj/pyproj/proj_dir/share/proj/proj.ini) - succeeded
DEBUG:PROJ_DEBUG: Using coordinate operation Inverse of NAD83 to WGS 84 (57) + axis order change (2D) + USA_Contiguous_Albers_Equal_Area_Conic
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_pahpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_pahpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(pahpgn.gsb): call fopen(/home/snowal/.local/share/proj/pahpgn.gsb) - failed
DEBUG:PROJ_DEBUG: Using https://cdn.proj.org/us_noaa_pahpgn.tif
Albers: (1773370.9951035047, 466667.6736596611)
True
Albers: (1773370.9951035047, 466667.6736596611)
False

Initialized disabled. disable result == enable result:

DEBUG:PROJ_DEBUG: pj_open_lib(proj.ini): call fopen(/home/snowal/scripts/pyproj/pyproj/proj_dir/share/proj/proj.ini) - succeeded
DEBUG:PROJ_DEBUG: pj_open_lib(ca_nrc_NA83SCRS.tif): call fopen(/home/snowal/.local/share/proj/ca_nrc_NA83SCRS.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(NA83SCRS.GSB): call fopen(/home/snowal/.local/share/proj/NA83SCRS.GSB) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ca_nrc_ABCSRSV4.tif): call fopen(/home/snowal/.local/share/proj/ca_nrc_ABCSRSV4.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ABCSRSV4.GSB): call fopen(/home/snowal/.local/share/proj/ABCSRSV4.GSB) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ca_nrc_SK83-98.tif): call fopen(/home/snowal/.local/share/proj/ca_nrc_SK83-98.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(SK83-98.GSB): call fopen(/home/snowal/.local/share/proj/SK83-98.GSB) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_ethpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_ethpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ethpgn.gsb): call fopen(/home/snowal/.local/share/proj/ethpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_wthpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_wthpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(wthpgn.gsb): call fopen(/home/snowal/.local/share/proj/wthpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_FL.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_FL.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(FL): call fopen(/home/snowal/.local/share/proj/FL) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_emhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_emhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(emhpgn.gsb): call fopen(/home/snowal/.local/share/proj/emhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_WO.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_WO.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(WO): call fopen(/home/snowal/.local/share/proj/WO) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_mihpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_mihpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(mihpgn.gsb): call fopen(/home/snowal/.local/share/proj/mihpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_cnhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_cnhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(cnhpgn.gsb): call fopen(/home/snowal/.local/share/proj/cnhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_nvhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_nvhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(nvhpgn.gsb): call fopen(/home/snowal/.local/share/proj/nvhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_mnhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_mnhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(mnhpgn.gsb): call fopen(/home/snowal/.local/share/proj/mnhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_nmhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_nmhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(nmhpgn.gsb): call fopen(/home/snowal/.local/share/proj/nmhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_azhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_azhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(azhpgn.gsb): call fopen(/home/snowal/.local/share/proj/azhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_nyhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_nyhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(nyhpgn.gsb): call fopen(/home/snowal/.local/share/proj/nyhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_cshpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_cshpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(cshpgn.gsb): call fopen(/home/snowal/.local/share/proj/cshpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_mohpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_mohpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(mohpgn.gsb): call fopen(/home/snowal/.local/share/proj/mohpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_okhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_okhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(okhpgn.gsb): call fopen(/home/snowal/.local/share/proj/okhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_WI.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_WI.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(WI): call fopen(/home/snowal/.local/share/proj/WI) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_cohpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_cohpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(cohpgn.gsb): call fopen(/home/snowal/.local/share/proj/cohpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_wmhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_wmhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(wmhpgn.gsb): call fopen(/home/snowal/.local/share/proj/wmhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_wyhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_wyhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(wyhpgn.gsb): call fopen(/home/snowal/.local/share/proj/wyhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_nchpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_nchpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(nchpgn.gsb): call fopen(/home/snowal/.local/share/proj/nchpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_nbhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_nbhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(nbhpgn.gsb): call fopen(/home/snowal/.local/share/proj/nbhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_uthpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_uthpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(uthpgn.gsb): call fopen(/home/snowal/.local/share/proj/uthpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_vahpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_vahpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(vahpgn.gsb): call fopen(/home/snowal/.local/share/proj/vahpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_ilhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_ilhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ilhpgn.gsb): call fopen(/home/snowal/.local/share/proj/ilhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_sdhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_sdhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(sdhpgn.gsb): call fopen(/home/snowal/.local/share/proj/sdhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_lahpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_lahpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(lahpgn.gsb): call fopen(/home/snowal/.local/share/proj/lahpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_gahpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_gahpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(gahpgn.gsb): call fopen(/home/snowal/.local/share/proj/gahpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_kshpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_kshpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(kshpgn.gsb): call fopen(/home/snowal/.local/share/proj/kshpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_kyhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_kyhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(kyhpgn.gsb): call fopen(/home/snowal/.local/share/proj/kyhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_ndhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_ndhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ndhpgn.gsb): call fopen(/home/snowal/.local/share/proj/ndhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_iahpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_iahpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(iahpgn.gsb): call fopen(/home/snowal/.local/share/proj/iahpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_mshpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_mshpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(mshpgn.gsb): call fopen(/home/snowal/.local/share/proj/mshpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_alhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_alhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(alhpgn.gsb): call fopen(/home/snowal/.local/share/proj/alhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_arhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_arhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(arhpgn.gsb): call fopen(/home/snowal/.local/share/proj/arhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_wvhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_wvhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(wvhpgn.gsb): call fopen(/home/snowal/.local/share/proj/wvhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_mehpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_mehpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(mehpgn.gsb): call fopen(/home/snowal/.local/share/proj/mehpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_ohhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_ohhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(ohhpgn.gsb): call fopen(/home/snowal/.local/share/proj/ohhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_schpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_schpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(schpgn.gsb): call fopen(/home/snowal/.local/share/proj/schpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_pahpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_pahpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(pahpgn.gsb): call fopen(/home/snowal/.local/share/proj/pahpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_nehpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_nehpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(nehpgn.gsb): call fopen(/home/snowal/.local/share/proj/nehpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_TN.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_TN.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(TN): call fopen(/home/snowal/.local/share/proj/TN) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_inhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_inhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(inhpgn.gsb): call fopen(/home/snowal/.local/share/proj/inhpgn.gsb) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_MD.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_MD.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(MD): call fopen(/home/snowal/.local/share/proj/MD) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(us_noaa_njhpgn.tif): call fopen(/home/snowal/.local/share/proj/us_noaa_njhpgn.tif) - failed
DEBUG:PROJ_DEBUG: pj_open_lib(njhpgn.gsb): call fopen(/home/snowal/.local/share/proj/njhpgn.gsb) - failed
Albers: (1773370.9846869048, 466667.8457989395)
True
Albers: (1773370.9846869048, 466667.8457989395)
False

@snowman2 snowman2 merged commit 69dc136 into pyproj4:master Sep 22, 2020
@snowman2 snowman2 deleted the simplify branch September 22, 2020 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants