3

I have (lat, lon) for the center of a circle.
I have a radius R in km.
My code

for (var i = 0; i < steps; i++) {
    let degrees = (i/steps)*360
    let radians = (Math.PI/180)*degrees
    let x = lat + radius * Math.cos(radians)
    let y = lon + radius * Math.sin(radians)
    coordinates.push([x,y])
}

returns an oval shape because of the latitude and variable radius is not in km, but in coordinates.

How can I adapt this code in order to generate a perfect circle?

1 Answers1

0

For not very large circle radius you can correct longitude dimension using division by cos(latitude), because meridian/parallel ratio depends on this value.

MBo
  • 77,366
  • 5
  • 53
  • 86