-
Install R from https://cran.r-project.org/
-
Install git from https://git-scm.com/ or copy code from below in your own project.
git clone https://gist.github.com/124f49a421ad5197b5ba6a9f45c8bc18.git rExample
cd rExample
-
Install R packages called from the script in question.
-
Run:
Rscript basic_example.R
Sends a simple request to /api/data/flat/ to demonstrate how to get data for a single stream segment.
This is a somewhat extreme example of chunked query that will return way more than 20 million records. It is for demonstrating the principle. However, for practical reasons you will reduce the return size further e.g by using projections or do analysis with a subset of the data and aggregate the intermediate results in a map-reduce fashion.
After downloading and concatenating all the hundreds requests you need to dedup the dataset since river segments may touch more than one segment. Looping through small watersheds instead of just squares would be a remedy.