duckdb / duckdb_spatial

MIT License
451 stars 33 forks source link

SHP driver open_options does not seem to work with ENCODING option #356

Open ttomasz opened 2 months ago

ttomasz commented 2 months ago

Example files:

SQL example:

select *
from st_read('/vsizip/./Downloads/020101.zip/PRG_PunktyAdresowe_020101.shp', open_options=['ENCODING=WINDOWS-1250']) 
limit 5;

Result:

┌─────────┬─────────┬─────────┬─────────────┬─────────┬─────────────────────┬─────────┬───────────────────────────────────────────────┐
│  TERYT  │   PNA   │ SIMC_id │ SIMC_nazwa  │ ULIC_id │     ULIC_nazwa      │  Numer  │                     geom                      │
│ varchar │ varchar │ varchar │   varchar   │ varchar │       varchar       │ varchar │                   geometry                    │
├─────────┼─────────┼─────────┼─────────────┼─────────┼─────────────────────┼─────────┼───────────────────────────────────────────────┤
│ 020101  │ 59-700  │ 0935989 │ ????INVAL…  │ 18648   │ ????INVALID VALUE…  │ 34      │ POINT (260060.88199839657 382544.5259835962)  │
│ 020101  │ 59-700  │ 0935989 │ ????INVAL…  │ 09421   │ ????INVALID VALUE…  │ 82      │ POINT (262141.78239842618 381462.537184705)   │
│ 020101  │ 59-700  │ 0935989 │ ????INVAL…  │ 02058   │ ????INVALID VALUE…  │ 13      │ POINT (258755.64489838033 383519.40798285604) │
│ 020101  │ 59-700  │ 0935989 │ ????INVAL…  │ 07026   │ ????INVALID VALUE…  │ 27C     │ POINT (261791.14839842354 382338.35378450714) │
│ 020101  │ 59-700  │ 0935989 │ ????INVAL…  │ 07026   │ ????INVALID VALUE…  │ 27B     │ POINT (261788.7517984234 382329.84118450433)  │
└─────────┴─────────┴─────────┴─────────────┴─────────┴─────────────────────┴─────────┴───────────────────────────────────────────────┘

Using that encoding in open options works with ogrinfo.

rouault commented 1 month ago

Using that encoding in open options works with ogrinfo.

I suspect the GDAL build of duckdb_spatial isn't built against libiconv

Maxxen commented 1 month ago

Using that encoding in open options works with ogrinfo.

I suspect the GDAL build of duckdb_spatial isn't built against libiconv

Thanks for having a look at this! But yes, it's not built against libiconv. IIRC it was somewhat difficult to build it statically cross platform but we could have another attempt at doing so in the future, ideally after we rework the current build setup, although I don't have a timeline for that.