davidcarslaw / openairmaps

mapping functions to support openair
https://davidcarslaw.github.io/openairmaps/
GNU General Public License v3.0
21 stars 6 forks source link

Locations are plotted incorrectly. #18

Closed jenright-git closed 1 year ago

jenright-git commented 1 year ago

Having issues where the locations of multiple sites are being mixed up. Locations are swapping positions when plotted.

Occurring in windrosemap, polarMap and in manual creation using the addPolarMarker function.

Adding a label or popup with the "site" name plots all locations with the data of the first location.

jack-davison commented 1 year ago

Hi @jenright-git

There is a known bug in the release version of openairmaps that can end up jumbling up markers for data South of the Equator. Is that the case for you? (e.g., are you using data from South America or Australia/New Zealand?)

As a sanity check, try installing the development version and let me know if that fixes things. Note that you'll need the "devtools" (or "remotes") package.

# install.packages("devtools")
devtools::install_github("davidcarslaw/openairmaps")

If not, a reproducible example may be useful to help us diagnose your problem.

jenright-git commented 1 year ago

Hi Jack,

Thanks for the response. Yes, I am using data from Australia and installing the development version looks to have fixed the issue for the standard functions.

It doesn't appear to work on the addPolarMarkers function.

My code is below if you can spot anything wrong with it. Data is also attached.

leaflet::leaflet() %>% leaflet::addProviderTiles("Esri.WorldImagery") %>% openairmaps::addPolarMarkers( lng = "lon", lat = "lat", data = winddata, fun = openair::windRose, pollutant = "ws", label = "site", iconWidth = 150, iconHeight = 150, paddle = FALSE, angle = 22.5, width = 0.2, breaks = c(0.5, 1, 2, 3, 4, 5, 7, 10, 15, 20), dig.lab = 2, group = "Wind Rose"

) %>% openairmaps::addPolarMarkers( lng = "lon", lat = "lat", data = winddata, fun = openair::polarPlot, pollutant = "pm25", iconWidth = 150, iconHeight = 150, group = quickTextHTML("PM2.5 Polar Plot") ) %>%

openairmaps::addPolarMarkers(
lng = "lon",
lat = "lat",
data = winddata,
fun = openair::polarPlot,
pollutant = "pm10",
iconWidth = 150, iconHeight = 150,
#type = "lat",
group = quickTextHTML("PM10 Polar Plot")

) %>% openairmaps::addPolarMarkers( lng = "lon", lat = "lat", data = winddata, fun = openair::polarPlot, pollutant = "no", iconWidth = 150, iconHeight = 150, group = quickTextHTML("NO Polar Plot") )%>%

 openairmaps::addPolarMarkers(
lng = "lon",
lat = "lat",
data = winddata,
fun = openair::polarPlot,
pollutant = "no2",
iconWidth = 150, iconHeight = 150,
#type = "lat",
group = quickTextHTML("NO2 Polar Plot")
)%>%

  openairmaps::addPolarMarkers(
lng = "lon",
lat = "lat",
data = winddata,

fun = openair::polarPlot,
pollutant = "o3",
iconWidth = 150, iconHeight = 150,
#type = "lat",
group = quickTextHTML("O3 Polar Plot")
)%>%

openairmaps::addPolarMarkers(
lng = "lon",
lat = "lat",
data = winddata,
fun = openair::polarPlot,
pollutant = "co",
iconWidth = 150, iconHeight = 150,
#type = "lat",
group = quickTextHTML("CO Polar Plot")
)%>%

leaflet::addLayersControl(baseGroups = quickTextHTML(c("Wind Rose", "PM2.5 Polar Plot", "PM10 Polar Plot", "NO Polar Plot", "NO2 Polar Plot", "O3 Polar Plot", "CO Polar Plot")))

Appreciate the help.

Regards,

On Fri, Jan 6, 2023 at 1:10 AM Jack Davison @.***> wrote:

Hi jenright,

There is a known bug in the release version of openairmaps that can end up jumbling up markers for data South of the Equator. Is that the case for you? (e.g., are you using data from South America or Australia/New Zealand?)

As a sanity check, try installing the development version and let me know if that fixes things. Note that you'll need the "devtools" (or "remotes") package.

install.packages("devtools")

devtools::install_github("davidcarslaw/openairmaps")

— Reply to this email directly, view it on GitHub https://github.com/davidcarslaw/openairmaps/issues/18#issuecomment-1372261373, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4TL5MGDA6WGZBW4SKC5QSDWQ3I3XANCNFSM6AAAAAATR5GJVM . You are receiving this because you authored the thread.Message ID: @.***>

jack-davison commented 1 year ago

Hi again @jenright-git,

Thanks very much for spotting this; the addPolarMarkers() function uses some different code in the background that I overlooked updating when I fixed the Southern Hemisphere issues in polarMap() etc.

Could you redownload the dev version and let me know if the problem is now fixed?

I couldn't quite find your data, so if this hasn't fixed the problem do email it on to davison.jack.jd@gmail.com. If the problem has been fixed there's no need, however.

Cheers, Jack

jenright-git commented 1 year ago

The problem is fixed. Thanks again for looking at this, it's very helpful.

Thanks,

James

On Sat, Jan 7, 2023 at 11:07 PM Jack Davison @.***> wrote:

Hi again,

Thanks very much for spotting this; the addPolarMarkers() function uses some different code in the background that I overlooked updating when I fixed the Southern Hemisphere issues in polarMap() etc.

Could you redownload the dev version and let me know if the problem is now fixed?

Cheers, Jack

— Reply to this email directly, view it on GitHub https://github.com/davidcarslaw/openairmaps/issues/18#issuecomment-1374459189, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4TL5MERFG2NQ43COOOWGYDWRFL7FANCNFSM6AAAAAATR5GJVM . You are receiving this because you were mentioned.Message ID: @.***>

jack-davison commented 1 year ago

No worries James. I'll look to submit this fix to CRAN today/tomorrow, so you should be able to get the up-to-date version using install.packages() hopefully later this week.

Any further issues do get in touch!

Jack