USEPA / elevatr

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

Wrong check on WGS84-based projected coordinate systems #79

Open lucarraro opened 1 year ago

lucarraro commented 1 year ago

In the CRAN version of this package, there seems to be a problem when prj identifies a WGS84-based UTM coordinate system. elevatr somehow expects a longitude value from -180 to 180, even if coordinates are projected and hence not given in degrees.

The following command fails (EPSG= 32632 stands for WGS 84 / UTM zone 32N):

get_elev_raster(data.frame(x=c(320000, 475000), y=c(5060000, 5180000)), prj = "EPSG:32632", z = 9)

The issue does not arise when ED50-based projections are used. The following command works (EPSG = 23032 stands for ED50 / UTM zone 32N):

get_elev_raster(data.frame(x = c(320000, 475000), y = c(5060000, 5180000)), prj = "EPSG:23032", z = 9)

The issue is apparently due to loc_check checking whether the crs string contains 4326 (in particular: grepl("\\b4326\\b", st_crs(prj_test))).

I noticed that this issue is fixed in the current GitHub version of the package. It would be great if you could also upload the CRAN version.

jhollist commented 1 year ago

@lucarraro Sorry for the delay in responding. I have a few fixes in the works and am hoping to push a CRAN version sometime in the next week or so. Stay tuned.