USEPA / EPATADA

This R package can be used to compile and evaluate Water Quality Portal (WQP) data for samples collected from surface water monitoring sites on streams and lakes. It can be used to create applications that support water quality programs and help states, tribes, and other stakeholders efficiently analyze the data.
https://usepa.github.io/EPATADA/
Creative Commons Zero v1.0 Universal
40 stars 18 forks source link

Ongoing discussion: pros/cons of original vs. TADA lat/lon fields #439

Open cristinamullin opened 6 months ago

cristinamullin commented 6 months ago

There should be both lines and polygons, but only polygons are successfully included in the output.

Sometimes when I run the above example (or other similar ones) in fetchATTAINS, I will get an error message with a URL. At the URL, the final lines visible indicate: "exceededTransferLimit": true. image

This is an example of a data set where I saw those issues:

test1 <- TADA_DataRetrieval(startDate = "2018-05-01",
endDate = "2018-09-30",
statecode = "IL",
applyautoclean = TRUE)
hillarymarler commented 6 months ago

I've been spending some time this morning looking at the IL example Cristina included above as well as some other examples. I am still seeing similar issues on some data sets.

Here is another example which does the same thing when I run TADA_GetATTAINS().

test <- TADA_DataRetrieval(startDate = "2018-05-01", endDate = "2018-09-30", statecode = "TN", applyautoclean = TRUE)

[1] "Your TADA data covers a large spatial range. The ATTAINS pull may take a while." Warning message: In readLines(con) : incomplete final line found on 'https://gispub.epa.gov/arcgis/rest/services/OW/ATTAINS_Assessment/MapServer/3/query?&geometry=-90.1783%2c%2035.00305%2c%20-81.7235%2c%2036.623877&inSR=4326&resultRecordCount=2000&resultOffset=8000&spatialRel=esriSpatialRelIntersects&f=geojson&outFields=*&geometryType=esriGeometryEnvelope&returnGeometry=true&returnTrueCurves=false&returnIdsOnly=false&returnCountOnly=false&returnZ=false&returnM=false&returnDistinctValues=false&returnExtentOnly=false&featureEncoding=esriDefault'

If you follow the link and scroll to the bottom of the page, the final line indicates transfer limit was exceeded. I am still not sure why I am the only one experiencing this issue. I'm currently updating a bunch of packages (though none seem directly relevant to the TADA/ATTAINS functions).

Any suggestions of other things I should try? Or additional information I can provide that would be helpful?

kathryn-willi commented 6 months ago

Thank you for the clarification, this was helpful! It is my understanding that exceededTransferLimit: true means that there are so many features within a query that you cannot pull them all at once. To get around this, we use repeat to pull across a moving window of features (moving window of 2000, which I believe is the limit for ATTAINS' API). Therefore, I don't think this is a bug in the code... unless I'm misinterpreting something?

Here is the definition of "exceededTransferLimit" from the developer site:

The exceededTransferLimit property is now included in the JSON response when paging through a query result with the resultOffset and resultRecordCount parameters. When exceededTransferLimit is true, it indicates there are more query results and you can continue to page through the results. When exceededTransferLimit is false, it indicates that you have reached the end of the query results.

In the original PR, you also mentioned that sometimes a TADA_GetATTAINS() pull was not exporting all the ATTAINS data; instead it was only generating polygons, when it should be generating both lines and polygons. Have you been able to reproduce this issue again? We have yet to encounter this issue on our end, so it's still got us stumped!

This is the example you provided: test1 <- TADA_DataRetrieval(startDate = "2018-05-01", endDate = "2018-09-30", statecode = "IL", applyautoclean = TRUE)