massbays-tech / MassWateR

R package for working with Massachusetts surface water quality data
https://massbays-tech.github.io/MassWateR
Creative Commons Zero v1.0 Universal
11 stars 3 forks source link

Create map function #26

Closed fawda123 closed 2 years ago

fawda123 commented 2 years ago

Create function to map results, uses results, accuracy, and sites file:

Results need to be summarized acros dates for a site, then color results by magnitude.

ben-wetherill commented 2 years ago

Looking amazing!

My comments:

  1. We need to be able to filter by location group.
  2. Can we suppress the lat/lon labels?
  3. We definitely need a better basemap. At the moment, I'm finding NULL to be the most pleasing option.
fawda123 commented 2 years ago

@ben-wetherill should be done:

anlzMWRmap(res = resdat, param = "DO", acc = accdat, sit = sitdat, maptype = NULL, locgroup = 'Sudbury', addwater = T, warn = F, latlon = F)

image

ben-wetherill commented 2 years ago

The latlon and location group work great.

The addwater is not quite exciting me yet. First of all, it takes a really long time to run, and a really long time to load the package. Each time I run a map, it takes several minutes. I also received a message at the beginning "Do you want to install from sources the packages which need compilation?" That will be troublesome for users. Secondly, it shows all water bodies, so it has a lot of extra water bodies that are probably not needed, especially for large scale maps. It's hard to see the rivers from the puddles.

fawda123 commented 2 years ago

Hm, it should not take that long to make the maps. It only takes a few seconds to make the map on my end, but that's just for the examples in the vignette. Does it take longer for other plots you've made?

It's also possible we can just clip the downloaded vector objects that overlap with site locations, although that might look odd since the downloaded objects aren't continuous. Maybe that's something we can decide during beta testing?

The load time for the package should only be a few seconds. I just noticed I accidentally had a copy of the website in the main branch of the package, which I just deleted. Try reinstalling and see if the load time is the same. The compilation message is also odd, I don't see that on my end. We can discuss on Thursday.

ben-wetherill commented 2 years ago

It seems to be running faster now - 10 seconds for full OARS dataset.

I keep getting this error anlzMWRmap(resdat, param="DO saturation", acc=dqoaccdat, sit=sitedat, palcol = "Spectral", maptype = "terrain-background", addwater = TRUE, latlon = FALSE, locgroup = "Lower Assabet",) Error in resp_abort(): ! HTTP 504 Gateway Timeout. Run rlang::last_error() to see where the error occurred. Warning message: In st_buffer.sfc(., dist = units::set_units(buffdist, degree)) : st_buffer does not correctly buffer longitude/latitude data

And this message Coordinate system already present. Adding new coordinate system, which will replace the existing one.

And this warning: anlzMWRmap(resdat, param="DO saturation", acc=dqoaccdat, sit=sitedat, palcol = "Spectral", maptype = NULL, addwater = TRUE, latlon = FALSE, locgroup = "Sudbury",) Warning message: In st_buffer.sfc(., dist = units::set_units(buffdist, degree)) : st_buffer does not correctly buffer longitude/latitude data

fawda123 commented 2 years ago

@ben-wetherill let me know if you still get that timeout error. I think that's caused by a server issue with the open street map layer when you use the addwater option. I updated the code so it will ping the server again until it gets the data, but it's difficult to test on my end.

I need to figure out those other warnings/messages. I know what causes it, but it's tricky to suppress.

Adding this here for my own reference: https://stackoverflow.com/questions/71927170/how-to-suppress-warnings-globally-in-a-r-package-function

ben-wetherill commented 2 years ago

I'm not getting the timeout error any more.