pyepsg icon indicating copy to clipboard operation
pyepsg copied to clipboard

Get function no longer working

Open jgutierrezm113 opened this issue 2 years ago • 4 comments

It seems like there has been a recent change to epsg.io web page where now the gml return is no longer supported from the URL request, so the get function is broken when it tries to convert the request from the string into an XML. Is there any expected update to the library or was the update to the epsg web page a bug?

jgutierrezm113 avatar Aug 02 '22 14:08 jgutierrezm113

I created an issue here: https://github.com/maptiler/epsg.io/issues/185

MBennGit avatar Aug 03 '22 09:08 MBennGit

Steps to reproduce and traceback:

Python 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:39:48)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyepsg
>>> pyepsg.get(21781)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ferguson/.conda/envs/s1coh-pyrosar/lib/python3.9/site-packages/pyepsg.py", line 288, in get
    root = ET.fromstring(xml)
  File "/home/ferguson/.conda/envs/s1coh-pyrosar/lib/python3.9/xml/etree/ElementTree.py", line 1347, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0

j08lue avatar Aug 03 '22 13:08 j08lue

Project is dead. Issue still present in 2024, while last version is 6 years old. The inability to use get() renders pyepsg practically useless. If you have the free space, just go with osgeo with its gdal submodule. Sadly, that alternative requires a local binary installation of GDAL (the PyPl package is just the wrapper for it), which some people may have a problem with (easy to tackle in virtual env such as the one from Anaconda though).

aleksandaratanasov avatar Sep 06 '24 03:09 aleksandaratanasov

Like Cartopy, you should probably use pyproj instead

from pyproj import CRS
crs = CRS.from_epsg(21781)

Or, if you are using the the CRS with Rasterio anyways, you might as well

from rasterio.crs import CRS
crs = CRS.from_epsg(21781)

Is there functionality of pyepsg that you are missing in either of the two, @aleksandaratanasov?

j08lue avatar Sep 06 '24 07:09 j08lue

Like Cartopy, you should probably use pyproj instead

from pyproj import CRS
crs = CRS.from_epsg(21781)

Or, if you are using the the CRS with Rasterio anyways, you might as well

from rasterio.crs import CRS
crs = CRS.from_epsg(21781)

Is there functionality of pyepsg that you are missing in either of the two, @aleksandaratanasov?

Thanks for the tip.

I completely switched to GDAL due to other project requirements. The big drawback (compared to the two you have posted) is how clunky the Python API of GDAL is (imho).

aleksandaratanasov avatar Oct 21 '24 07:10 aleksandaratanasov