Re: Scaling Geometry to Match Image File


katsonandrew3.5@...
 

In case this helps. Here is how I did scaling it to get more accurate numbers originally before I switched but this was even flawed:

world_total_bounds = world_boundaries.total_bounds

population_image_total_bounds = world_pop_image.bounds

x_scale = (population_image_total_bounds.right - population_image_total_bounds.left) / (world_total_bounds[MAX_X] - world_total_bounds[MIN_X])
y_scale = (population_image_total_bounds.top - population_image_total_bounds.bottom) / (world_total_bounds[MAX_Y] - world_total_bounds[MIN_Y])

world_boundaries['geometry'] = world_boundaries['geometry'].apply(lambda geometry: shapely.ops.transform(lambda x, y, z=None: (x * x_scale, y * y_scale), geometry))

Join main@fiona.groups.io to automatically receive all group messages.