Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script throws error at get bounding box #284

Closed
cmahony opened this issue Jun 14, 2024 · 4 comments
Closed

script throws error at get bounding box #284

cmahony opened this issue Jun 14, 2024 · 4 comments
Assignees
Labels
bug Something isn't working Urgent resolve asap user user-identified issues

Comments

@cmahony
Copy link
Collaborator

cmahony commented Jun 14, 2024

issue brought by Carlos Carroll:

Colin – Just starting to work with your script (revised version for the current climr) for the +2 degree simulated climate.
The csv I used for ClimateNA imports fine, and looks fine;

> head(xyz)
  id     lat      lon elev
1  1 82.8334 -63.6129  122
2  2 82.8288 -63.5567  156
3  3 82.8351 -63.7695   21
4  4 82.8304 -63.7132  129
5  5 82.8257 -63.6570  232
6  6 82.8210 -63.6008  287
But the script fails at the next stage:
## get bounding box based on input points
thebb <- get_bb(xyz)
Error in .check_bb(thebb) : 
  lon and lat are not in lat/long projection EPSG:4326

Could this be because my points are not a regular grid (ie equally spaced in lat/long?). This by design. The input csv does work in ClimateNA. Thanks!


So I can create a bounding box using

thebb <- c(max(xyz[, 2]), min(xyz[, 2]), max(xyz[, 3]), min(xyz[, 3]))
> thebb
[1]   83.1978   14.1351  -52.6277 -179.1419

But unfortunately, subsequent lines continue to check for EPSG:4326:

> delta <- input_gcms(dbCon, thebb, list_gcms()[3], list_ssps()[1], period = list_gcm_periods()[1])
Error in .check_bb(bbox) : 
  lon and lat are not in lat/long projection EPSG:4326

I can run the subsequent lines in the script (ie, input_gcms, input_refmap) if I comment out the check bounding box lines, but the resulting output is empty tiles (NA).

@cmahony cmahony added bug Something isn't working user user-identified issues Urgent resolve asap labels Jun 14, 2024
@cmahony cmahony self-assigned this Jun 14, 2024
@cmahony
Copy link
Collaborator Author

cmahony commented Jun 14, 2024

the problem is that some of the requested points are outside the limits specified in check_bb:

.check_bb <- function (bbox) {
  ## check projection
  minLon <- -179.0625 
  maxLon <- -51.5625
  minLat <- 14.375
  maxLat <- 83.125
  
  if (any((bbox[4] < minLon), (bbox[3] > maxLon),
      (bbox[2] < minLat), (bbox[1] > maxLat))) {
    stop("lon and lat are not in lat/long projection EPSG:4326")
  }
}
xyz <- fread("C:/Users/CMAHONY/Downloads/deminputgeog/deminputgeog.csv")[,-2] # CHANGE PATH
names(xyz) <- c("id", "lat", "lon", "elev")
s <-sample(1:dim(xyz)[1], 100000)
plot(xyz$lon[s], xyz$lat[s], pch=16, cex=0.2)
plot(ext(minLon, maxLon, minLat, maxLat), border="red", add=T)
> apply(xyz,2,min)
       id       lat       lon      elev 
   1.0000   14.1351 -179.1419  -82.0000 
> apply(xyz,2,max)
           id           lat           lon          elev 
21517591.0000       83.1978      -52.6277     5868.0000 

image

@cmahony
Copy link
Collaborator Author

cmahony commented Jun 14, 2024

closing this issue to start a new one for expanding the bounding box.

@cmahony cmahony closed this as completed Jun 14, 2024
@cmahony cmahony reopened this Jun 14, 2024
@cmahony
Copy link
Collaborator Author

cmahony commented Jun 14, 2024

i used google earth to find the precise limits of North american extent. southern border of Mexico is 14.53N, northern limit of arctic is 83.118N, Western extent of aleutian islands extends past -180E. so the only problem is that the western extent does exclude outlying aleutian islands.
recommend we see if we can expand the extent (if climr source data allows), or clarify the error message such as "lon and lat are not in lat/long projection EPSG:4326 or extent is outside ext(-179.0625, -51.5625, 14.375, 83.125)"

@cmahony
Copy link
Collaborator Author

cmahony commented Jun 14, 2024

closing. transfered issue to #285

@cmahony cmahony closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Urgent resolve asap user user-identified issues
Projects
None yet
Development

No branches or pull requests

1 participant