You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be good to add a statement to the readme pointing out that this code employs a coordinate system in which Y axis values decrease from bottom to top. Thus, it will choke (silently) in conventional geomapping applications using lat/lon coordinates (because latitude increases from bottom to top of a north-at-top map).
Short of wading into the code to patch that, users can quickly and easily transform their sites and bbox latitudes via this function so that they will work with this library. Just use this function to transform your latitudes: y2 = min + max - y1
where y1 = latitude, y2 = transformed latitude, min = minimum latitude (of the sites or bbox) and max = maximum latitude (of the sites or bbox). What this function does, in essence, is to flip your map vertically, so that the transformed map's y axis direction corresponds to the coordinate system the code expects. Then, after calculating the voronoi cells, transform their vertices' y coordinates back to map latitudes using the same function (i.e., flip the voronoi cells vertically, to conform to 'north up').
Note that no transformation of longitudes is required; this code's coordinate system expects x values to increase from left to right, which is what longitude does too, and the code handles negative longitudes just fine as is. But I have not looked into what happens if your map spans the equator or the prime meridian, nor have I checked whether it handles negative latitudes (okay, okay: I'm obviously U.S.-centric).
I know I would have found a sentence in the readme to this effect to be a real time-saver. But that said, thanks so much for this great code.
The text was updated successfully, but these errors were encountered:
You're spot on about the problem. But the solution is even simpler that you describe. All you need to transform is the bbox by swapping bbox.yt and bbox.yb. There's no need to transform and later untransform sites.
It might be good to add a statement to the readme pointing out that this code employs a coordinate system in which Y axis values decrease from bottom to top. Thus, it will choke (silently) in conventional geomapping applications using lat/lon coordinates (because latitude increases from bottom to top of a north-at-top map).
Short of wading into the code to patch that, users can quickly and easily transform their sites and bbox latitudes via this function so that they will work with this library. Just use this function to transform your latitudes:
y2 = min + max - y1
where
y1
= latitude,y2
= transformed latitude,min
= minimum latitude (of the sites or bbox) andmax
= maximum latitude (of the sites or bbox). What this function does, in essence, is to flip your map vertically, so that the transformed map's y axis direction corresponds to the coordinate system the code expects. Then, after calculating the voronoi cells, transform their vertices' y coordinates back to map latitudes using the same function (i.e., flip the voronoi cells vertically, to conform to 'north up').Note that no transformation of longitudes is required; this code's coordinate system expects x values to increase from left to right, which is what longitude does too, and the code handles negative longitudes just fine as is. But I have not looked into what happens if your map spans the equator or the prime meridian, nor have I checked whether it handles negative latitudes (okay, okay: I'm obviously U.S.-centric).
I know I would have found a sentence in the readme to this effect to be a real time-saver. But that said, thanks so much for this great code.
The text was updated successfully, but these errors were encountered: