GeoJSON¶
Description:
- Implements all the GeoJSON Objects described in The GeoJSON Format Specification.
Resources:
- [GitHub] https://github.com/jazzband/geojson
Example 1¶
Create geoJSON object from Point
In [ ]:
Copied!
from geojson import Point
Point((-115.81, 37.24))
from geojson import Point
Point((-115.81, 37.24))
Example 2¶
Create geoJSON object from Polygon
In [ ]:
Copied!
from geojson import Polygon
# No hole within polygon
no_hole = Polygon([[(2.38, 57.322), (-120.43, 19.15), (23.194, -20.28), (2.38, 57.322)]]) # doctest: +ELLIPSIS
# Polygon with hole
hole = Polygon([
[(2.38, 57.322), (-120.43, 19.15), (23.194, -20.28), (2.38, 57.322)],
[(-5.21, 23.51), (15.21, -10.81), (-20.51, 1.51), (-5.21, 23.51)]
]) # doctest: +ELLIPSIS
print(no_hole)
print(hole)
from geojson import Polygon
# No hole within polygon
no_hole = Polygon([[(2.38, 57.322), (-120.43, 19.15), (23.194, -20.28), (2.38, 57.322)]]) # doctest: +ELLIPSIS
# Polygon with hole
hole = Polygon([
[(2.38, 57.322), (-120.43, 19.15), (23.194, -20.28), (2.38, 57.322)],
[(-5.21, 23.51), (15.21, -10.81), (-20.51, 1.51), (-5.21, 23.51)]
]) # doctest: +ELLIPSIS
print(no_hole)
print(hole)