Can someone explain the following python code.


value_geojson is a geojson variable. I like to think that I'm not a total python newbie but these are too many [] for me. I am a GeoJSON newbie though.

Would appreciate help on that one, eventhough I know it's probably to simple for SE


1 Answer 1


See sections 3.2 and 3.3 of the geojson standard.

It looks like value_geojson is a FeatureCollection object, which have a single member "features" which is a list of Feature objects. So


is now just the first Feature object. Those have a few members, including "properties", which is an arbitrary JSON object. At that point we're outside of the geojson standard, so whatever "title" means is more context-specific.

  • $\begingroup$ ok that already helped me a bit. So, "value_geojson["features"][0]" returns the first Object in value_geojson. Each Object is basically a python dictionary with the keys "properties" and "title". Thus, the full line returns the values of both keys for the first Object? In the tutorial I saw that line it returns "5000.00 ". Thus, "5000.00" is the value stored in "Properties" and " " is the value stored in "title"? $\endgroup$
    – DGIS
    Commented Jan 11, 2021 at 19:23
  • $\begingroup$ No, those last two are also nested. ...["properties"] is itself a dictionary, probably with many key-value pairs, one of which is evidently (very strangely) "title": "5000.00". Try printing value_geojson["features"][0]["properties"].keys(). $\endgroup$
    – Ben Reiniger
    Commented Jan 11, 2021 at 19:37
  • $\begingroup$ Ok I understand. Thanks a lot :). When I run your line I get: dict_keys(['fill', 'fill-opacity', 'stroke', 'stroke-opacity', 'stroke-width', 'title']). Thus, yes title has apparently the value "5000.00". $\endgroup$
    – DGIS
    Commented Jan 11, 2021 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.