Welcome to the Utopia Forums! Register a new account
The current time is Mon Jun 21 09:10:11 2021

Utopia Talk / Politics / (OT) R for geospatial mapping
Y2A
Member
Thu Apr 15 15:18:08
I'm wondering if any of you have ever used R and are familiar with using it's geospatial features (ggplot2, rgdal and other relevant packages).

As a pet project (that I am hoping to leverage for future work projects as well) I am putting together the results of the 2021 Peruvian elections by region, province and municipality.

Surprisingly I have already been able to find shapefiles with these administrative divisions and am able to call them into R studio.

I'm just wondering, for anyone who's ever used it if you are aware of any good features you've run into for mapping the data and making it look more aesthetic. Or of any pitfalls to be aware of. First time using R for this, not a pro by any means.
Rugian
Member
Thu Apr 15 15:26:17
Never have, looks really cool though. Good luck
Sam Adams
Member
Thu Apr 15 15:59:11
Ive only used R for basic regression automation... but my impression was it was a decent language that was pretty easy to use. Havent used the map functions of it. Id suspect its pretty straightforward given the good reputation of R?
Y2A
Member
Tue Apr 27 00:14:51
keeping this up for motivation. just got around to being able to map the subdivisions using ggplot in an aesthetically pleasing way (there is a bit to making it look natural, like it is on a globe). now need to map the results to the subdivisions on my plot.

unfortunately, the ONPE (elections administrator), puts out CSVs for each individual subdivision down to the district level rather then having a single file that aggregates them all. I pulled the department (think state) CSVs and created a macro to pull all the relevant info into a single file. So I will be able to plot those.

But getting all the district-level (think every town/city) will be a real pain in the ass without putting together some kind of script that downloads all of these CSVs from their website. With that said, that kind of deep granularity is really what I am looking for, as department-level results maps are readily available.

http://www...ccionesPresidenciales/RePres/P
Y2A
Member
Tue Apr 27 00:24:13
any ideas for creating a program that automates the pulling of files from a website would be welcome.
Sam Adams
Member
Tue Apr 27 09:08:47
Thats easy, so long as they are not protected by those are you a human pictures. Any number of programs can automate downloads. On windows the most basic is powershell. Python is popular. C# is easy if you already have visual studio installed.
Wrath of Orion
Member
Tue Apr 27 20:31:49
Python would be ideal for pulling and organizing files. You can do your whole project in Python if you want, but it's perfectly feasible to handle the data collection through Python and then let R handle the rest. R's geospatial functionality has improved a lot over the last handful of years.

I would not use R to automate the data retrieval unless you must. I'm sure it is doable with the right package, but that's really not what R is good at.

I don't know how much specific help I can be because, though I'm experienced enough with geospatial work in both Python and R, I've been away from them long enough that I'd need to spend some time brushing up.
show deleted posts

Your Name:
Your Password:
Your Message:
Bookmark and Share