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

Simplify set_crs and to_crs #189

Open
veenstrajelmer opened this issue Dec 7, 2023 · 0 comments
Open

Simplify set_crs and to_crs #189

veenstrajelmer opened this issue Dec 7, 2023 · 0 comments

Comments

@veenstrajelmer
Copy link
Collaborator

Current code in:

def set_crs(
self,
crs: Union["pyproj.CRS", str] = None, # type: ignore # noqa
epsg: int = None,
allow_override: bool = False,
):
"""
Set the Coordinate Reference System (CRS) of a UGRID topology.
NOTE: The underlying geometries are not transformed to this CRS. To
transform the geometries to a new CRS, use the ``to_crs`` method.
Parameters
----------
crs : pyproj.CRS, optional if `epsg` is specified
The value can be anything accepted
by :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
such as an authority string (eg "EPSG:4326") or a WKT string.
epsg : int, optional if `crs` is specified
EPSG code specifying the projection.
allow_override : bool, default False
If the the UGRID topology already has a CRS, allow to replace the
existing CRS, even when both are not equal.
"""
import pyproj
if crs is not None:
crs = pyproj.CRS.from_user_input(crs)
elif epsg is not None:
crs = pyproj.CRS.from_epsg(epsg)
else:
raise ValueError("Must pass either crs or epsg.")

However, pyproj.CRS.from_user_input also correctly parses epsg integer values, so it is not necessary to do this separately.

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

When branches are created from issues, their pull requests are automatically linked.

1 participant