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

"Squashed" maps #2

Open
hugovk opened this issue Sep 20, 2018 · 1 comment
Open

"Squashed" maps #2

hugovk opened this issue Sep 20, 2018 · 1 comment

Comments

@hugovk
Copy link
Contributor

hugovk commented Sep 20, 2018

This is a similar issue to marcusvolz/strava#5.

Plots of tracks in Helsinki, at 60 degrees north, look a bit squashed, as no map projection is used.

  1. Download and unzip this GPS track: 20130902-171543-Ride.gpx.zip
  2. Run:
import stravaplot as strava
s = strava.plot('20130902-171543-Ride.gpx')

s.color("gyroscope")

# display the plot
s.show()

# save it as an image
s.save('20130902-171543-Ride.png')

Plots this:

20130902-171543-ride

On Strava it looks like this:

image

What's going on is the "normal" maps aren't being plotted with 1:1 units. Looking at this next map from here shows nice squares, but one grid in one direction is 0N0.50, and to the other is 0E1.00:

image

Of course, the reason is the earth is a sphere and flat maps are projections. At the equator one degree of lat/lon are roughly equal. As we go further north, one degree of latitude gets to zero. At 60N, we're 2/3 up.

So we probably want to scale the latitude by how far away from the equator we are. Perhaps something along the lines of https://stackoverflow.com/a/14457180/724176?

@hugovk
Copy link
Contributor Author

hugovk commented Sep 23, 2018

Here's a branch with a workaround.

master...hugovk:mercator-workaround

Rather than appending latitude and longitude values, this uses a Mercator projection calculations to come up with x and y values instead. Dummy, unit map width and height values are used, as we don't know and don't need to know the final size as matplotlib will take care of that.

I've not submitted this as a PR, as any settings applied after the Mercator calculations, like padding, are using the original lat/lon scale, not the new x/y scale. But this works for my purposes as I'm not showing any scale or adjusting those settings.

Here's the new output:

20130902-171543-ride

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