Open jdkleiner opened 3 years ago
To run these maps - see the code block at the bottom of cumulative_hydrotools_tidy.R
Hi Joey,
I am having troubles using your CIA_maps.R code. I am pretty sure my problem is being unable to download the "wicket" package. It looks like the package was removed from CRAN on 1/27/21 so I am unable to download it directly. I also tried to download it through a github repository: devtools::install_github("ropensci/wicket"), but that also didn't work. I also just tried downloading an archived version of the package and that did not seem to work either. I'm wondering if you have any advice on how to get around this issue. Thanks!
@jdkleiner
Thanks for sleuthing, not sure I've run into this particular issue before where a package is removed from CRAN. BUT it was an easy fix nonetheless :) The function wkt_centroid() that was housed in the "wicket" package has been incorporated into the package "wellknown". I've updated the code accordingly, so all you need to do is make a pull of the HARParchive repo and you should be in business!
Holler if you run into any more snags
@nabrahams1
Hey Joey,
Thanks for getting back to me! Not running into that error anymore. I tried running it a few times within my app and then just in a separate R file and it kept popping up the error below. May be just an easy mistake that I'm missing and I will definitely get back into it next week. Thanks again!
Here's the error that keeps popping up:
Error in mget(words, envir, "any", NA, inherits = TRUE) :
@jdkleiner
Are you getting the error when running the load_MapLayers() or the CIA_maps() function? And do you know what line is resulting in the error, or generally how much of the code executes before it spits out the error? May be easiest to just past in your full RStudio console output to this thread so I can dig in.
Thanks, and sorry for the error!
@nabrahams1
Hi Joey,
I have been working on getting this map into the R shiny app and I'm still running into a few issues. Now when I'm running it, I keep getting an error that reads:
[1] "PROCESSING: OR"
[1] "RETRIEVING BASEMAP:"
Warning: Error in : no such column: seglist
110:
I think it must be tripping up at retrieving the base map but I am having trouble understanding why "seglist" is needed and how the shiny code has changed "seglist" so that it isn't found anymore. Thanks!
@jdkleiner
Hmm, In your shiny code does the "cia_data" dataframe that gets fed into the CIA_maps() function still have a column named "seglist"?
That's used in the ggplot for labeling the riversegs on the map
@nabrahams1
Figured out that error! Our functions for generating the cia_data data frame were slightly different, so I just had to add a lf code from your script that generated the numbered list of segments. I am working on a slight error right now with the file name and hopefully I'll be able to solve that today!
Sweet! Post some snazzy screenshots if you get it functional!
Hey Joey. I'm still a bit confused on how cumulative_hydrotools_shiny.R works. In the last few lines of the code, how does ggsave save the map file that you've generated? Is it just saving the "cia_map" list that you've generated? I think the error in the shiny code pops up because saving to the local drive is different then rendering an image in R shiny. Thanks again for all your help.
@jdkleiner
Ah yeah so ggsave() defaults to the last plot object, perhaps it would have been clearer if I had the code explicit like:
ggsave(paste0(export_path,riv_seg,"_cia_map.png",sep = ""),plot = cia_map, width=5.5, height=5)
You should be able to just remove that line for use in your shiny app, just display the cia_map object
@nabrahams1
Needs some sizing changes and some more edits here and there but success! Thanks again for all of your help.
@jdkleiner
Excellent! Great work getting the map in there, that shiny dashboard is really shaping up!
@nabrahams1
Also Natty, can you go ahead and push your progress to GitHub when you get a chance? I want to test using your shiny app for a modeling project I'm currently working on :) @nabrahams1
Just added!
@jdkleiner
Thanks, I was able to get it running no problem!
@nabrahams1
FYI Natty I made a couple handy updates to the shiny app code, take a look at my recent merged pull request to check it out. Something that would be good for you to work on is replacing the AllSegList that's hard coded into script with the list of Rsegs it pulls in from VAHydro- this will be critical for running the app for VWP projects that have resegmented Rsegs (aka hydrocode in the format "TU3_8880_9230_sf_big_cherry").
@nabrahams1
Initial Testing - JK modifying mapping script used for generating maps in the State Plan, adapting code to be more portable, and allow mapping of the river segments presented in the HARP CIA plots.
Example Plots:
(Still need to improve the way it overlays rseg names, but initial results below).![cia_map](https://user-images.githubusercontent.com/29379385/112354353-fbade400-8ca2-11eb-9c77-c9764543144c.png)