Coder Social home page Coder Social logo

fozy81 / nbn4r Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 3.0 12.1 MB

This is a project to enable the R community to access data and resources hosted at National Biodiversity Network (NBN) Atlas. The goal is to enable outputs (e.g., observations of species) to be queried and output in standard formats.

R 100.00%

nbn4r's Issues

Problem installing in R 3.6

Really useful package, but since upgrading to R 3.6 (Windows 10) I'm getting the following error on the install_github("fozy81/NBN4R"). The error states there is no RCurl package, but this is already installed and loaded.

installing source package 'NBN4R' ...
using staged installation
R
byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called 'RCurl'
Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package 'NBN4R'
removing 'C:/Users/nras/R/win-library/3.6/NBN4R'
Error: Failed to install 'NBN4R' from GitHub

Circular buffer when using specieslist()

Hello,

I'm trying to query the NBN database using specieslist() for polygons of various shapes/areas. I have no problems when calculating species richness when using rectangular buffers. When I attempt to use a circular buffer, however, I receive a HTTP 414 error.

After a bit of research, I think this error might be caused by the length of the polygon string that I'm sending to NBN using specieslist(). For example, a simple rectangle can be defined like this:

library(NBN4R)
ext_rectangle<-"POLYGON ((-1.378784 52.09807, -1.378784 52.25807, -1.172791 52.25807, -1.172791 52.09807, -1.378784 52.09807))"
 rectangle_test<-specieslist(wkt = ext_rectangle) 

A small 2km circular buffer around a point, however, has a much longer polygon string (please excuse the inelegant code!):

library(NBN4R)
library(sf)
library(raster)

coords<-as.numeric(c("-0.406494", "51.998410"))
pt <- SpatialPointsDataFrame(data.frame(coords[1], coords[2]), data = data.frame('Pt1'), proj4string = CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
poly<-st_as_sf(buffer(pt, width = 2000)) # Puts 2km circular buffer around point
ext_circular<-st_as_text(poly$geometry) # Creates a WKT string for specieslist() function
circle_test<-specieslist(wkt = ext_circular)

Error in check_status_code(status_code, on_redirect = on_redirect, on_client_error = on_client_error,  : 
  HTTP status code 414 received.
  Either there was an error with your request or in the NBN4R package, or the servers are down. If this problem persists please notify the NBN4R maintainers by lodging an issue at NBN4R github repo or emailing [email protected]
In addition: Warning messages:
1: In cached_get(url = this_url, type = "filename") :
  URL length may be longer than is allowed by the server
2: In download_to_file(url, outfile = this_outfile, binary_file = identical(type,  :
  URL length may be longer than is allowed by the server

If you inspect the objects ext_rectangle and ext_circular you'll notice the extreme difference in length, ostensibly because it takes more information to define a circle than it does a rectangle. I think that trying to pass a string as long as ext_circular using the specieslist() function is causing the HTTP 414 error.

My question, therefore, is whether there is an easier way of defining a circular buffer around a point, which I can convert to WKT so that specieslist() can function? Is this possible?

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.