Circle¶
Takes a Point and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
Example¶
import json
from geojson import Feature, Point
from turfpy.transformation import circle
center = Feature(geometry=Point((19.0760, 72.8777)))
cc = circle(center, radius=5, steps=10)
print(json.dumps(cc, indent=2, sort_keys=True))
{
"geometry": {
"coordinates": [
[
[
19.076,
72.922666
],
[
18.986041,
72.914058
],
[
18.93063,
72.891543
],
[
18.930858,
72.863753
],
[
18.986411,
72.841302
],
[
19.076,
72.832734
],
[
19.165589,
72.841302
],
[
19.221142,
72.863753
],
[
19.22137,
72.891543
],
[
19.165959,
72.914058
],
[
19.076,
72.922666
]
]
],
"type": "Polygon"
},
"properties": {},
"type": "Feature"
}
Interactive Example¶
from geojson import Point, Feature
from ipyleaflet import Map, GeoJSON
from turfpy.transformation import circle
center = Feature(geometry=Point((-75.343, 39.984)))
geo_json = GeoJSON(data=circle(center, radius=5, steps=10, units='km'))
m = Map(center=[39.978756161038504, -75.32421022653581], zoom=11)
m.add_layer(geo_json)
m