I would like to build a django webapp. One part of this should allow the user to interactively select geographic areas from a map. The map should come from openstreetmap, and the user should be able to do different kinds of selections:
freehand
rectangles
circles
For further processing, the selected area needs to be converted into a shapefile / OGR geometry.
Probably there are already solutions for the individual steps, and I'll have to integrate those. So my question is:
What's the best way to display a OSM map in my django app?
How do I select the regions?
How can I convert the selection to an OGR geometry?
Note: If I should make this into seperate questions, let me know!
I think you should rather asked this question on the SE GIS site because it is rather about web mapping techniques than django.
Concerning your questions I advice you to have a look at leaflet, a js library that makes map and geometry integration very easy. I both use them in my django projects. For geometry creation you need a add-on called leaflet draw. I haven't used it yet but it looks very promising.
To create shapefiles I often use leaflet it in combination with a pure python package called pyshp.
I hope this helps to get you started.
Related
I am looking for a software package, or even better, a python package that allows me to draw objects by inputing parameters, for example: I want a circle at position x,y, radius r, thickness t, color c and then look at it at different angles.
I know that I could use stuff like blender, but I feel that this is overkill and it would take a long time to learn it sufficiently.
I just need this to do some ncie looking plots in my thesis.
thx.
I would recommend OpenSCad. It is a software to create 3D objects by writing code. Although it isn't a python package, it is quite lightweight, has a nice view and the commands are really easy to learn - take a look at their Cheat Sheet. The projects can be shared as text files or exported in various 3D formats, to get a prettier view from other software.
And I you want to do the same but stick with Python you can combine OpenSCAD with SolidPython.
I'm writing a web interface for a database of genes values of some experiments with CGI in Python and I want to draw a graph for the data queried. I'm using matplotlib.pyplot, draw a graph, save it, and perform it on the web page. But usually there are many experiments queried hence there are a lot of values. Sometimes I want to know which experiment does one value belong to because it's a big value, whereas it's hard to identify because the picture is small in size. The names of the experiments are long strings so that it will mess the x axis if I put all the experiment names on the x axis.
So I wonder if there is a way to draw a graph that can interact with users, i.e. if I point my mouse to some part on the graph, there would be one small window appears and tells me the exact value and what is the experiment name here. And the most important is, I can use this function when I put the graph on the web page.
Thank you.
What you want is basically D3.js rendering of your plots. As far as I know, there are currently three great ways of achieving this, all under rapid development:
MPLD3 for creating graphs with Matplotlib and serving them as interactive web graphics (see examples in Jake's blog post).
Plotly where you can either generate the plots directly via Plotly or from Matplotlib figures (e.g. using matplotlylib) and have them served by Plotly.
Bokeh if you do not mind moving away from Matplotlib.
I am trying to depict the relationship of different data entities with my ETL (extraction transformation loading) pipeline. The final output is a large directed graph. So far I am using Python to extract data relationship. Pydot helps me generate svg file which I can open up using a browser. The graph that I generate is static.
Pydot lets me setup tooltip and allows me to link other html pages with nodes or edges. I am looking for more than that.
A small portion of the graph is shown below
I want to do several things with this graph.
Every node can have several attributes (including name). It is not possible for me to display those attributes because of paucity of space. But as users mouse over (or do other mouse based action) I would like those attributes to show up as "floating" table which user can dismiss if not interested.
Not all node attributes are integer or strings. It can be graphs as well. For example for one of the nodes I may have a bar chart showing how often this data entity is getting loaded in last 7 days. I would like that bar chart to float over as the user moves (clicks) mouse over that node. Currently I am using matplotlib to generate bar / pie charts associated (please see above) with nodes. I link those diagrams with my original directed graph using setURL in pydot. But the user experience is not great since it takes user over to a new page.
I am happy with node layout etc that I get by default from Pydot/GraphViz. I prefer not to do everything from ground up unless it is absolutely necessary.
Ability to highlight only certain part of the graph based on query in node or edge attributes
I read this forum and came across several options in response to questions similar to mine.
gephi
igraph (I played around with igraph which lets me query by vertex
or edge. I couldn't figure out how I can make my final graph
interactive based on user input e.g. floating table on mouse over of
a node etc)
Javascript libraries - sigma.js, arbor.js, d3.js nodebox
networkX
nodebox
I have Python skill but quite novice on Javascript side. I would like to know from experts what can be my best bet (from functionality and ease of use point of view). A browser based solution is preferred.
Any suggestion / help will be really appreciated.
Thanks
Abhijit
Try NetworkX. Node attributes can be anything hashable, so that addresses (at least) your first two bullets.
You will still be using matplotlib to generate the charts. I don't know of a better solution than that.
What I want to do is to generate a static image (e.g. a png) using python and using openstreetmap tiles as a background.
Mathplotlib and Basemap is almost what I'm looking for. The problem is being able to use OSM tiles as background. I'm not pleased by the approach suggested in http://stevendkay.wordpress.com/2010/02/24/plotting-points-on-an-openstreetmap-export/
The closest I found is in this answer but using R, and not python Plotting points from a data.frame using OpenStreetMap
Did I miss any obvious and easy solution?
Thanks for your help
EDITÂ : this questions suggests many tools, but none seems to match my needs How can I display OSM tiles using Python?
You overlooked the "Export" tab at the OSM website, which is capable of generating a static image with the dimensions and map extents you want. Have a look at http://wiki.openstreetmap.org/wiki/Export
Please be advised that generating static images is a resource-intensive process, and the OSM sysadmins will frown upon you if you do a large number of requests or abuse this feature. Unfortunately this means you'll have to find another solution if you're trying to do lots of images.
By the way, the data you're plotting on top is properly projected into EPSG:3857 and not just raw lat/lon coordinates, right? Raw lat/lon data will look distorted at large zoom levels.
I have some GPS position recordings, which I want to draw into a map (e.g. OpenStreetMap) and save this as an image file.
I'm using python. I've found osm-gps-map as a candidate library to do the visualization, but apparantly the API lacks some functionality to satisfy all of my needs. What I need is a library that does:
draw stuff into a map (e.g. an OSM-based map), i.e. a list of GPS positions.
automatically adjust view (scale/position) to fit in all drawn positions
save this view to an image file
I seriously want to avoid being forced to manually make a screenshot from a widget or a browser window. And if possible I also want to avoid to implement the necessary projection functionality by myself (as in here). Does anyone know a library/toolchain that provides the desired functionality (if possible for use by Python)?
You may want to consider using Basemap for matplotlib. Here is a blog post describing how to use this package with OSM.
There are examples of how to draw custom GPS points on top of OSM background map using Matplotlib Basemap, Matplotlib or Cairo in GeoTiler project: https://github.com/wrobell/geotiler/tree/master/examples.