USEPA / elevatr

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

Some regions returning different resolutions on same request #31

Closed jhollist closed 2 years ago

jhollist commented 4 years ago

Reported by Adrien Foutelet (Thanks!)

Some areas appear to be reutrning rasters of different resolution on the same request. Need to track down reason why (source of different resolution???)

Example that recreates error:

## start of file
#
#
# Sets working directory
# setwd("")
#
# Creates bounding box
bounding_box<-data.frame(x=seq(from=33,to=45,length.out=2), 
                         y=seq(from=33, to=40, length.out=2))
#
# Specifies projection.
projection_specifications<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
#
# Use elevatr package to get elevation data for each point.
library(elevatr)
raster<-get_elev_raster(bounding_box,
                        prj=projection_specifications,
                        z=8,
                        src="aws",
                        clip="bbox")
#
# Saves the .tif raster
library(raster)
writeRaster(raster,
            filename=file.path("./elevation.tif")),
format="GTiff",
overwrite=TRUE)
#
## end of file
RonjaRaeningidottir commented 4 years ago

Same problem for me with a relatively small region. It gives the error message "Merging DEMs Error in compareRaster(x, extent = FALSE, rowcol = FALSE, orig = TRUE, : different resolution".

jhollist commented 4 years ago

@RonjaRaeningidottir Can you provide the bounding box for the region you are trying to access? Thanks!

RonjaRaeningidottir commented 4 years ago

Hei @jhollist , my input is:

RegionDEM <- get_elev_raster(RegionCrop, prj = prj_4326, z = 12, expand = 0.1, # extending by 0.2 degrees here clip = "bbox", verbose = T)

with

RegionCrop lon lat 44.11283 40.18608 44.11283 40.28358 44.17158 40.18608 44.17158 40.28358

Hope this helps, really like the package:)

jhollist commented 2 years ago

@RonjaRaeningidottir Sorry for the massive delay in responding, but I am finally getting around to going through old issues. I just tested your code and it seems to be working. I think this is now fixed and I am going to close the issue. If you are still having the same issue, let me know and we can reopen the issue.