Comments (9)
@sckott Thoughts on the best approach here? Do we want to add an extra slot for spatial classes? Have a function that just converts the object and returns a spatial object? Something I haven't thought of?
from spocc.
We do have some conversion in place already, see examples https://github.com/ropensci/spocc/blob/master/R/classes.r#L157-L167
Hmm. Don't know best answer, but IMHO it makes sense to just convert after getting the data back to other classes. I think always just have point data, not polygons or lines. So there are a few relevant sp
classes for point data, including SpatialPointsDataFrame
and SpatialPoints
.
I wonder if we can convert data to polygons or lines from points? Is that a common use case?
We should ask someone working on sp
, rgeos
, etc. about this
Or maybe @karthik or @cboettig have a good sense for what classes we want to be able to convert to from the data gathered in this package?
from spocc.
Let's wait on the class issue. As Scott says there is more to discuss on this.
from spocc.
Not a very common use case I'd think. So the basic idea would be to code a function that converts a spocc object to a spatial object. Seems like the low hanging fruit here.
from spocc.
Hi @spacedman - This package spocc
aims to be a general interface to species occurrence data on the web. Functions in spocc
gather data from different web APIs and output an S4
object. We want to build in conversions to objects that people are used to working with in the context of sp
, rgeos
, rgdal
, etc. packages. All data we get is point, so no lines or polygons.
We started doing some simple conversion to a SpatialPointsDataFrame
object (see https://github.com/ropensci/spocc/blob/master/R/classes.r#L151-L180). What else should we do? What are the common use cases that we should cover?
from spocc.
On 4 December 2013 23:49, Scott Chamberlain [email protected]:
Hi @spacedman https://github.com/spacedman - This package spocc aims to
be a general interface to species occurrence data on the web. Functions in
spocc gather data from different web APIs and output an S4 object. We
want to build in conversions to objects that people are used to working
with in the context of sp, rgeos, rgdal, etc. packages. All data we get
is point, so no lines or polygons.We started doing some simple conversion to a SpatialPointsDataFrameobject (see
https://github.com/ropensci/spocc/blob/master/R/classes.r#L151-L180).
What else should we do? What are the common use cases that we should cover
Just having a quick play there, and the example in the docstring doesn't
work:
dat <- occ(query='Accipiter striatus', from='gbif')
spdat <- as(dat, "SpatialPointsDataFrame")
Error in asMethod(object) :
no slot of name "data" for this object of class "occDat"
but I think its because the occ object has an @gbif slot that has the @DaTa
slot:
str(dat@gbif@data)
'data.frame': 20 obs. of 5 variables:
$ name : chr "Accipiter striatus Vieillot, 1808" "Accipiter striatus
Vieillot, 1808" "Accipiter striatus Vieillot, 1808" "Accipiter striatus
Vieillot, 1808" ...
$ key : num 7.73e+08 7.69e+08 7.73e+08 7.73e+08 7.73e+08 ...
maybe you've refactored this or I've got an old version of something
somewhere...
Anyway... something the code doesn't consider is the coordinate reference
system. I see you rely on getting latitude and longitude but there's
various standard lat-long systems that are broadly incompatible. The usual,
modern lat-long system is based on the WGS84 definition of the shape of the
earth, and a particular prime meridian and so on, and is known as EPSG
4326. You can specify that a spatial points data frame is using these
coordinates by doing:
proj4string(foo) = CRS("+init=epsg:4326")
Now some of your species data might be old, and using a different
coordinate system, and if you can't pull that definition from the database
then your coordinates will be a bit off. Possibly a km here and there
doesn't matter on a global scale (do your data sources have
uncertainty/precision measures in their metadata?) but its something you
want to get right if you can.
Barry
from spocc.
Hey @spacedman Sorry about the error. I have just fixed that and pushed in the most recent commit. There was some refactoring and I forgot to fix those as
functions.
Yes, the data is WGS84, see GBIF's docs here. Thanks for pointing this out, we'll fix right away.
Any other advice?
from spocc.
Nothing else to say at the moment! Glad to be of help.
Barry
On 5 December 2013 16:14, Scott Chamberlain [email protected]:
Hey @spacedman https://github.com/spacedman Sorry about the error. I
have just fixed that and pushed in the most recent commit. There was some
refactoring and I forgot to fix those as functions.Yes, the data is WGS84, see GBIF's docs herehttp://www.gbif.org/developer/occurrence#p_latitude.
Thanks for pointing this out, we'll fix right away.Anything other advice?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-29911185
.
from spocc.
Thanks for the help!
from spocc.
Related Issues (20)
- occ() not able to find GBIF records HOT 4
- bug in ecoengine bbox when bounding box passed
- use wellknown instead of wicket
- occ "gbif" search is not working HOT 2
- Add option to use GBIF downloads in addition to search HOT 2
- Add option to use auk for bulk ebird data
- drop ecoengine as an option: pkg archived on cran
- failing cran checks - due to vcr change most likely
- has_coords not functioning as expected HOT 1
- error with occ2df HOT 2
- occ2df with coordinate uncertainty and occurrence status HOT 4
- error with the limitation extractign data from OBIS HOT 4
- Add Cogent Server Status Messages
- always return latitude and longitude as numeric values HOT 1
- Resolving "non-zero exit status" HOT 1
- Citing GBIF data properly
- Search with occ does not match the inatopts HOT 2
- Remove rbison
- Change to new cran checks badge URL HOT 1
- submit new version to CRAN? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spocc.