Skip to content

USEPA/campd-viz-gallery-facility-map

Repository files navigation

Clean Air Market Program Data (CAMPD) Viz Gallery Facility Map

This repo is for CAMPD's R Shiny App facility map. The app uses lealfet to display a map of facilities that exist in the Clean Air Power Sector Programs database. It also provides users based data on the facility attributes and compliance performance.

Getting started

Running local

After cloning the repo, run

shiny::runApp()

Deploying to the cloud

1) Vendor r packages

The r packages that are installed for this app are found at r-shiny-cloud-gov-instructions. Clone this repo and copy everything from /src/contrib into this apps /vendor_r/src/contrib directory.

2) Prep for pushing to the cloud

  • Update the enviroment variable for the application named APP_VERSION. This is what will show up in the bottom bar of the page.
  • Uncomment/switch out these lines in their respective locations
library_path <- paste("Library Path: ", Sys.getenv(c("LD_LIBRARY_PATH")))
print(paste("LD_LIBRARY_PATH: ", library_path))

lib_dir <- "/home/vcap/deps/0/r/lib"
local_lib_dir <- "r-lib"
local_bin_dir <- "r-bin"

if (dir.exists(lib_dir)) {
  if (dir.exists(local_lib_dir)) {
    # Get the list of libs
    lib_tars <- list.files(local_lib_dir)
    lib_tars <- paste(local_lib_dir, lib_tars, sep = "/")
    
    print(paste("Local libs: ", lib_tars))
    print(paste("Working directory: ", list.files(getwd())))
    
    # Copy the files to the lib_dir
    for (i in 1:length(lib_tars)) {
      untar(lib_tars[i], exdir = lib_dir)
    }
    
    Sys.setenv(PROJ_LIB = lib_dir)
    
  }
  if (dir.exists(local_bin_dir)) {
    Sys.setenv(RMARKDOWN_PANDOC = local_bin_dir)
    Sys.setenv(PATH = paste("/home/vcap/app/",
                            local_bin_dir, ":${PATH}", sep = ""))
  }
  print(list.files(lib_dir))
}
# get application environment variables
APPLICATION_ENV_VARIABLES <- fromJSON(Sys.getenv(c("VCAP_APPLICATION")))
epaSlimHeader("epaNav",APPLICATION_ENV_VARIABLES$space_name),
#epaSlimHeader("epaNav","local"),
epaSlimFooter("epaFoot", appVersion = Sys.getenv(c("APP_VERSION")), appPublished = format(Sys.Date(),"%a %b %d %Y"))
#epaSlimFooter("epaFoot", appVersion = "v1.0.0", appPublished = format(Sys.Date(),"%a %b %d %Y"))
#shiny::runApp(shinyApp(ui,server))
# switch to below while deploying
shiny::runApp(shinyApp(ui,server), host="0.0.0.0", port=strtoi(Sys.getenv("PORT")))

3) Push the App

In your terminal cf push APPNAME

Find Cloud Foundry's doc page for more info.

Other information

Data Source

This map pulls data hosted on CAMPD R Shiny Data Source which is updated nightly using the CAM APIs.

R Shiny One EPA Template

This EPA R Shiny Template uses the react components from the EASEY Design System.

USWDS Styling

By using the EPA R Shiny Template, you also incorporate USWDS stying. Find documentation in the Utilities section.

Disclaimer

The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.