question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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()

SYSTEM INFO --------------------- python : 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] executable : C:\Users\timmey9\.conda\envs\freshGIS\python.exe machine : Windows-10-10.0.18362-SP0

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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
snowman2commented, Jul 13, 2021

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" or OSR_WKT_FORMAT="WKT1_ESRI" with fiona.Env:

Write:

with fiona.Env(OSR_WKT_FORMAT="WKT2_2018"):
    df.to_file('./test.shp')

Read:

with fiona.Env(OSR_WKT_FORMAT="WKT2_2018"):
   gdf = geopandas.read_file("./test.shp")
0reactions
jdmcbrcommented, Nov 16, 2020

Thanks for looking into this one and creating the issue in the PROJ tracker, @snowman2!

Read more comments on GitHub >

github_iconTop Results From Across the Web

CRS error working with Solaris [closed] - GIS Stack Exchange
I'm one of the maintainers for the solaris project. I tried to reproduce your error in my environment but could not.
Read more >
CRSError: Invalid projection: epsg:4326: for geopandas
I am using anaconda for geopandas. However, everytime I try to use epsg:4326:, it gives an error. CRSError: Invalid projection: epsg:4326: ...
Read more >
BUG: Invalid input to create CRS - Bountysource
I have confirmed this bug exists on the master branch of geopandas. Code sample. import geopandas as gpd from shapely.geometry import Polygon ...
Read more >
Issue create fails with "Invalid Input" error | Jira Cloud
“issue creation” fails with error as “Invalid Input” when a multi-line custom field and is used in create issue screen. Steps to Reproduce....
Read more >
Invalid input data size with communicator - Anybus Gateways
This error typically occurs when the amount of data allocated on the communicator does not matching the size configured for the module in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found