question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: turf.circle

See original GitHub issue

This 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:

  1. 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.
  2. 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:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mstdokumacicommented, Jun 3, 2016
0reactions
DenisCarrierecommented, Jun 6, 2016

Woohoo! Been looking for this update for a long time 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found