I would like to create buffered polygons of locations (towns, villages etc) in order to use them for searching in radius.
This is what I would like to achieve (units for ilustration):
This is how I do it in pyclipper:
import pyclipper
coordinates = # Array of lat,lng tuples
clipper_offset = pyclipper.PyclipperOffset()
coordinates = pyclipper.scale_to_clipper(coordinates)
clipper_offset.AddPath(coordinates, pyclipper.JT_ROUND,
pyclipper.ET_CLOSEDPOLYGON)
scaled_coordinates = clipper_offset.Execute(1000.0)
scaled_coordinates = pyclipper.scale_from_clipper(scaled_coordinates)
Number 1000.0 is arbitrary and my question is - how do I calculate the right offset ratio for Execute method, so that the offsetted polygon will approximately represent 10,20 and 50km radius ?
Btw. is this the right approach to this problem ?
The way that worked for me:
import pyclipper
coordinates = [(198,362),(220,330),(282,372),(260,404)] # Array of lat,lng tuples
clipper_offset = pyclipper.PyclipperOffset()
coordinates_scaled = pyclipper.scale_to_clipper(coordinates)
clipper_offset.AddPath(coordinates_scaled, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
new_coordinates = clipper_offset.Execute(pyclipper.scale_to_clipper(10))
new_coordinates_scaled = pyclipper.scale_from_clipper(new_coordinates)
I mean:
new_coordinates = clipper_offset.Execute(pyclipper.scale_to_clipper(10))
10 or any other value that you need.
It based on baji answer that don't work for me
[ scale_to_clipper(x) => pyclipper.scale_to_clipper(x) ]