NEFSC / NEFSC-Spatial

http://nefsc.github.io/NEFSC-Spatial
http://nefsc.github.io/NEFSC-Spatial
Other
7 stars 0 forks source link

Add leaflet maps to pkgdown site #51

Closed jmhatch closed 1 year ago

jmhatch commented 1 year ago

Resolves #49 and #50.

For now, leaflet maps need to be built locally to avoid having to re-build them every time the pkgdown site is re-built and re-deployed (it takes some time). Could change this in the future w/ a GitHub action. The leaflet maps and corresponding .Rmd files are generated using data-raw/create_leaflet_maps.R. The leaflet maps are stored in pkgdown/leaflet_maps as .rda files. The .Rmd files are stored in vignettes/articles. Also, added a Maps element to the navbar with a drop-down menu pointing to the corresponding .Rmd file with the leaflet map (which gets rendered to html when the site is built). Some datasets would not render on leaflet in a web browser, I'm guessing it's too much data (they often have very fine coastline data). Below is a list of data sets that are not included in Maps b/c of the leaflet issue:

  1. amapps_grid
  2. Herring_Management_Areas
  3. NAFO_Divisions_2021_poly_clipped
  4. Statistical_Areas_2010
  5. Statistical_Areas_2010_withNames
andybeet commented 1 year ago

@jmhatch This looks great. Nice job. Regarding the other data sets, i'll take a look at 2-5. I know the stat areas are unnecessarily large. And yes it is due to the coastline being overly detailed

@kimberly-bastille if you like this then merge the request

jmhatch commented 1 year ago

Thanks, @andybeet. What's weird is that I can get those large datasets to render on leaflet in RStudio's Viewer. But when I try to render the html in a web browser, like Chrome, it fails and gives an error message in the log console. Not sure what to make of it.

andybeet commented 1 year ago

@jmhatch Can you add the script to data raw showing how you created the rds files in the pkgdown folder? I am trying to see if i get the same issue as you do with the other data sets but unsure how to create those files that you call in the rmds

jmhatch commented 1 year ago

@andybeet, sorry about that. I thought they would get added, since they don't meet any of the .gitignore exclusion rules. But when I ran git status --ignored I saw a couple of files in data-raw/ that were being ignored. Weird. If you know what would cause this or if I'm doing something wrong let me know. I just added the files using git add -f [path-to-file]. Should be in the data-raw folder now in the add_leaflet branch.

andybeet commented 1 year ago

@jmhatch I was able to render all other datasets to html using your method (other than amapps). It does take some time to build website, but i'm not sure that is such a big deal. The gh action will only run when merging branches to main. However when building locally it will be an annoyance. Is that what you meant/found? Was that why you didnt want to add them to the repo?

jmhatch commented 1 year ago

Thanks @andybeet. So when you run pkgdown::build_site() and navigate to Maps/Herring_Management_areas (or one of the other troublemakers) in your web browser you see a leaflet map? I tried again and it still fails. Maybe it's a Chrome (or specific version of Chrome) issue?

andybeet commented 1 year ago

yes, when i do that i see a leaflet map in the browser image

jmhatch commented 1 year ago

Thanks @andybeet. It must be a local issue, so that's good to know. Could you tell me what web browser (and version) you're using? Also, could you create a PR for your branch to fold in those extra leaflet maps to main?

Also, IT just updated my R / RStudio / RTools installation. So it could be an R version issue.

andybeet commented 1 year ago

I am using chrome Version 115.0.5790.171 (Official Build) (64-bit). I will create a pull request now

jmhatch commented 1 year ago

Thanks @andybeet, appreciate it. I am using the same Chrome version, so I'm thinking it might be an R / R pkg version issue.