GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@seisman seisman commented Nov 25, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@seisman
Add a test for geopandas with non-ASCII characters
64f374e
@seisman
seisman marked this pull request as ready for review November 25, 2025 01:20
@seisman
Set encoding to UTF-8
90ff2c9
@seisman seisman added the bug Something isn't working label Nov 25, 2025
@seisman seisman added this to the 0.18.0 milestone Nov 25, 2025
@seisman 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 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
@seisman seisman added the needs review This PR has higher priority and needs review. label Nov 25, 2025
@seisman

seisman commented Nov 25, 2025

Copy link
Copy Markdown
Member Author

@yvonnefroehlich This PR should fix the issue you had in GenericMappingTools/pygmt-paper-figures#6 (comment).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weiji14
weiji14 approved these changes Nov 25, 2025
View reviewed changes
Comment thread pygmt/tests/test_geopandas.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pygmt/tests/test_geopandas.py
gdf = gpd.GeoDataFrame(
{
"name_ascii": ["Fiji"],
"name_utf8": ["فيجي"], # Arabic

@weiji14 weiji14 Nov 25, 2025

Copy link
Copy Markdown
Member

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.

All reactions
@seisman @weiji14
Update pygmt/tests/test_geopandas.py [skip ci]
2f040fe
Co-authored-by: Wei Ji <[email protected]>
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Nov 25, 2025
@seisman
seisman merged commit f9f343d into main Nov 26, 2025
@seisman
seisman deleted the geopandas/nonascii branch November 26, 2025 00:54
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Nov 26, 2025
@yvonnefroehlich

yvonnefroehlich commented Nov 27, 2025

Copy link
Copy Markdown
Member

Ah, OK. Thanks for looking at this 🙂.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@weiji14 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

Projects

None yet

Milestone

0.18.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@seisman @yvonnefroehlich @weiji14
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.