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

Different results for SetFromUserInput() and ImportFromWkt() #7170

Closed
deppen8 opened this issue Feb 2, 2023 · 1 comment
Closed

Different results for SetFromUserInput() and ImportFromWkt() #7170

deppen8 opened this issue Feb 2, 2023 · 1 comment
Assignees

Comments

@deppen8
Copy link

deppen8 commented Feb 2, 2023

Expected behavior and actual behavior.

This issue was discovered while using rasterio (rasterio/rasterio#2752) but it seems to be derived from gdal.

I expected rasterio.CRS.from_user_input(my_wkt_string) to return the same result as rasterio.CRS.from_wkt(my_wkt_string) for a given WKT string.

Instead, for my input, rasterio.CRS.from_user_input(my_wkt_string) raises an error, but rasterio.CRS.from_wkt(my_wkt_string) is valid.

@snowman2 was able to replicate the error using osgeo.osr SetFromUserInput() and ImportFromWkt() (see repro below).

Steps to reproduce the problem.

Repeating the minimal example from @snowman2 ...

>>> from osgeo import osr
>>> osr.UseExceptions()

>>> my_wkt_string = """
        PROJCS["North_America_Albers_Equal_Area_Conic",
        GEOGCS["GCS_North_American_1983",
        DATUM["North_American_Datum_1983",
        SPHEROID["GRS_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
        PROJECTION["Albers_Conic_Equal_Area"],
        PARAMETER["False_Easting",0],
        PARAMETER["False_Northing",0],
        PARAMETER["longitude_of_center",-96],
        PARAMETER["Standard_Parallel_1",20],
        PARAMETER["Standard_Parallel_2",60],
        PARAMETER["latitude_of_center",40],
        UNIT["Meter",1],
        AUTHORITY["EPSG","102008"]]"""
>>> ref = osr.SpatialReference()
>>> ref.SetFromUserInput(my_wkt_string)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.9/site-packages/osgeo/osr.py", line 708, in SetFromUserInput
    return _osr.SpatialReference_SetFromUserInput(self, *args)
RuntimeError: OGR Error: Corrupt data
>>> ref.ImportFromWkt(my_wkt_string)

Operating system

MacOS Ventura 13.0

GDAL version and provenance

GDAL 3.6.2 installed via Homebrew

@rouault rouault self-assigned this Feb 2, 2023
@rouault rouault closed this as completed in c821e9a Feb 4, 2023
rouault added a commit that referenced this issue Feb 4, 2023
OSRSpatialReference::SetFromUserInput(): skip leading white space (fixes #7170)
@snowman2
Copy link
Contributor

snowman2 commented Feb 4, 2023

Thanks @rouault 👍

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

No branches or pull requests

3 participants