{ target_geotable : Targets ? Locate targets that you want to connect to a source }
{ source_geotable : Sources ? Locate sources }
{ source_range_in_meters : Source Range in Meters ? Specify the maximum distance at which a source can service a target }
# CrossCompute
target_geotable_path = 'random-polygons.csv'
source_geotable_path = 'random-lines.csv'
source_range_in_meters = 35000
target_folder = '/tmp'
import geotable
utm_proj4 = geotable.load_utm_proj4(target_geotable_path)
target_geotable = geotable.load(target_geotable_path, target_proj4=utm_proj4)
source_geotable = geotable.load(source_geotable_path, target_proj4=utm_proj4)
print('target_count = %s' % len(target_geotable))
from shapely.geometry import GeometryCollection
source_collection = GeometryCollection(source_geotable.geometries)
excluded_indices = []
for index, row in target_geotable.iterrows():
g = row['geometry_object']
if source_collection.distance(g) <= source_range_in_meters:
continue
excluded_indices.append(index)
from os.path import join
target_path = join(target_folder, 'excluded-target.kmz')
t = target_geotable
t = t.iloc[excluded_indices]
t.save_kmz(target_path)
print('excluded_target_count = %s' % len(t))
print('excluded_target_geotable_path = %s' % target_path)
{ target_count : Target Count ? Number of targets }
{ excluded_target_count : Excluded Target Count ? Number of targets that are too far from a source }
{ excluded_target_geotable : Excluded Targets ? Targets that are too far from a source }