Evan
Evan

Reputation: 313

"Invalid projection" when creating a CRS

I am attempting to construct a CRS instance with PyProj to match a geographic shape to image bounds. With the following code

pyproj.Proj(proj='aea', lat1=b[1], lat2=b[3])

I am getting the error:

pyproj.exceptions.CRSError: Invalid projection: +proj=aea
 +lat1=34.82176739999999 +lat2=34.8219931 +type=crs

There doesn't seem to be a lot of documentation about what makes a projection valid or invalid, apart from an apparently no longer extant documentation page on the Proj4 wiki. Can anyone help me to understand what's going wrong here? The code (not written by me) appears to have worked in the past.

Upvotes: 0

Views: 6891

Answers (1)

Sergio Monteleone
Sergio Monteleone

Reputation: 2886

I think the issue here is you mispelled the projection parameters.

lat1 and lat2 should be lat_1 and lat_2 (with the underscore).

The correct proj string should be:

+proj=aea +lat_1=34.82176739999999 +lat_2=34.8219931

You can find more details about the format of the proj string in the official documentation, linked here: https://proj4.org/operations/projections/aea.html

Upvotes: 3

Related Questions