Leaflet.Editable for Shiny? - r

I'm trying to get to grips with Leaflet in Shiny for R. I'm happy with handling the display capability. My main aim is for the user to be able to interact with the user interface to be able to add their own points and polygons and to edit geographies and their attributes when they need to, too. The layers will be pre-existing in most cases.
The extension Leaflet.Editable does everything I need it to do from what I can see, but unless I am mistaken does not (yet?) appear to be implemented in the Leaflet for R library. Leaflet.Draw which is included in leaflet.extras for R appears to be an alternative.
My question is:
is there an implementation of Leaflet.Editable that I've simply missed?
If there isn't, what do people recommend for drawing / editing points and polygons, including editing attributes?

Related

What is the best way to make a collection of SVG symbols into R

I have an R package that makes technical schematics for geology purposes (StratigrapheR on https://cran.r-project.org/web/packages/StratigrapheR/index.html). The idea is to automate the generation of specific graphics as the one below (modified from Humblet and Boulvain 2000 for reference).
It needs a lot of symbols that I would like the user to easily find and use into R. My basic idea is to import SVG files into different "collections", ideally making these collections open-source, and allowing easy access via GitHub repositories or R packages. But also, each user should be able to make their own symbology easily accessible, or propose their own collection online.
What would be the best way to make collections of SVG available into R while allowing other users to add their own collections ?

Is there any method for fix manually an Alloy Analyzer graph?

I need to fix my Alloy graph, for example I have this output:
I can't move "node2" rectangle over the row of "node0" and "node1", and I can't move "node1" under "node2" whitout also move "node0". Is there any solution? Thank you.
PS: I am using Alloy Analyzer 4.2 under Windows.
PPS: This is only an example, i get a big graph with 5 or 6 rows of 20-25 rectangles, and if I can't fix it manually, it's only a mess.
To answer the direct question: I for one have never found a way to make the visualizer change its mind about which nodes should be on the same horizontal level. (That doesn't quite mean it's not possible, but it does mean that if it's possible it's not immediately obvious how to do it. But I guess you knew that already.)
If your goal is to make the auto-generated diagrams easier to read, the simplest approach is to experiment with adjustments to the visualizer theme. The "Magic Layout" button can be helpful; manual adjustments to hide some nodes or display some relations as labels rather than arcs can help with diagrams which are otherwise too cluttered.
If your goal is to make a 'good' version of a diagram for inclusion on a slide for a talk or a figure for a paper, you may want to export to Dot and import into a graph-drawing tool that gives you the kind of manual control you want (or edit the .dot file yourself, if you are familiar with graphviz and can make it do what you want), or export to XML and generate the graph description language of your choice from the XML.
I hope this helps.
The Lightning tool is an Ecplise plugin relying on Alloy4.2 to formally define Domain Specific Languages and might be a solution to your problem.
It's still under development, but if you are only interested in being able to freely reorganize each atom and label of generated instances, there shouldn't be any problems, as it uses Ecplise draw2D to render those latter.
If now you're really interested in providing an intuitive visualization to your generated instance (by intuitive I mean a visualization that is closer to its domain rather than the structure of your model), then you can define your own language (with your model as abstract syntax ) and define a concrete syntax for it.
The update site to be used for the installation of the tool is : http://lightning.gforge.uni.lu/update-site
Don't hesitate to contact me if you plan to give it a shot and get any issues.
(I'm eager of constructive feedbacks ;-) )
The steps to follow to generate a graphical instance in which any components can be moved are :
Install Lightning
Create a new Lightning Project
Create a new Language in this project
Put your model in the ASM folder
generate instances of the language by "running the project"

Using Cytoscape.js for network visualization in Shiny

I am working on a web project for network visualization. I am writing my code in R using Shiny. And I want to display my graph using Cytoscape.js
I've searched the web for some kind of source code doing this. But I couldn't find anything. The webpage of Cytoscape.js is not enough for me cause I am not expert in js and can't use the examples.
Briefly, I have Adjacency matrix of my graph and want to use it with cytoscpae.js. Do you know any source code or a tutorial of the steps I should go through?
Cytoscape.js supports JSON for input, so as long as your R/Shiny code can produce that, you should be able to use Cytoscape.js. Here's the format described: http://cytoscape.github.io/cytoscape.js/#notation/elements-json
It looks like Shiny has a predefined set of widgets it supports, so there are a few options here:
(1) Shiny adds support for Cytoscape.js (e.g. https://github.com/cytoscape/r-cytoscape.js),
(2) A Cytoscape.js plugin is written for Shiny.
(3) You use JS for at least part of your app.
(1) and (2) will take more time than (3), so depending on your requirements, you may have to bite the bullet and use normal JS. When using a framework like R/Shiny without your own JS, you'll always be locked into whatever's supported and miss whatever's not -- so you lose on flexibility.
For very flexible and general interaction between R and Cytoscape.js, see the RCyjs project (docs)

Where to start with map application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
i'm trying to desing a new application which allow user see he/her current location on a custom map (office, university compus, etc). but actually i have a couple of question in my mind (i haven't designed this kind of application before). i'm wondering:
How can i draw my own maps, what is the best option for it? there any format that i have to care of, there are any specification about it ?
Once i have my custom map. how can i do to mapping a global position system with the local positions ?
What are the tricks behing zoom on maps ? just differents layers with more or less informations and those layers changes on users demand ?
If a whant to mark some specific points over the map, like a cafeteria, boss's office etc, how can i do that ?
Sorry if my questions are too much generics and dumb, but i really need some clues about this topic because i don't have any idea how to design this kind of application as best as possible. and we don't whant to reinvent the wheel.
I will appreciate any help that you can provide me in order to desing this application
There are a number of approaches you can take to creating a maps application. Which one you use depends on the set of features you want to support, and the degree of control you want to maintain over the product.
If you want something like an embedded google map, then clearly the JavaScript Google Maps API may be best solution. If you need to support further features from the server side, like directions, you can make use of the web services api:
http://code.google.com/apis/maps/documentation/webservices/index.html
If, on the other hand, you essentially need a zoomable map of an area that you can define with markers and borders drawn from your database, and you want complete custom control over this image without having to rely on Google Maps' data or branding, then you can fairly easily build a scalable image either on the client or server, or both.
To start, you will need a set of point coordinates from which to draw your map. These can be derived from the SVG generated by a program like Adobe Illustrator when you draw vector graphics. Thus you could draw your own map in Illustrator and use the generated svg to create your map. In this case you will have to read about SVG and understand how to use it. Raphael.js is an excellent library that offers cross-browser compatible handling of SVG. If your map is of a familiar region, such as a country, you may be able to find SVG coordinates for it already on the web. You could start by grabbing a subset of the data in this file on wikipedia for the country or region you want to map.
Once you have a set of coordinates that define your map areas, you can keep them in a config file that can be read into memory from disk by your application as needed. It's convenient to save this data in the form of a hash, where each set of key-value pairs stores a separate svg 'path', or set of point coordinates that forms a closed shape. These could represent, for instance, the counties in a state.
Once you have the appropriate 'paths' stored in this manner, it is relatively easy to write a wide variety of software implementations.
Check out the imagemagick convert
documentation for the -draw
option for an example of how to
draw a png, jpeg, or gif on your
server from your stored svg paths.
Adam Hooper has some brilliant ideas of what to do with a custom map using SVG on the client side:
http://adamhooper.com/eng/articles/9
Note that you do not necessarily
need to use SVG. Here's an
example of a map drawn on the
server using ImageMagick, with a
highlightable clickmap drawn over it
by the browser, where the
highlighting is handled by the
jquery maphighlight plugin, which
uses the canvas element where it is
supported and VML in its place on
Internet Explorer browsers. All of
these layers (ImageMagick,
client-side click-map, and
client-side javascript highlighting)
are built with straight lines drawn
between point coordinates, so none
of this is actually SVG, and may be
easier to understand. Have a look
at the page source to see how the
click map is drawn, then look at the
maphighlight plugin to understand
what's going on:
http://davidlynch.org/js/maphilight/docs/
A third option, if you need to support more google-maps-like features, but want to add your own map data without using an overlay, is to implement some application of Open Street Maps. If you go to openstreetmap.org, find the area you want to customize, and click the edit tab at the top, you can edit the map as needed for your area. This edits the map data for all users of the Open Street Map service. Then you can get the openlayers javascript from http://openlayers.org/ to render a map on your website from Open Street Maps data that you can freely edit yourself. Also see the OpenStreetMap Wiki that tells you more about the OpenStreetMap movement.
If you don't want to reinvent the wheel, then don't try do do it: take the Google Maps API, add some markers and you're done. Zooming included. They have examples to guide you and there's loads of knowledge about the usage.
All you need is a free API key.
Edit: Your comment in the original question indicates that you want to use a custom overlay over existing maps. That's also possible as this example shows (see docs for custom overlays).
In the effort to not reinvent the wheel (which is definitely a good idea), much of the work of the maps themselves has already been done. The simplest approach will be to integrate Google Maps into your application. To address your individual points:
You don't have to draw your own maps. Tons of them already exist. Unless you're asking about drawing maps of indoor facilities yourself and plotting on those? In which case, how do you plan to approach this from a hardware perspective? GPS won't work well.
You need a piece of hardware that supplies the GPS coordinates. From there, you can just call the API to plot it.
Already done.
Calls to the API. Just provide the location (address, GPS, whatever you have) to the API. GPS will be more accurate, of course. But I'm pretty sure there's a geolocation service as part of the API and you can store the coordinates locally and adjust them manually if they're inaccurate.
If I'm off-base from your actual idea here, let me know. "Maps" is, of course, vague.

Does anyone know how to create a interactive graphs using flare or other visualisation classes?

Does anyone know of software or flex/flash/as3 source or visualisation software that could be used to make interactive graphs, where the user would enter a query that would pull data from a MySQL database and the user would build a sunburst or icicle graph by dragging and dropping items into a tree-like structure and they would be able to view the graph? i have attempted to use flare but my programming skills are pretty bad. So far from what i gather, flare only allows the graphing of defined datasets rather than allowing a user to modify the dataset and thus creating a new dataset.
Help?
This is far too big for the scope of a single question. You're going to need to write at least a few different pieces.
1.) Access to the database and a way to view datasets
2.) Control handlers to drag and drop datasets onto your chart object
3.) A chart object that can handle receiving dropped dataset items and render itself accordingly.
There are lots of good charting frameworks out there including Flare, Axiis, Flex charting, Fusion Charts, iLog Elixir. I'm not sure what you're trying to do but any one of those should be able to serve as your charting piece.
We worked on a project that used Flare and Flex. We had to provide the data to Flare in an XML format called GraphML, so we had code to convert the data into the required format in our C# backend, and then we passed it to Flex. There were naff all tutorials for it though, so took some time to figure it out.
There is a properly cool graphing tool (although its commercial) called Kapit. Check out their Diagrammer and Visualizer demos. It could be the case that its worth the spend.
But I agree with Mr Owen, theres some mad scope in that question:)

Resources