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.
Related
I have a triangle mesh and look for a way to get programmatically for a given (x,z) 2D point all y coordinates which are represented by the mesh (x,y1,z),(x,y2,z) ..., preferable in python. I have the mesh stored in one of the common file formats (.stl , .obj ...)
The problem behind this question is that i convert a 2D face image into a 3D mesh of the face (using the marvelous https://github.com/sicxu/Deep3DFaceRecon_pytorch project) and then want to map the depth information of the 3D model back to the 2d image (to build something fancy in blender ...)
I finally found a solution for the problem which is both slow and inelegant but does the job for me for now.
I use section_multiplane function of the trimesh python library for that. Basically i use this function to intersect the mesh with 2d planes parallel to the y,z-plane and calculate the depth values by analyzing the resultant 2D Path. The library is very fast in calculating the intersections but the part i wrote - extracting the depth information from the 2D Paths - is painfully slow right now. (which doesnt matter in my particular application)
The code for that I have now is deeply interwoven in my particular application so it doesn't make sense to share it but if someone is interested in this approach there is a very helpful example included in the trimesh library which covers the crucial points: section_multiplane example
I am sure there are much more elegant solutions for this problem available but I wanted to share this approach in case somebody struggles finding a better approach too ...
Heatmap displaying the extracted depth information:
depth info:
I have a pair of coordinates (lat, long).
I need to generate an image of displaying these coordinates on the map.
And then generate such images with other coordinates in the future without the Internet.
Please tell me whether there are solutions that allow you to display coordinates offline?
Upd: is there any opportunity to download maps offline , eg: gps tracker maps or something like that?
thank you
This is not possible while offline. To generate an image of the coordinate location you would most likely be using
os.system("open \"\" https://www.google.nl/maps/place/" + location)
and then generating a image of the location that is popped up. This is impossible to do while offline, I am very sorry.
The question is too broad to give a good answer. However:
There are several companies, such as TeleAtlas and NavTeq, that sell map data. I have no idea what buying the world from them at 1:1M resolution would cost, but I'd guess several thousand USD.
You could download data, or pre-rendered rasters, from Natural Earth. However, they don't have quite the resolution required for good 1:1M maps.
You could download data from OpenStreetMap. The data is free (as in beer, and as in speech), but using it is a major undertaking.
There are companies that offer pre-rendered maps in various formats from OpenStreetMap data. OpenMapTiles is the one I happen to have at the top of my head, but here are others.
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 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.
I have a large data set of tuples containing (time of event, latitude, longitude) that I need to visualize. I was hoping to generate a 'movie'-like xy-plot, but was wondering if anyone has a better idea or if there is an easy way to do this in Python?
Thanks in advance for the help,
--Leo
get matplotlib
The easiest option is matplotlib. Two particular solutions that might work for you are:
1) You can generate a series of plots, each a snapshot at a given time. These can either be displayed as a dynamic plot in matplotlib, where the axes stay the same and the data moves around; or you can save the series of plots to separate files and later combine them to make a movie (using a separate application). There a number of examples in the official examples for doing these things.
2) A simple scatter plot, where the colors of the circles changes with time might work well for your data. This is super easy. See this, for example, which produces this figure
alt text http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/ellipse_collection.hires.png
I'd try rpy. All the power of R, from within python.
http://rpy.sourceforge.net/
rpy is awesome.
Check out the CRAN library for animations,
http://cran.r-project.org/web/packages/animation/index.html
Of course, you have to learn a bit about R to do this, but if you're planning to do this kind of thing routinely in future it will be well worth your while to learn.
If you are interested in scientific plotting using Python then have a look at Mlab: http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/mlab.html
It allows you to plot 2d / 3d and animate your data and the quality of the charts is really high.
Enthought's Chaco is designed for interactive/updating plots. the api and such takes a little while to get use to, but once you're there it's a fantastic framework to work with.
I have had reasonable success with Python applications generating SVG with animation features embedded, but this was with a smaller set of elements than what you probably have. For example, if your data is about a seismic event, show a circle that shows up when the event happened and grows in size matching the magnitude of the event. A moving indicator over a timeline is really simple to add.
Kaleidoscope (Opera, others maybe, Safari not) shows lots of pieces moving around and I found inspirational. Lots of other good SVG tutorial content on the site too.
You might want to look at PyQwt. It's a plotting library which works with Qt/PyQt.
Several of the PyQwt examples (in the qt4examples directory) show how to create "moving" / dynamically changing plots -- look at CPUplot.py, MapDemo.py, DataDemo.py.