BUG: Invalid input to create CRS
See original GitHub issue-
[ x] I have checked that this issue has not already been reported.
-
[x ] I have confirmed this bug exists on the latest version of geopandas.
-
(optional) I have confirmed this bug exists on the master branch of geopandas.
Code sample
import geopandas as gpd
from shapely.geometry import Polygon
polygon = Polygon([[-93.448499, 42.721669],[-93.447275, 42.722667],[-93.445998, 42.720974],[-93.448499, 42.721669]])
df = gpd.GeoDataFrame({'NAME':['poly1'], 'geometry':[polygon]}, crs='EPSG:4326')
target_crs = 'PROJCS["IaRCS_04_Sioux_City-Iowa_Falls_NAD_1983_2011_LCC_US_Feet",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",14500000.0],PARAMETER["False_Northing",8600000.0],PARAMETER["Central_Meridian",-94.83333333333333],PARAMETER["Standard_Parallel_1",42.53333333333333],PARAMETER["Standard_Parallel_2",42.53333333333333],PARAMETER["Scale_Factor",1.000045],PARAMETER["Latitude_Of_Origin",42.53333333333333],UNIT["Foot_US",0.3048006096012192]]'
df.to_crs(target_crs, inplace=True)
df.to_file('./test.shp') #crash with "fiona.errors.CRSError: Invalid input to create CRS"
Problem description
I am trying to take some GIS data, transform it, then write it to a SHP file. This all seems to work except for saving to a file. I am using a very specific CRS that I included in the code sample as target_crs
. The transform seems to occur without issue,
but I can’t save to a SHP file without an error being thrown. So the new CRS is parsed and understood enough to perform the transform, but for some odd reason cannot write it to a PRJ file. The value for target_crs
was given to me and seems to work in ArcGIS. Despite my efforts scouring the internet, I have been unable to fix this.
I created a new virtual environment in conda and reproduced the bug with my paired-down code in the fresh environment.
Error
fiona.errors.CRSError: Invalid input to create CRS: PROJCRS["IaRCS_04_Sioux_City-Iowa_Falls_NAD_1983_2011_LCC_US_Feet",BASEGEOGCRS["NAD83(2011)",DATUM["NAD83 (National Spatial Reference System 2011)",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]],ID["EPSG",1116]],PRIMEM["Greenwich",0,ANGLEUNIT["Degree",0.0174532925199433]]],CONVERSION["unnamed",METHOD["Lambert Conic Conformal (2SP Michigan)",ID["EPSG",1051]],PARAMETER["Latitude of false origin",42.5333333333333,ANGLEUNIT["Degree",0.0174532925199433],ID["EPSG",8821]],PARAMETER["Longitude of false origin",-94.8333333333333,ANGLEUNIT["Degree",0.0174532925199433],ID["EPSG",8822]],PARAMETER["Latitude of 1st standard parallel",42.5333333333333,ANGLEUNIT["Degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Latitude of 2nd standard parallel",42.5333333333333,ANGLEUNIT["Degree",0.0174532925199433],ID["EPSG",8824]],PARAMETER["Easting at false origin",14500000,LENGTHUNIT["US survey foot",0.304800609601219],ID["EPSG",8826]],PARAMETER["Northing at false origin",8600000,LENGTHUNIT["US survey foot",0.304800609601219],ID["EPSG",8827]],PARAMETER["Ellipsoid scaling factor",1.000045,ID["EPSG",1038]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["US survey foot",0.304800609601219,ID["EPSG",9003]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["US survey foot",0.304800609601219,ID["EPSG",9003]]]]
Output of geopandas.show_versions()
GEOS, GDAL, PROJ INFO
GEOS : None GEOS lib : None GDAL : 3.0.2 GDAL data dir: None PROJ : 6.2.1 PROJ data dir: C:\Users\timmey9.conda\envs\freshGIS\Library\share\proj
PYTHON DEPENDENCIES
geopandas : 0.8.1 pandas : 1.1.3 fiona : 1.8.13.post1 numpy : 1.19.2 shapely : 1.7.1 rtree : 0.9.4 pyproj : 2.6.1.post1 matplotlib : None mapclassify: None geopy : None psycopg2 : None geoalchemy2: None pyarrow : None
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
The fix for Fiona has been waiting a while, so I wanted to add a workaround for anyone who might run into this.
Solution: use
OSR_WKT_FORMAT="WKT2_2018"
orOSR_WKT_FORMAT="WKT1_ESRI"
withfiona.Env
:Write:
Read:
Thanks for looking into this one and creating the issue in the PROJ tracker, @snowman2!