-
Notifications
You must be signed in to change notification settings - Fork 202
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
Field Name encode error when writing to Mapinfo File #1399
Comments
Hi @alexJhao. From the information you gave
it looks like you have built Fiona from its source. Is that true? The WIndows distributions on pypi.org have GDAL version 3.8.4. Can you check to see that your GDAL library was built with support for the iconv library that provides internationalization support? |
I not sure whether built Fiona from its source or not. I use "conda install geopandas". |
@alexJhao thank you. I don't use MapInfo and am not an expert on the format, so I hope I do not lead you off course. I wonder if you need to use the
Or maybe UTF-8 would be better. I'm not sure. |
Had tried UTF-8 also, same result😓 I write a script to solved it temporarily.
|
On the Fiona main branch I see a def test_issue1399(tmp_path):
"""Test schema encoding issue reported in #1399."""
schema = {
"properties": {"地市": "str:80", "区县": "str:80", "商业街名称": "str:80"},
"geometry": "Polygon",
}
with fiona.open(
tmp_path / "a.tab",
"w",
driver="MapInfo File",
crs=CRS.from_epsg(4326),
schema=schema,
) as colxn:
pass
Logs mention MapInfo charset. The 502 error code is specific to MapInfo and is not one of the usual GDAL error codes that Fiona expects.
From looking at https://github.com/rouault/gdal/blob/65e177b7e3277bc3f39d64ae44796a8c813f4129/ogr/ogrsf_frmts/mitab/mitab_utils.cpp#L485 and the code below it, I think it's possible that MapInfo doesn't support non-Latin characters for field names. Is that true @rouault ? |
Good question to which I don't know the answer. Maybe @drons who introduced support for encodings in the mapinfo driver knows. Perhaps the "laundering" of characters of code >= 192 done in TABCleanFieldName() in mitab_utils.cpp should be removed when using a charset other than the default neutral one? |
Moreover, modern Mapinfo supports UTF-8 encoding, but GDAL don't (see mitab_imapinfofile.cpp |
Expected behavior and actual behavior.
I read data from GPKG, then write data to a Mapinfo TAB file. I found the field name error encode.
I use binary mode to open the a.tab file. found the field name changed.
in the TAB file,
three field names is:
but the original field name are: '地市', '区县', '商业街名称'
their 'ansi' code are :
Operating system
Win10
Fiona and GDAL version and provenance
python 3.11.5
GDAL 3.6.2
fiona 1.9.6
The text was updated successfully, but these errors were encountered: