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 #5

Closed
hugovk opened this issue Dec 28, 2017 · 7 comments
Closed

"Squashed" maps #5

hugovk opened this issue Dec 28, 2017 · 7 comments

Comments

@hugovk
Copy link
Contributor

hugovk commented Dec 28, 2017

My maps look great, but also a bit squashed. If I plot it with Helsinki's bounding box:

p2a <- plot_map(data, lon_min = 24.8312, lon_max = 25.2022, lat_min = 60.1301, lat_max = 60.2893)

I get a map like this:

map001

When it normally looks more like this:

image

http://maps.stamen.com/#toner/11/60.1934/25.0715

Do you know what accounts for this, and how I could square it off? Thanks!

@marcusvolz
Copy link
Owner

That's strange, the addition of coord_equal() should provide the true aspect ratio. Could you provide your data?

@hugovk
Copy link
Contributor Author

hugovk commented Dec 29, 2017

Here's a single coastal route: 20130902-171543-Ride.gpx.zip

On Strava it looks like this:

image

> data <- process_data('.')
> p1 <- plot_facets(data)
> ggsave("plots/facets003.png", p1, width = 20, height = 20, units = "cm")
> p2a <- plot_map(data, lon_min = 24.8312, lon_max = 25.2022, lat_min = 60.1301, lat_max = 60.2893)
> ggsave("plots/map003.png", p2a, width = 20, height = 20, units = "cm", dpi = 600)

Which produces this facet:

facets003

But this map:

image

@marcusvolz
Copy link
Owner

The facet uses scales = "free" and doesn't use coord_equal, so it will scale to fill out the facet. The map uses coord_equal, so the x and y axes have the same relative scale (i.e. one unit on the x-axis is the same length as one unit on the y-axis).

From the raw data it looks like the ranges are [60.14653. 60.16568] and [24.920093, 24.961935], so it looks like the map is being plotted correctly - maybe the data has been corrupted?

As a temp solution you can just remove coord_equal from the map code and then manually resize the plot in RStudio before saving.

@hugovk
Copy link
Contributor Author

hugovk commented Dec 29, 2017

I think the data is fine, the first map is from 7 years of data and different devices, and if some were corrupt I'd expect the map as a whole to show more square, with some odd points. But the map as a whole looks accurate, except being "squashed".

The last file uploads and shows fine on GPSies:

screen shot 2017-12-29 at 17 06 16

Those ranges look correct. Here's one corner of those ranges, 60.14653N, 24.920093E:
image

And the other one, 60.16568N, 24.961935E:
image

So I guess 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

I wonder why that is?

@hugovk
Copy link
Contributor Author

hugovk commented Dec 29, 2017

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.

@hugovk
Copy link
Contributor Author

hugovk commented Dec 29, 2017

It's as easy as using ggplot2::coord_map() instead of ggplot2::coord_equal() to fix it!

image

@marcusvolz
Copy link
Owner

Thanks for figuring this out. It makes sense, Helsinki is further from the equator than Melbourne which is why my one didn't seem to be particularly distorted.

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

2 participants