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

Re: latest sf/ggplotblog posts, facetting, rnaturalearth #33

Open
adrfantini opened this issue Oct 26, 2018 · 5 comments
Open

Re: latest sf/ggplotblog posts, facetting, rnaturalearth #33

adrfantini opened this issue Oct 26, 2018 · 5 comments

Comments

@adrfantini
Copy link

adrfantini commented Oct 26, 2018

These are 2 suggestions for improving the three (really good) blog posts recently published regarding plotting spatial data with ggplot2 and sf.

I wasn't sure where to leave these, as I do not know how to reach the authors.

  1. I personally use facetting in ggplot quite often, way more often than I use cowplot or patchwork to arrange plots manually. Of course facets work well with sf data, they look clean and you do not have to bang your head around to find the proper size ratios. The downside is that they are, of course, much less flexible. E.g. you cannot plot two different physical dimensions next to one another, but you can plot the same thing from different datasets.
  2. I find grabbing spatial data from rnaturalearth, rnaturalearthhires and rnaturalearthdata is much more convenient than using maps or rworldmap. These packages interface to http://www.naturalearthdata.com/, optionally providing sf objects as output. One neat and useful thing is that if you grab, for example, both country boundaries and municipalities, they match exactly, avoiding small and ugly differences which come from using datasets from different sources.
@edzer
Copy link
Member

edzer commented Oct 26, 2018

Great suggestions; the authors are @melimore86 and @basille . Maybe room for a jointly written part 4?

@basille
Copy link
Contributor

basille commented Oct 29, 2018

Hey @adrfantini, both suggestions are indeed very good! The first is not something we use very often, but I can see the benefits — that would have been a good fit on Part 3. As for the second suggestion, I actually never used those packages! It would be great indeed to look into them, and include them in our original pieces!

I like the suggestion of @edzer , although I don't know if @melimore86 would be available to work on this one. I'd be happy to help and guide this part. Would you know how to make it a consistent piece (i.e. Part 4, as suggested by @edzer)?

@adrfantini
Copy link
Author

Hi @basille , I have personally never used RMD, but It does not look too complicated, I think I could try and I'd be glad to. Problem is I do not have any spare time before the beginning of January, due to annoyances like having to write a thesis and such: I do not want to commit to other projects right now, however small they are.

I'll be happy to do this in January. In the meantime, if you want to implement my suggestions your self, feel free of course.

@melimore86
Copy link
Contributor

Hello,

Great suggestions. I am taking a look at ggplot faceting to incorporate that into Tutorial 3. I will also look in those packages mentioned to compare the differences.

Thanks,
Mel M

@andysouth
Copy link

andysouth commented Oct 30, 2018

Hello all,
Firstly great three posts, 2ndly great suggestions by @adrfantini.

I developed rworldmap and rnaturalearth and I was just about to suggest using rnaturalearth.

rworldmap : older, no longer in active development, does lots of things
rnaturalearth : newer, active development, just the data

I would suggest replacing this

library("rworldmap")
library("rworldxtra")
world <- getMap(resolution = "high")

with:

library(rnaturalearth)
world <- ne_countries(scale='medium')

or you can get it to do the sf conversion for you
world <- ne_countries(scale='medium', returnclass = 'sf')

You would also need to change the install to rnaturalearth and rnaturalearthdata.

I think the only other thing you would need to alter in the posts is to change the fieldnames NAME and POP_EST to lowercase to fit with the more recent Natural Earth data.

Happy to check further for you.

I should probably ad something to the rworldmap readme pointing people to rnaturalearth.

Andy

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

5 participants