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

Transformer creation broken with empty area of interest #1326

Open
tpwrules opened this issue Jul 23, 2023 · 0 comments
Open

Transformer creation broken with empty area of interest #1326

tpwrules opened this issue Jul 23, 2023 · 0 comments
Labels
Milestone

Comments

@tpwrules
Copy link
Contributor

Code Sample, a copy-pastable example if possible

from pyproj import CRS, Transformer
from pyproj.aoi import AreaOfInterest
from pyproj.database import query_utm_crs_info

def broken(lat, lon):
    aoi = AreaOfInterest(
        west_lon_degree=lon,
        south_lat_degree=lat,
        east_lon_degree=lon,
        north_lat_degree=lat,
    )
    utm_crs_list = query_utm_crs_info(
        datum_name="WGS 84",
        area_of_interest=aoi,
    )
    utm_crs = CRS.from_epsg(utm_crs_list[0].code)

    return Transformer.from_crs(CRS("WGS 84"), utm_crs, area_of_interest=aoi)

def working(lat, lon):
    aoi = AreaOfInterest(
        west_lon_degree=lon,
        south_lat_degree=lat,
        east_lon_degree=lon+1e-8,
        north_lat_degree=lat+1e-8,
    )
    utm_crs_list = query_utm_crs_info(
        datum_name="WGS 84",
        area_of_interest=aoi,
    )
    utm_crs = CRS.from_epsg(utm_crs_list[0].code)

    return Transformer.from_crs(CRS("WGS 84"), utm_crs, area_of_interest=aoi)

lat, lon = 42.032974, -93.581543

working(lat, lon)

# worked in 3.4.1, broken in 3.5.0 and 3.6.0
# throws pyproj.exceptions.ProjError: Error creating Transformer from CRS.
broken(lat, lon)

Problem description

An area of interest with 0 area (i.e. east/west and/or north/south coordinates the same) causes some internal exception when passed to Transformer.from_crs. Enlarging the area even negligibly results in the operation working properly.

A zero-size area should still technically be valid. Both variants do work without crashing in v3.4.1.

Expected Output

A 0 area of interest should work and produce a Transformer object.

Environment Information

pyproj info:
    pyproj: 3.5.0
      PROJ: 9.2.0
  data dir: /nix/store/l21lg0k87m6z743923ld2clp76yykskk-proj-9.2.0/share/proj
user_data_dir: /home/tpwatson/.local/share/proj
PROJ DATA (recommended version): 1.13
PROJ Database: 1.2
EPSG Database: v10.082 [2023-02-06]
ESRI Database: ArcGIS Pro 3.1 [2023-19-01]
IGNF Database: 3.1.0 [2019-05-24]

System:
    python: 3.10.12 (main, Jun  6 2023, 22:43:10) [GCC 12.3.0]
executable: /nix/store/46j792vz3np5f32kg36ifa2s2qsyppq7-python3-3.10.12-env/bin/python3.10
   machine: Linux-4.15.0-169-generic-x86_64-with-glibc2.37

Python deps:
   certifi: 2022.12.7
    Cython: None
setuptools: None
       pip: None

Installation method

nixpkgs built from source

@tpwrules tpwrules added the bug label Jul 23, 2023
@snowman2 snowman2 added this to the 3.6.2 milestone Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants