2

I am trying to read a shapefile with German letters (e.g.ß) with the following script:

import geopandas as gpd

df = gpd.read_file( r"path/to/file.shp", engine="pyogrio", use_arrow = True

)

However, I get an encoding error, and I did try to specify it with encoding = "utf-8", but I alsow tried "latin" and "ISO-8859-1", but none worked. This is the error message:

ArrowException: Unknown error: Wrapping Chausseestra�e failed

How can I fix it?

Is there a way to do this?

i.i.k.
  • 1,427
  • 5
  • 11
  • I believe that the fix is to define the encoding to match with the one used in the shapefile. Unfortunately it may be hard to find what encoding the shapefile is using. Similar problem in here https://stackoverflow.com/questions/65990086/geopandas-encodings-for-never-seen-before-characters. – user30184 Nov 09 '23 at 15:53
  • 1
    What if you try encoding = "cp1250" ? – Taras Nov 09 '23 at 15:59
  • @Taras I did try your solution, but unfortunately it didn't work. – i.i.k. Nov 09 '23 at 16:12
  • Can you please check the encoding of your shapefile? – Taras Nov 09 '23 at 16:40
  • How can I check my encoding? I have multiple files. – i.i.k. Nov 09 '23 at 17:23
  • https://gis.stackexchange.com/q/12218/99589 – Taras Nov 09 '23 at 18:24
  • What about ISO-8859-2 or cp1250 encodings ? – Taras Nov 09 '23 at 18:31
  • Both the encoding specified by an optional .cpg file and any encoding details present in the .dbf LDID header block are considered. – Taras Nov 09 '23 at 18:33
  • I'd try to add a .cpg text file to the shapefile (so same stem as .shp file, but suffix .cpg) with just the following tekst in it: CP1252. In the past it solved some issues for me with the text maïs (= dutch) in shapefiles. – Pieter Nov 10 '23 at 07:49
  • If CP1252 doesn't work, try replacing the CP1252 with some alternative encodings in the .cpg file, e.g. CP1250, ISO-8859-1, Windows-28591,... – Pieter Nov 10 '23 at 07:57

0 Answers0