isd_parse_line: Parse NOAA ISD/ISH data files - line by line

Description Usage Arguments Value References See Also Examples

View source: R/isd_parser_line.R

Description

Parse NOAA ISD/ISH data files - line by line

Usage

1
isd_parse_line(x, additional = TRUE, as_data_frame = TRUE)

Arguments

x

(character) a single ISD line

additional

(logical) include additional and remarks data sections in output. Default: TRUE

as_data_frame

(logical) output a tibble. Default: FALSE

Value

A tibble (data.frame)

References

ftp://ftp.ncdc.noaa.gov/pub/data/noaa

See Also

isd_parse

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
path <- system.file('extdata/024130-99999-2016.gz', package = "isdparser")
lns <- readLines(path, encoding = "latin1")
isd_parse_line(lns[1])
isd_parse_line(lns[1], FALSE)

res <- lapply(lns[1:1000], isd_parse_line)
library("data.table")
library("tibble")
as_tibble(
 rbindlist(res, use.names = TRUE, fill = TRUE)
)

# only control + mandatory sections
isd_parse_line(lns[10], additional = FALSE)
isd_parse_line(lns[10], additional = TRUE)

Example output

# A tibble: 1 x 38
  total_chars usaf_station wban_station date  time  date_flag latitude longitude
  <chr>       <chr>        <chr>        <chr> <chr> <chr>     <chr>    <chr>    
1 0054        024130       99999        20160000  4         +60750   +012767  
# … with 30 more variables: type_code <chr>, elevation <chr>,
#   call_letter <chr>, quality <chr>, wind_direction <chr>,
#   wind_direction_quality <chr>, wind_code <chr>, wind_speed <chr>,
#   wind_speed_quality <chr>, ceiling_height <chr>,
#   ceiling_height_quality <chr>, ceiling_height_determination <chr>,
#   ceiling_height_cavok <chr>, visibility_distance <chr>,
#   visibility_distance_quality <chr>, visibility_code <chr>,
#   visibility_code_quality <chr>, temperature <chr>,
#   temperature_quality <chr>, temperature_dewpoint <chr>,
#   temperature_dewpoint_quality <chr>, air_pressure <chr>,
#   air_pressure_quality <chr>,
#   AW1_present_weather_observation_identifier <chr>,
#   AW1_automated_atmospheric_condition_code <chr>,
#   AW1_quality_automated_atmospheric_condition_code <chr>, REM_remarks <chr>,
#   REM_identifier <chr>, REM_length_quantity <chr>, REM_comment <chr>
# A tibble: 1 x 31
  total_chars usaf_station wban_station date  time  date_flag latitude longitude
  <chr>       <chr>        <chr>        <chr> <chr> <chr>     <chr>    <chr>    
1 0054        024130       99999        20160000  4         +60750   +012767  
# … with 23 more variables: type_code <chr>, elevation <chr>,
#   call_letter <chr>, quality <chr>, wind_direction <chr>,
#   wind_direction_quality <chr>, wind_code <chr>, wind_speed <chr>,
#   wind_speed_quality <chr>, ceiling_height <chr>,
#   ceiling_height_quality <chr>, ceiling_height_determination <chr>,
#   ceiling_height_cavok <chr>, visibility_distance <chr>,
#   visibility_distance_quality <chr>, visibility_code <chr>,
#   visibility_code_quality <chr>, temperature <chr>,
#   temperature_quality <chr>, temperature_dewpoint <chr>,
#   temperature_dewpoint_quality <chr>, air_pressure <chr>,
#   air_pressure_quality <chr>
# A tibble: 1,000 x 38
   total_chars usaf_station wban_station date  time  date_flag latitude
   <chr>       <chr>        <chr>        <chr> <chr> <chr>     <chr>   
 1 0054        024130       99999        20160000  4         +60750  
 2 0054        024130       99999        20160100  4         +60750  
 3 0054        024130       99999        20160200  4         +60750  
 4 0054        024130       99999        20160300  4         +60750  
 5 0054        024130       99999        20160400  4         +60750  
 6 0039        024130       99999        20160500  4         +60750  
 7 0054        024130       99999        20160600  4         +60750  
 8 0039        024130       99999        20160700  4         +60750  
 9 0054        024130       99999        20160800  4         +60750  
10 0054        024130       99999        20160900  4         +60750  
# … with 990 more rows, and 31 more variables: longitude <chr>,
#   type_code <chr>, elevation <chr>, call_letter <chr>, quality <chr>,
#   wind_direction <chr>, wind_direction_quality <chr>, wind_code <chr>,
#   wind_speed <chr>, wind_speed_quality <chr>, ceiling_height <chr>,
#   ceiling_height_quality <chr>, ceiling_height_determination <chr>,
#   ceiling_height_cavok <chr>, visibility_distance <chr>,
#   visibility_distance_quality <chr>, visibility_code <chr>,
#   visibility_code_quality <chr>, temperature <chr>,
#   temperature_quality <chr>, temperature_dewpoint <chr>,
#   temperature_dewpoint_quality <chr>, air_pressure <chr>,
#   air_pressure_quality <chr>,
#   AW1_present_weather_observation_identifier <chr>,
#   AW1_automated_atmospheric_condition_code <chr>,
#   AW1_quality_automated_atmospheric_condition_code <chr>, REM_remarks <chr>,
#   REM_identifier <chr>, REM_length_quantity <chr>, REM_comment <chr>
# A tibble: 1 x 31
  total_chars usaf_station wban_station date  time  date_flag latitude longitude
  <chr>       <chr>        <chr>        <chr> <chr> <chr>     <chr>    <chr>    
1 0054        024130       99999        20160900  4         +60750   +012767  
# … with 23 more variables: type_code <chr>, elevation <chr>,
#   call_letter <chr>, quality <chr>, wind_direction <chr>,
#   wind_direction_quality <chr>, wind_code <chr>, wind_speed <chr>,
#   wind_speed_quality <chr>, ceiling_height <chr>,
#   ceiling_height_quality <chr>, ceiling_height_determination <chr>,
#   ceiling_height_cavok <chr>, visibility_distance <chr>,
#   visibility_distance_quality <chr>, visibility_code <chr>,
#   visibility_code_quality <chr>, temperature <chr>,
#   temperature_quality <chr>, temperature_dewpoint <chr>,
#   temperature_dewpoint_quality <chr>, air_pressure <chr>,
#   air_pressure_quality <chr>
# A tibble: 1 x 38
  total_chars usaf_station wban_station date  time  date_flag latitude longitude
  <chr>       <chr>        <chr>        <chr> <chr> <chr>     <chr>    <chr>    
1 0054        024130       99999        20160900  4         +60750   +012767  
# … with 30 more variables: type_code <chr>, elevation <chr>,
#   call_letter <chr>, quality <chr>, wind_direction <chr>,
#   wind_direction_quality <chr>, wind_code <chr>, wind_speed <chr>,
#   wind_speed_quality <chr>, ceiling_height <chr>,
#   ceiling_height_quality <chr>, ceiling_height_determination <chr>,
#   ceiling_height_cavok <chr>, visibility_distance <chr>,
#   visibility_distance_quality <chr>, visibility_code <chr>,
#   visibility_code_quality <chr>, temperature <chr>,
#   temperature_quality <chr>, temperature_dewpoint <chr>,
#   temperature_dewpoint_quality <chr>, air_pressure <chr>,
#   air_pressure_quality <chr>,
#   AW1_present_weather_observation_identifier <chr>,
#   AW1_automated_atmospheric_condition_code <chr>,
#   AW1_quality_automated_atmospheric_condition_code <chr>, REM_remarks <chr>,
#   REM_identifier <chr>, REM_length_quantity <chr>, REM_comment <chr>

isdparser documentation built on Feb. 18, 2020, 1:09 a.m.