micahfreedman / monarch_map_gif

Tutorial for creating an animated .gif of monarch butterfly occurrence records from iNaturalist
6 stars 4 forks source link

get_map error #1

Closed Biogeomur closed 4 years ago

Biogeomur commented 4 years ago

Thank you for sharing this code. I was excited to try it with the plants I am monitoring on iNaturalist. I have gotten stuck with the get_map command. I did get a google API and entered the key in to R. However I am getting this error: Source : https://maps.googleapis.com/maps/api/staticmap?center=Topeka,%20Kansas&zoom=3&size=640x640&scale=2&maptype=satellite&language=en-EN&client=xxx&signature=xxx Error in aperm.default(map, c(2, 1, 3)) : invalid first argument, must be an array In addition: Warning message: In get_googlemap(center = location, zoom = zoom, maptype = maptype, : HTTP 400 Bad Request

Do I need to do something more on the Google API side?

Thank you for any assistance.

Biogeomur commented 4 years ago

I figured it out! I did have to change my API client name. Now I am getting an error after this code

monarchs.anim #display the .gif

Error in seq.default(range[1], range[2], length.out = nframes) : 'from' must be a finite number In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf

micahfreedman commented 4 years ago

Glad you got the API key figured out!

Hmm, not sure what might be causing that error. Are you able to generate a single static map showing all of your observations? My best guess is that the issue is with the transition_time() argument; I think that it can only accept numeric variables, so even if you are trying to plot something by month, you might need to wrap it with as.numeric() or as.integer(). Hope this helps.

Biogeomur commented 4 years ago

Thanks for the reply. I got it to work. Now I will just need to modify it to use our phenology data that we add to our iNat obs. (open flower along the AT) and maybe figure out a finer timestep to the color coding. I am new to R so this is a really helpful start. thanks again!

micahfreedman commented 4 years ago

Good to hear! I'm still learning all the time, too. Would love to see what you end up making.

If you have multiple species that you are monitoring and don't want to plot it all together, you could also use facet_wrap(~Species) to display them separately. This tutorial has some more examples for making animated figures: https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/