GeezerVison is showing github.com — geopandas: Fix UnicodeEncodeError on Windows for geopandas.GeoDataFrame with non-ASCII characters by seisman · Pull Request #4224 · GenericMappingTools/pygmt
Conversation
seisman
commented
Nov 25, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This PR adds a test for geopandas with non-ASCII characters, which doesn't work on Windows (https://github.com/GenericMappingTools/pygmt/actions/runs/19654941294/job/56289538628?pr=4224):
..\pygmt\tests\test_geopandas.py:289:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\pygmt\helpers\decorators.py:591: in new_module
return module_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
..\pygmt\src\info.py:100: in info
with lib.virtualfile_in(check_kind="vector", data=data) as vintbl:
C:\Users\runneradmin\micromamba\envs\pygmt\Lib\contextlib.py:137: in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
..\pygmt\helpers\tempfile.py:157: in tempfile_from_geojson
geojson.to_file(**ogrgmt_kwargs)
C:\Users\runneradmin\micromamba\envs\pygmt\Lib\site-packages\geopandas\geodataframe.py:1637: in to_file
_to_file(self, filename, driver, schema, index, **kwargs)
C:\Users\runneradmin\micromamba\envs\pygmt\Lib\site-packages\geopandas\io\file.py:731: in _to_file
_to_file_pyogrio(df, filename, driver, schema, crs, mode, metadata, **kwargs)
C:\Users\runneradmin\micromamba\envs\pygmt\Lib\site-packages\geopandas\io\file.py:793: in _to_file_pyogrio
pyogrio.write_dataframe(df, filename, driver=driver, metadata=metadata, **kwargs)
C:\Users\runneradmin\micromamba\envs\pygmt\Lib\site-packages\pyogrio\geopandas.py:710: in write_dataframe
write(
C:\Users\runneradmin\micromamba\envs\pygmt\Lib\site-packages\pyogrio\raw.py:723: in write
ogr_write(
pyogrio\\_io.pyx:2585: in pyogrio._io.ogr_write
???
pyogrio\\_io.pyx:2575: in pyogrio._io.ogr_write
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <encodings.cp1252.Codec object at 0x00000273C9A3F110>, input = '\u0641\u064a\u062c\u064a'
errors = 'strict'
def encode(self,input,errors='strict'):
> return codecs.charmap_encode(input,errors,encoding_table)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-3: character maps to <undefined>
This PR fixes the issue by setting encoding="UTF-8" when writing geopandas to ORG_GMT file.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
seisman
changed the title
Add a test for geopandas with non-ASCII characters
geopandas: Fix the UnicodeEncodeError on Windows for geopandas.GeoDataFrame with non-ASCII characters
Nov 25, 2025
seisman
changed the title
geopandas: Fix the UnicodeEncodeError on Windows for geopandas.GeoDataFrame with non-ASCII characters
geopandas: Fix UnicodeEncodeError on Windows for geopandas.GeoDataFrame with non-ASCII characters
Nov 25, 2025
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
|
gdf = gpd.GeoDataFrame(
|
|
|
{
|
|
|
"name_ascii": ["Fiji"],
|
|
|
"name_utf8": ["فيجي"], # Arabic
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm that this is Fiji in Arabic 😆
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ah, OK. Thanks for looking at this 🙂.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
weiji14
weiji14 approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
bug
Something isn't working
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|