HertieDataScience / SyllabusAndLectures

Hertie School of Governance Introduction to Collaborative Social Science Data Analysis
MIT License
37 stars 60 forks source link

Questions re generation of 3D globe mapping piracy attacks #78

Open laurencehendry opened 8 years ago

laurencehendry commented 8 years ago

Hi all,

Not sure if anyone else has been using the globejs package that we're looking forward to using to help present our findings on Friday.

Our code: https://github.com/bjoernboening/MaritimePiracy/blob/master/Shiny/3D%20Globe%20Piracy%20Mapped threejs examples site: http://bwlewis.github.io/rthreejs

However, we've been encountering one or two problems:

  1. How to change the colour schemes effectively (where in the code? This link has proven helpful to understanding colour schemes in R, but I can't seem to change the corresponding correct values for it to work for, e.g. changing the colour of landmasses: https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/colorPaletteCheatsheet.pdf)

2.How to reformat the variable for latitudinal data (or longitidunal data for that matter) so it's no longer string? (Unfortunately couldn't recreate the code that was entered into my console during our meeting, Chris). As you can see from the picture, this has badly messed up our latest renderings...

3.It would also be great to know how to change the arc lengths (we are trying to visualise violent attack dummy and coastal length, with longer arcs denoting this -but they currently remain very small...)

Many thanks!

Laurence

image image

christophergandrud commented 8 years ago

Re converting your lat and lon into numeric:

First gsub the , into .. with something like data$lat <- gsub(',', '.', data$lat). Second convert to numeric with data$lat <- as.numberic(data$lat). (Of course replace the data frame and variable names to what is relevant for you).

laurencehendry commented 8 years ago

Thanks! Problems 2 and 3 have now been resolved. (Arc length now provides helpful coast to country size ratio). Still trying to figure out colour schemes for borders... image

christophergandrud commented 8 years ago

Nice.

laurencehendry commented 8 years ago

Hi Chris,

Point 3 has now also been resolved. However, I've discovered there is a problem that often arises with the first rendering of the plot. Often times the first rendering is 'dark', as in no colours, which are crucial to understanding the plot. On the second command to render the output usually works fine again. This isn't a problem aside from for the website, since it is the first output that is knitted for the HTML page in R. My question: How can I get R to repeat my command of rendering the globe twice, and then to take the second rendering and not the first (since the first render only outputs correctly about 50% of the time).

Another problem is the time that it takes the website to load the 3D globes (over a minute; sometimes crashing; fastest with safari), hopefully this is not too big a problem.

Grateful for any help! Laurence

image

christophergandrud commented 8 years ago

Hi I'm at the airport and our if WiFi range. I'll likely be able to look at this tomorrow. Our stop by the office.

laurencehendry commented 8 years ago

Many thanks! Safe travels!