jazzband / geojson

Python bindings and utilities for GeoJSON
https://pypi.python.org/pypi/geojson/
BSD 3-Clause "New" or "Revised" License
905 stars 120 forks source link

using a valid geojson dictionary in a contructor #111

Closed dharasty closed 6 years ago

dharasty commented 6 years ago

There are cases where I have a dictionary that was decoded from valid JSON, and the JSON happened to be a GeoJSON object. It would be convenient to have a "load()" function that turns those in to instances of the geojson classes.

In other words, If I have this:

     # from some other source
    valid_geojson_decode = dict(type="Polygon", coordinates=....}

Now I have to do this:

     geojson.loads(json.dumps(valid_geojson_decode ))

Would like to do this:

     geojson.from_dict(valid_geojson_decode )
dharasty commented 6 years ago

Found this was already there! (Had to read the code; was not in the docs from here.)

Use: geom1 = geojson.GeoJSON.to_instance(valid_geojson_decode)