ropensci / unconf15

rOpenSci's San Francisco hackathon/unconf 2015
http://unconf.ropensci.org
36 stars 7 forks source link

Creating HTMLWidgets #5

Open jcheng5 opened 9 years ago

jcheng5 commented 9 years ago

@ramnathv, @jjallaire, and I will all be at the unconf and we are some of the authors of the htmlwidgets package. If you're not familiar with it, htmlwidgets makes it straightforward to adapt JavaScript visualizations to be easily used from the R console, R Markdown documents, and Shiny apps. The unconf would be a great opportunity for us to show people who are interested how to make their own htmlwidgets-based packages, and we can work together on them.

Have an idea for a widget? Please leave a comment!

sckott commented 9 years ago

@jcheng5 I'd be interested in getting a widget made to use within some of our packages that do spatial stuff for users to be able to select geographic areas (if its possible to capture user input) to then pass on to other functions to get data via web APIs (something I tried this time last year, but never got it done :cry:)

karthik commented 9 years ago

I'm glad you proposed this @jcheng5! I'm very interested in this, both from a q/a and demo perspective but also have a couple of visualization tools I'd like to build via htmlwidgets. I'll put some ideas together shortly.

Seconding @sckott that it would be great to have a general purpose toolkit that worked with leaflet so we could drag bounding boxes and passed that as input for searching the various biodiversity databases that we currently provide access to.

jcheng5 commented 9 years ago

User input on top of leaflet would be very possible, that seems like a really powerful use case.

lmullen commented 9 years ago

I'd be very interested in working on any spatial projects. One thought is to add time-based animation/scrubbing to leaflet or cartographer. (I'd also like to re-implement the functions in the classIntervals package in C++.)

srvanderplas commented 9 years ago

I'd be interested in adapting animint to work with this as well. It would be really sweet to be able to preview animint plots in RStudio's plot window.

jhollist commented 9 years ago

Anything spatial also catches my interest.

One comment on using leaflet or any of the web mercator based javascript libraries for spatial stuff. (FYI, I am a complete Noob wrt javascript) As @karthik suggets leaflet would be fine for grabbing samples within an extent, but if any thing else were to be asked with regards to the spatial arrangement another library (D3 supports projections, as I understand it) should be used because web mercator is really bad with measurements (e.g. area/length). So if a function were to be developed to get all points from gbif within 10km of a selected point, a web mercator based interface would not likely return the correct set.

Take a look at http://servicesbeta.esri.com/demos/compareMeasurements.html to see the issue.

In short, any spatially based use case needs to consider projections in the interface and the data with which the interface is interacting.

sckott commented 9 years ago

@jhollist Requiring GDAL/rgdal would be too heavy, but maybe the implementation could use d3.jsvia V8?

jcheng5 commented 9 years ago

@jhollist @sckott Would this be any help? https://github.com/kartena/Proj4Leaflet

karthik commented 9 years ago

@jcheng5 wow, looks great.

jhollist commented 9 years ago

@jcheng5 That looks perfect. Appears to use the same libraries (proj.4) used by GDAL.

It is possible this might not be an issue. It really depends on what lat-longs are returned. I am new to web mapping so take this for what it is worth, but the the leaflet tiles are web mercator. Locations from web mercator have been shown to be as much as 40km off! If coords are projected then that needs to be dealt with. That being said, the underlying opensteetmap data are in an unprojected geographic coordinates and those locations would be ok.

I think using the simple bounding box or even canned searches (e.g. by State or county) should suffice and don't get into the search by distance kinda thing which would avoid the possible measurement issues. Then it is just simply a matter of checking the accuracy of the locations you get with interacting with leaflet. You may find that I am getting all fired up for nothing...

jhollist commented 9 years ago

So, I might be getting fired up for nothing.

Used an example for leaflet to pop up location, grabbed GPS coords and they match. So, it appears it is the geographic coordinates that are returned with this example and not the projected Web Mercator coordinates.

bbest commented 9 years ago

The spatial bounding box selection via leaflet htmlwidget is similar in function to raster::drawExtent.

Would love to also see some simple interactive subset/selection options with htmlwidgets, a la Shiny light (but without requiring an R engine). For instance with the Ocean Health Index (OHI), we have many values registered to the same set of polygons. Could a drop-down select box enable choosing the given column in a data frame and leaflet updates the chloropleth visualization? I imagine this functionality would have broad appeal.

PS Wish I could be there in person, but @jules32 and @jafflerbach are representing our scientific group and I'll just occasionally chime in on issues.