# In Leaflet how to quarter a circle?

1587
2
07-13-2016 09:19 AM
Occasional Contributor II

I need to use a circle to select points, but I need to identify which points are in the NE, SE, SW, NW quads of the circle.. Since my circle is created by Lat/Long and a Radius, with the Radius being in meters how can I draw a line to bisect it into quarters?

My thoughts were to first select the points by circle, then create 4 squares(quads) and use them to further select the points inside the circle. However it turns out you need lat/longs to draw a square and I'd need to figure out how to get the Min/Max values for a square so many meters wide. Finally for the map graphic I'd have to clip the box using the circle.

My second option was create 4 arrays (NE,SE, SW, NW) and just run a check to see if they are North and East of the circle center coordinate, etc and place them in the correct array, than symbolize then using different colors based on array values.

Does anyone have any thoughts, Ideas, links, or code examples?

Tags (1)
1 Solution

Accepted Solutions
Frequent Contributor

your second option sounds reasonable to me.

just as a reminder, in Leaflet, when you call L.circle.toGeoJSON(), all that is returned is a point.  i wrote/cribbed some code to generate actual polygonal geometries and calculate area that you can check out here​, but i'd argue it might be overkill in this case.

2 Replies
Frequent Contributor

your second option sounds reasonable to me.

just as a reminder, in Leaflet, when you call L.circle.toGeoJSON(), all that is returned is a point.  i wrote/cribbed some code to generate actual polygonal geometries and calculate area that you can check out here​, but i'd argue it might be overkill in this case.

Occasional Contributor II

I solved the circle to GeoJSOn issue by first getting the points within the circles bounding box, then I loop through the data and check :