geopandas: error while saving geodataframe as mapinfo .tab file
Hi,
I’m getting below error while exporting geopandas dataframe as mapinfo .TAB file.
Code:
import geopandas as gpd
p=r"D:\data.TAB"
testdata = gpd.read_file(p)
testdata.to_file("output.TAB", driver="MapInfo File")`
(base) D:\FTTC_Automation\Python\PC_Check\fttc_app>python test.py
Traceback (most recent call last):
File "fiona\ogrext.pyx", line 1167, in fiona.ogrext.WritingSession.start
File "fiona\_err.pyx", line 246, in fiona._err.exc_wrap_int
fiona._err.CPLE_AppDefinedError: IMapInfoFile::CreateField() called with unsupported field type 12. Note that Mapinfo files don't support list fiel
d types.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 6, in <module>
cable.to_file("output.TAB", driver="MapInfo File")
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\geodataframe.py", line 413, in to_file
to_file(self, filename, driver, schema, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\io\file.py", line 116, in to_file
schema=schema, **kwargs) as colxn:
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\env.py", line 397, in wrapper
return f(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\__init__.py", line 267, in open
**kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\collection.py", line 162, in __init__
self.session.start(self, **kwargs)
File "fiona\ogrext.pyx", line 1173, in fiona.ogrext.WritingSession.start
fiona.errors.SchemaError: IMapInfoFile::CreateField() called with unsupported field type 12. Note that Mapinfo files don't support list field types
Any help much appreciated.
Thanks in Advance, Mani
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 22 (10 by maintainers)
I have also encountered this error of saving integer columns to .TAB files with the MapInfo driver.
I found out that all integer types (int64, int32, and int16) results in the error “CPLE_AppDefinedError: IMapInfoFile::CreateField() called with unsupported field type 12. Note that Mapinfo files don’t support list field types.”
Currently, I use the workaround by casting the integer columns to floats.
Its a bug or mis-informative error (using my port of ogr2ogr.c to C#). I’ve upgraded NuGet Gdal + Gdal.Native + Gdal.Plugins from 1.11.1 through 2.4.2 (where I first saw the bug) to 2.4.4 which broke my working test.
Using OSGeo4W64 produces the follow warning rather than error so I guess I will heed it and change my test data: “ogr2ogr -f “MapInfo File” tmp.tab test.shp -overwrite Warning 1: The output driver does not seem to natively support Integer64 type for field STATESP020. Converting it to Real instead. -mapFieldType can be used to control field type conversion.”
I also may have changed build from Auto/x86 to x64 which kind of makes sense: i.e. “Integer64”. So many inter-dependencies in S/W Development these days make life a nightmare (its the environment/build changes like 32-bit/x86 to 64-bit/x64 that are the worst of all with the most inscrutable error message results: you’ve got to have your wits about you!
Got another problem now with XUnit refusing to return from running some tests…