Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't directly deal with Northern Hemisphere latitudes #35

Open
ghost opened this issue Mar 28, 2017 · 1 comment
Open

Can't directly deal with Northern Hemisphere latitudes #35

ghost opened this issue Mar 28, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 28, 2017

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.

@forrestthewoods
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant