Skip to content

elevation function returns error (randomly?) #148

@dlebauer

Description

@dlebauer

I am trying to extract elevation for different points around a boundary. I am sure there is a better way (e.g. using the raster package, and would love an example) but I think what I found may be a bug in the rgbif::elevation function:

If I try

library(ggplot2)
library(data.table)
library(rgbif)
d <- data.table(map_data("county"))
site <- d[region == "illinois"]
site[,elevation(latitude = lat, longitude = long)]

I get

Error in getdata(dat) : client error: (400) Bad Request

If I try this in a loop

  pts <- list()
  for(i in 1:nrow(site)){
    #elev[[i]] <- site[, GNgtopo30(lat = lat, lng = long)]
    pts[[i]] <- elevation(latitude = site$lat[i], longitude = site$long[i])
  }

I get the error

Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 1, 0

But every time I run the loop, it fails on a different value of i.

Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions