Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DownloadStationsByState(string[] stateCodes, string localFilePath, StationFields stationFields = null)
- {
- this.localFilePath = localFilePath;
- DownloadedStations = new List<Station>();
- List<string> columnNames = stationFields == null ? StationFields.DefaultStationFields : stationFields;
- string url =
- "http://nwis.waterdata.usgs.gov/nwis/peak?" +
- string.Join("&", stateCodes.Select(stateCode => "state_cd=" + stateCode).ToArray()) + // e.g. state_cd=va&state_cd=wa
- "&coordinate_format=decimal_degrees" +
- "&sort_key=site_no&group_key=NONE&format=sitefile_output" +
- "&sitefile_output_format=rdb" + // rdb = plain text in CSV
- // Column names
- string.Concat(columnNames.Select(field => "&column_name=" + field).ToArray()) +
- "&set_logscale_y=1&date_format=YYYY-MM-DD&rdb_compression=file&hn2_compression=file" +
- "&list_of_search_criteria=lat_long_bounding_box";
- DownloadStations(url, localFilePath);
- }
- private void DownloadStations(string url, string localFilePath)
- {
- webClient = new WebClient();
- webClient.DownloadFileCompleted -= WebClientOnStationDownloadCompleted;
- webClient.DownloadFileCompleted += WebClientOnStationDownloadCompleted;
- IsWebClientCancelled = false;
- IsWebClientBusy = true;
- webClient.DownloadFileAsync(new Uri(url), localFilePath);
- }
Add Comment
Please, Sign In to add comment