Skip to content

ENH: detect and correctly handle JSON-encoded fields marked with OFSTJSON by GDAL #445

@veenstrajelmer

Description

@veenstrajelmer
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of geopandas.

  • (optional) I have confirmed this bug exists on the main branch of geopandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import geopandas as gpd
uhslc_gpd = gpd.read_file("https://uhslc.soest.hawaii.edu/data/meta.geojson")
time_min = uhslc_gpd["fd_span"].apply(lambda x: x["oldest"])

Problem description

The above code raises "TypeError: string indices must be integers, not 'str'" in geopandas>=1.0.0. For older versions the code runs successfully. The issue is that the column now contains strings with dicts instead of plain dicts. It seems that something goes wrong with the parsing of the geojson.

Expected Output

A subset of the original column.

Output of geopandas.show_versions()

SYSTEM INFO

python : 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)]
executable : C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\python.exe
machine : Windows-10-10.0.19045-SP0

GEOS, GDAL, PROJ INFO

GEOS : 3.11.2
GEOS lib : None
GDAL : 3.8.5
GDAL data dir: C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\Lib\site-packages\pyogrio\gdal_data
PROJ : 9.3.0
PROJ data dir: C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\Lib\site-packages\pyproj\proj_dir\share\proj

PYTHON DEPENDENCIES

geopandas : 1.0.0
numpy : 1.26.4
pandas : 2.2.2
pyproj : 3.6.1
shapely : 2.0.2
pyogrio : 0.9.0
geoalchemy2: None
geopy : 2.4.1
matplotlib : 3.8.4
mapclassify: None
fiona : 1.9.5
psycopg : None
psycopg2 : None
pyarrow : None

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions