2
$\begingroup$

I am trying to download data from NOAA and I can't figure out how to construct a query to do it.

This URL points to a page that contains data for tides at six minute intervals between Jan 01 2021 and Feb 28 2021:

tidesandcurrents.noaa.gov/waterlevels.html?id=8443970&units=standard&bdate=20210101&edate=20210228&timezone=GMT&datum=MLLW&interval=6&action=data (link to the url)

If I ask for a wider range of data on that web page, the site refuses do serve the data.

I'd like to generate a sequence of queries to download the data in smaller chunks, but I can't figure out how to construct a query.

I've tried:

URLRead[URL["https://tidesandcurrents.noaa.gov/waterlevels.html"], 
 <|"Query" -> {"id" -> 8443970, "units" -> "standard", 
    "bdate" -> 20210101, "edate" -> 20210131, "timeszone" -> "GMT", 
    "datum" -> "MLLW", "interval" -> 6, "action" -> "data"}|>
 ]

and

URLDownload[
 URL["https://tidesandcurrents.noaa.gov/waterlevels.html"], 
 <|"Query" -> {"id" -> 8443970, "units" -> "standard", 
    "bdate" -> 20210101, "edate" -> 20210131, "timeszone" -> "GMT", 
    "datum" -> "MLLW", "interval" -> 6, "action" -> "data"}|>]

which both fail. Does anyone know how to do this?

$\endgroup$
0

1 Answer 1

4
$\begingroup$

Did you try the API at https://api.tidesandcurrents.noaa.gov/api/prod/ ?

Following request seems to work fine:

data = URLExecute[
   "https://api.tidesandcurrents.noaa.gov/api/prod/datagetter" 
   , { "product" -> "predictions"
     , "application" -> "NOS.COOPS.TAC.WL"
     , "begin_date" -> "20250101"
     , "end_date" -> "20250131" 
     , "datum" -> "MLLW"
     , "station" -> "8443970"
     , "time_zone" -> "GMT"
     , "units" -> "english"
     , "interval" -> 6
     , "format" -> "json"}
   , "RAWJson"] 

data["predictions"][[;; 5]]
(*
 {<|"t" -> "2025-01-01 00:00", "v" -> "0.857"|>
, <|"t" -> "2025-01-01 00:06", "v" -> "1.017"|>
, <|"t" -> "2025-01-01 00:12", "v" -> "1.183"|>
, <|"t" -> "2025-01-01 00:18", "v" -> "1.355"|>
, <|"t" -> "2025-01-01 00:24", "v" -> "1.532"|>}
*)
$\endgroup$
1
  • 1
    $\begingroup$ Thank you @vindobono $\endgroup$ Commented 6 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.