Rafnuss / GeoPressureR

Global positioning by atmospheric pressure
https://raphaelnussbaumer.com/GeoPressureR
GNU General Public License v3.0
7 stars 1 forks source link

`geopressure_ts` error for location over water #11

Closed Rafnuss closed 2 years ago

Rafnuss commented 2 years ago

Problem If the lat,lon requested in geopressure_ts() is over water, GeoPresseAPI returns an empty csv. Currently the error message warns the user of this issue with a link to google map to copy paste. For instance:

> Returned csv file is empty. Check that the time range is none-empty and that the location is not on water: maps.google.com/maps?q=0,0

This problem appear when we query the most likely map of pressure returned by geopressure_map() and geopressure_map2path()

Solution 1 On GeoPressureAPI, we could accept location near water and move them to the closest shore, ideally return a warning message. @mgravey , is that possible? what could be done without reducing computational efficiency?

Solution 2 Check before making the query in R. This would require to use another package, download external data (ERA5-Land is 50MB) otherwise the code below get land polygon for 2MB

 sf::sf_use_s2(FALSE)
 pts <- st_as_sf(path, coords = c("lon","lat"), crs = st_crs(4326))
 # poly <- ne_countries(returnclass="sf")
 poly <- ne_download(category = "physical", type="land", returnclass="sf")
 a <- st_join(pts, poly, join = st_intersects)