Comments (7)
@idanmiara Could you explain what I'm doing differently in my comment above where I do as you suggest and it works for me?
Thanks @djhoese, I've must have missed your comment before.
It seems that I've been mistakenly using pyproj.Proj
instead of pyproj.CRS
(as you did), so now it works.
I will try to make a PR to fix the docs accordingly.
from pyproj.
@idanmiara Do you have a suggestion of how it should be reworded/updated? Would you be comfortable making a pull request for this? If not, maybe you could post a comment here with the content you want in that section and one of the pyproj maintainers could make the PR.
from pyproj.
Hi @djhoese
I know that proj strings are discouraged and wkt is preferable, so is the following a bug in pyproj or in fiona?
import fiona
import pyproj
from fiona.crs import CRS
from pyproj import Proj
print(f'{fiona.__version__=}')
print(f'{pyproj.__version__=}')
pj = Proj(4326)
pj_str = pj.to_proj4()
wkt_str = pj.to_wkt()
print(f'{pj=}')
print(f'{pj_str=}')
print(f'{wkt_str=}')
print(f'{CRS.from_proj4(pj_str)=}')
print(f'{CRS.from_wkt(wkt_str)=}') # fails
output:
fiona.__version__='1.9.4.post1'
pyproj.__version__='3.6.1'
pj=<Other Coordinate Operation Transformer: longlat>
Description: PROJ-based coordinate operation
Area of Use:
- undefined
pj_str='+proj=longlat +datum=WGS84 +no_defs'
wkt_str='CONVERSION["PROJ-based coordinate operation",METHOD["PROJ-based operation method: +proj=longlat +datum=WGS84 +no_defs"]]'
CRS.from_proj4(pj_str)=CRS.from_epsg(4326)
ERROR 1: PROJ: internal_proj_crs_get_coordinate_system: Object is not a SingleCRS
Traceback (most recent call last):
File "fiona/crs.pyx", line 729, in fiona.crs.CRS.from_wkt
File "fiona/_err.pyx", line 280, in fiona._err.exc_wrap_ogrerr
fiona._err.CPLE_AppDefinedError: PROJ: internal_proj_crs_get_coordinate_system: Object is not a SingleCRS
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 17, in <module>
print(f'{CRS.from_wkt(wkt_str)=}') # fails
^^^^^^^^^^^^^^^^^^^^^
File "fiona/crs.pyx", line 731, in fiona.crs.CRS.from_wkt
fiona.errors.CRSError: The WKT could not be parsed. PROJ: internal_proj_crs_get_coordinate_system: Object is not a SingleCRS
from pyproj.
In [1]: from pyproj import CRS
In [2]: from fiona.crs import CRS as fCRS
In [3]: crs = CRS(4326)
In [4]: fCRS.from_wkt(crs.to_wkt())
Out[4]: CRS.from_epsg(4326)
In [5]: fCRS.from_proj4(crs.to_proj4())
/home/davidh/miniconda3/envs/satpy_py311_2/lib/python3.11/site-packages/pyproj/crs/crs.py:1293: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
proj = self._crs.to_proj4(version=version)
Out[5]: CRS.from_epsg(4326)
from pyproj.
With Fiona 1.9+ and GDAL 3+, the instructions should look similar to rasterio: https://pyproj4.github.io/pyproj/stable/crs_compatibility.html#rasterio
from pyproj.
With Fiona 1.9+ and GDAL 3+, the instructions should look similar to rasterio: https://pyproj4.github.io/pyproj/stable/crs_compatibility.html#rasterio
In the rio example you take a rio wkt and pass it to pyproj:
import rasterio.crs
from pyproj.crs import CRS
with rasterio.Env(OSR_WKT_FORMAT="WKT2_2018"):
rio_crs = rasterio.crs.CRS.from_epsg(4326)
proj_crs = CRS.from_wkt(rio_crs.wkt)
which works fine.
But what about the other direction as I did above, why does it fail?
from pyproj.
@idanmiara Could you explain what I'm doing differently in my comment above where I do as you suggest and it works for me?
from pyproj.
Related Issues (20)
- What happened to the `pyproj/aoi.py` module in releases? HOT 1
- Deprecation warning when transforming a single point enclosed in numpy array HOT 1
- LibTiff Vulnerabilities and Dependencies HOT 4
- Add JSON serializeability with PROJJSON? HOT 7
- to_CF for polar_stereographic, with latitude_true_scale, should include latitude_of_projection_origin HOT 2
- Reverse transformation does not produce initial coordinates
- DeprecationWarning: pkg_resources is deprecated as an API. HOT 1
- Support for deprecated and non-deprecated objects HOT 3
- Invert lat lon "Transformer" HOT 1
- Internal Proj Error: proj_create: unrecognized format / unknown name HOT 4
- Inverted x/y for transformation from WSG84 to LV95 (EPSG:2056) HOT 3
- muslinux wheel missing HOT 1
- test_azimuthal_equidistant fails with PROJ 9.4.0 HOT 1
- test failure in test_crs_cf.py HOT 2
- Add proj_query_geodetic_crs_from_datum HOT 2
- 3.6.1: pytest fails in `test/crs/test_crs_cf.py::test_azimuthal_equidistant` unit HOT 1
- A question about pyproj/_datadir.pyx HOT 2
- geometry_area_perimeter limitations not documented HOT 1
- Calculate area of arbitrary polygon on Earth's surface HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyproj.