YoJimboDurant / rmet2

R package for downloading data, processing, and QA'ing US EPA's AERMET program
MIT License
8 stars 2 forks source link

No "aersurface/nws_sfc_chars.out" #12

Open zxy1219 opened 1 year ago

zxy1219 commented 1 year ago

Thanks for creating such a useful package! I got a error when running the "kpit <- processMet(kpit, processor=c("aerminute", "aersurface", "aermet1", "aermet2", "aermet3"))" using the example code of your Pittsburgh airport case. The error indicated that there is no "nws_sfc.char.out" in my aersurface folder. How to fix this error?

zxy1219 commented 1 year ago

I got a similar issue while running the "processMet(station_name, processor="aerminute")". R says that there is no "aerminute_log" or other record files.

YoJimboDurant commented 1 year ago

Thanks for the feedback! Thanks to your feedback, I discovered that I needed to modify the example script to accommodate some of the TIFF tags that are inside the FedData land use files. This is accomplished by converting the rasters to terra SpatRast objects. Assuming you have added terra to your library:

# Download land use data using buffer - landcover
lc_2016 <-
  get_nlcd(
    as(sfc_station, "Spatial"),
    dataset = "landcover",
    label ="landcover",
    extraction.dir = paste(rootDir, "preprocessed_data", sep = "/"),
    force.redo = T,
    year = 2016,
    raster.options =c("COMPRESS=NONE", "TFW=YES", "datatype=INT1U")
  )

# tree cover
tc_2016 <-
  get_nlcd(
    as(sfc_station, "Spatial"),
    dataset = "canopy",
    label = "canopy",
    extraction.dir = paste(rootDir, "preprocessed_data", sep = "/"),
    force.redo = T,
    year = 2016,
    raster.options =c("COMPRESS=NONE", "TFW=YES", "datatype=INT1U")
  )

# impervious cover
imp_2016 <-
  get_nlcd(
    as(sfc_station, "Spatial"),
    dataset = "impervious",
    label = "Imperv",
    extraction.dir = paste(rootDir, "preprocessed_data", sep = "/"),
    force.redo = T,
    year = 2016,
    raster.options =c("COMPRESS=NONE", "TFW=YES", "datatype=INT1U")
  )

# Add some projection information
lc_2016aea <- project(
  rast(lc_2016),
  y = " +proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs",
  method = "near",
  res = c(30, 30),
  wopt = list(gdal = c("COMPRESS=NONE", "TFW=YES")),
  filename = gsub("[.]tif", "_rmet2.tif", raster::filename(lc_2016)),
  overwrite = T,
  datatype = "INT1U"
)

tc_2016aea <-
  project(
    rast(tc_2016),
    y = " +proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs",
    method = "near",
    res = c(30, 30),
    wopt = list(gdal = c("COMPRESS=NONE", "TFW=YES")),
    filename = gsub("[.]tif", "_rmet2.tif", raster::filename(tc_2016)),
    overwrite = T
  )
imp_2016aea <-
  project(
    rast(imp_2016),
    y = " +proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs",
    method = "near",
    res = c(30, 30),
    wopt = list(gdal = c("COMPRESS=NONE", "TFW=YES")),
    filename = gsub("[.]tif", "_rmet2.tif", raster::filename(imp_2016)),
    overwrite = T
  )

The other thing to be aware of is that you cannot use spaces in the directory for where your surface files are located. AERSURFACE seems not to recognize spaces in paths.

I will revise the example files with the new process. Thanks again!