2

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
  • 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, 2018 at 5:56

1 Answer 1

2

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 agree to our terms of service and acknowledge you have read our privacy policy.

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