How to get value from a .geojson that was converted into a geopandas GeoDataFrame?

Viewed 28

I got the following .geojson file from Overpass API:

{
  "type": "FeatureCollection",
  "generator": "overpass-ide",
  "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
  "timestamp": "2022-07-18T07:57:39Z",
  "features": [
    {
      "type": "Feature"
...

I converted this simply with gdf = geopandas.read_file(filename) into a GeoDataFrame object. This all worked great.

The GeoDataFrame object now contains all elements that were listed inside of "features" within the .geojson.

But now I wondered if there is any way for me to access the value for "timestamp" on this GeoDataFrame object? Or does the GeoDataFrame object not even contain this key/value-pair anymore?

gdf["timestamp"] does not work.

I could use the json-library like shown below, but then I would have to load the entire file again which seems like a huge waste of resources.

import json
f = open('filename.geojson', encoding="utf8")
data = json.load(f)
timestamp = data["timestamp"]

Any help would be much appreciated.

0 Answers
Related