Feature request: turf.circle
See original GitHub issueThis is a proposal to add a function that creates a circle (approximated polygon) given a point and a radius. Example:
var point = turf.point([52.521921, 13.399553]);
var circle = turf.circle(point, 50, "km");
When the buffer issue is fixed, the implementation can just be a call to buffer with the point. However, I think this function is useful in itself, and might be easier to implement.
My use case is to be able to specify an area either as a polygon or a circle and using turf.within
to check my points, instead of having two different code paths (turf.within
vs. turf.distance(...) < radius
).
Some extra thoughts:
- The function could take an optional
options
, where you can specify the number of segments and/or a precision. I think the function should have some defaults built-in to provide a good number of segments depending on the radius. - If it’s too hard to make it work around the north/south poles, I think in the beginning it could be documented as a known issue. At least my own use case is related to major cities around the world.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Turf.js | Advanced geospatial analysis
Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and...
Read more >turf - GeoServer find all features within a certain radius
I'm creating a Node JS backend in order to find and manipulate those routes. In order to find the routes I thought to...
Read more >turf/circle
Start using @turf/circle in your project by running `npm i @turf/circle`. There are 135 other projects in the npm registry using @turf/circle.
Read more >Turf.js to find bounding box of data loaded with Mapbox GL ...
As already noted, the Turf.js does not know anything about the Mapbox ... bbox = turf.bbox({ type: 'FeatureCollection', features: f }); map.
Read more >OpenLayers Examples
Example of using an ArcGIS REST Feature Service with a Tile strategy. ... Example of using Draw and Modify interactions for geodesic circles....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
turf.circle
is here now: https://github.com/Turfjs/turf/tree/master/packages/turf-circleWoohoo! Been looking for this update for a long time 👍