I'm trying to get the noise pollution layer from the following bts.dot.gov ESRI MapServer to render in R:

https://maps.bts.dot.gov/services/rest/services/Noise/CONUS_road_and_aviation_noise/MapServer

I'm using the following code in RStudio (all necessary packages are installed):

leaflet() %>% 
  setView(-117.1, 32.9, 10) %>%
  addEsriBasemapLayer(esriBasemapLayers$Oceans, autoLabels = TRUE) %>%
  addEsriDynamicMapLayer( 
    url = paste0("https://maps.bts.dot.gov/services/rest/services/Noise/CONUS_road_and_aviation_noise/MapServer"))

However, none of the noise pollution data is being rendered; I only see a blank map.

The following, virtually identical code for an ArcGIS MapServer does work (wildfire data):

leaflet() %>% 
  setView(-117.1, 32.9, 10) %>%
  addEsriBasemapLayer(esriBasemapLayers$Oceans, autoLabels = TRUE) %>%
  addEsriDynamicMapLayer( 
    url = paste0("https://maps7.arcgisonline.com/arcgis/rest/services/USDA_USFS_2014_Wildfire_Hazard_Potential/MapServer"))

Am I missing something here? The two map services seem very similar, but I have little experience. The BTS map does support dynamic layers, while the Wildfire map does not, but I have tried pulling the map using this option (among others) as well:

options = dynamicMapLayerOptions(dynamicLayers = "0")
  • 1
    I just discovered multiple messages in the console like this: "XMLHttpRequest cannot load maps.bts.dot.gov/services/rest/services/Noise/… due to access control checks." I'll leave this open just the same should anyone have guidance. – nod Nov 29 at 5:56

Solved it. I needed to set useCors to FALSE:

leaflet() %>% 
  setView(-117.1, 32.9, 10) %>%
  addEsriBasemapLayer(esriBasemapLayers$Oceans, autoLabels = TRUE) %>%
  addEsriDynamicMapLayer( 
    url = paste0("https://maps.bts.dot.gov/services/rest/services/Noise/CONUS_road_and_aviation_noise/MapServer/"),
    options = dynamicMapLayerOptions(useCors = FALSE))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.