USEPA / elevatr

An R package for accessing elevation data
Other
203 stars 26 forks source link

get_elev_point returns NA for (0,0) #25

Closed willgearty closed 5 years ago

willgearty commented 5 years ago

Running the following code:

get_elev_point(data.frame(long = 0, lat = 0), src = "aws", z = 7, prj = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")

returns NA for the elevation value:

Note: Elevation units are in meters 
Note:. The coordinate reference system is:
 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
class       : SpatialPointsDataFrame 
features    : 1 
extent      : 0, 0, 0, 0  (xmin, xmax, ymin, ymax)
crs         : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 
variables   : 2
names       : elevation, elev_units 
value       :        NA,     meters
jhollist commented 5 years ago

Thanks for this... Can confirm that I get the same result. Looking into a bit more it is related to latitude == 0, longitude == 0 works fine.

Let me dig in to see what the problem is. In the meantime, you could replace latitude of 0 with a very small value (eg. 0.00001). Or a better solution with the 0,0 is to use a small value for the expand argument. This appears to be an issue with how I am selecting the tiles. It only gets a single tile and the point is right on the edge of that tile.

And some fun things I learned.

jhollist commented 5 years ago

Got it fixed now. It now checks for long/lat and lat == 0. If that is the case, expands the bounding box (doesn't alter the point location) by a hair to capture more tiles. You'll need to install from master here:

devtools::install_github("jhollister/elevatr")

I've got a few other things in the works and should hopefully have a push to CRAN in the next month or so.

Thanks for using the package and thanks for the bug report!

willgearty commented 5 years ago

Perfect, thanks for the super quick turnaround!

jhollist commented 5 years ago

No problem. You got lucky! I've been working on another elevatr issue so it was fresh in my mind!

Thanks again for the bug report. I am going to take a look at the other one you submitted as well.

On Tue, May 14, 2019 at 1:01 PM Will Gearty notifications@github.com wrote:

Perfect, thanks for the super quick turnaround!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jhollist/elevatr/issues/25?email_source=notifications&email_token=ABJPYS3YRPRDFZPLLBWLAC3PVLV7XA5CNFSM4HMUO33KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVMECZI#issuecomment-492323173, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJPYS4YCR27R3MBTVGFPODPVLV7XANCNFSM4HMUO33A .

-- Jeffrey W. Hollister email: jeff.w.hollister@gmail.com cell: 401 556 4087 https://jwhollister.com