10 ms·
So You'd Like to Make a Map using Python
Use Pandas, Matplotlib, and Basemap to extract, clean and re-arrange data, before creating a series of thematic maps.
- pacofvf 13y agoIn our company we use python to make maps, but we go with the traditional GIS approach, dependencies?: postgis and mapnik. The first two examples would be solved by a single postgis query, the last one maybe would require some extra work. But nice work anyway, bookmarked.
- jofer 13y agoSurprised to see that they're using basemap instead of cartopy. There's nothing wrong with using basemap, but it can be a bit clunky, i.m.o. Then again, cartopy is only a year or two old, so it doesn't have the traction that basemap does. It's gained a fairly large following very quickly, though.
- urschrei 13y agoDoing the same thing using Cartopy is next on my list!
- Demiurge 13y agoCool article, explains how you can do anything using Python, although doesn't mention Mapnik. However, for most people, these days I would recommend to try TileMill (https://www.mapbox.com/tilemill/ https://www.mapbox.com/tilemill/) to make a map. The CartoCSS can let you style anything based on attributes and it also lets you add and style raster data.
- LeafStorm 13y agoCan you draw brightly colored lines on roads for a bus map? I like to mess around analyzing bus routes, but so far I haven't been able to find a computer-based tool for drawing them effectively.
- Demiurge 13y agoI would probably draw in QuantumGIS and export as shapefile. There are many many ways to draw or otherwise generate spatial data. I think it depends on what you mean by 'effectively'? Edit: Ok, I just re-thought your comment, and perhaps you mean to 'highlight' the existing road paths if they are also bus-routes. That would be trivial if your roads lines have attribute "bus_route". You can also add the attribute, then in QGIS you can select such paths, edit them and set the attribute as 'true', in TileMill you would then add a style to change color for lines with such attribute. Also, if the streets have names and you have a list of such streets, you can do a CartoCSS selection based on the street names attribute.
- maxerickson 13y agoTilemill ingests geographic/spatial data, it doesn't have much provision for interacting with it. You might find that someone has already drawn the bus routes you are interested in: http://wiki.openstreetmap.org/wiki/Buses http://wiki.openstreetmap.org/wiki/Buses (Then you just have the task of pulling the data out of OSM and translating it into a format that you can work with)
- Demiurge 13y agoAlso, I just realized, if the bus routes are not in the OSM, he could use the new iD editor and add the bus routes to OSM under his account, and then export :)
- roel_v 13y agoThis is trivial - assign a value to an attribute for all segments that are part of a bus route, then style accordingly (preferably in a gis, the approach in the op is a cumbersome roundabout way)
- hnha 13y agobe aware though that it is tile based and that comes with a price. for example you cannot have huge labels. also the dependency on many node.js packages can be annoying.
- Caged 13y agoYou can generate images from TileMill. https://dl.dropboxusercontent.com/u/602885/hot-pink.png https://dl.dropboxusercontent.com/u/602885/hot-pink.png
- bennyg 13y agoThat looks pretty interesting. I'll have to show my dad this stuff - he's a cartographer that specializes in Adobe Illustrator and makes large print maps. He's been looking at easy ways to transition to the web while maintaining high visual customization.
- pagekicker 13y agoWhat are blue plaques?
- acheron 13y agoHistorical markers: "on this spot in 18xx something happened" kind of thing. https://en.wikipedia.org/wiki/Blue_plaque https://en.wikipedia.org/wiki/Blue_plaque
- urschrei 13y agohttp://en.wikipedia.org/wiki/Blue_plaque http://en.wikipedia.org/wiki/Blue_plaque
- alan_cx 13y agoAny Amercians think it was some hideous British dental condition? ;)
- dannypgh 13y agoCartography? Hasn't everything already sort of been discovered, though by, like, Magellan and Cortés?
- mapmeld 13y agoIn modern parlance, cartography is more about information design. For example, what features appear at what zoom level on Google Maps? What color is an interstate?
- sp332 13y agoCartography is about making maps, not discoveries.
- bennyg 13y agoExcept for figuring out about Pangaea and continental drift.
- jofer 13y agoThat has nothing to do with cartography. That's geology. Geology often uses cartography to display data and various spatial analysis methods to analyze data, but what you're describing is purely geology. Sorry if I sound snippy... But as a geologist, we get a bit annoyed when one of the major discoveries of our field is attributed to "those darn geographers"! :)
- herge 13y agoMan, you can't get no respect for Arrested Development on HN.
- pwang 13y agoI think the blue parts are plaques...
- jaegerpicker 13y agoVery cool, article. I've always loved maps and mapping and python is my preferred language. The only thing I would mention is that it would be nice to have a pic of the results earlier in the article, that's just from the "let's look at this article, seems cool but what exactly is he teaching me" angle. I'm more likely to try the code if I can see the results up front. Otherwise it was a really cool example.
- polskibus 13y agoMy biggest problem with maps these days is the data license for commercial use. I dont need very detailed map, usually administrative level 2, but it's hard to find accurate sources that dont make you pay thousands of dollars per small userbase. We create our own app and distribute it, therefore cannot exactly estimate our userbase. Does anybody know of a decent source with good, fairly detailed world maps and liberal license ? Doesn't have to be free.
- henryboston 13y agohttp://www.openstreetmap.org/#map=5/51.500/-0.100 http://www.openstreetmap.org/#map=5/51.500/-0.100
- maxerickson 13y agoOpenstreetmap? Just requires a simple attribution. (there are certainly lots of things to work on in the data)
- polskibus 13y agoThe freely available dumps to SHP are not up -to-date or have insufficient details and my several efforts to produce an SHP myself have failed. I'd like to be able to produce a shp dump that contains only selected "layer" for given country.
- sivetic 13y agoI think OGR (gdal.org) has an OSM driver that you can install optionally to go from OSM -> SHP. Problem is that SHP and OSM are not 100% compatible formats, so data massaging may be necessary in many cases. Also, Geofabrik.de will export it for you for a fee.
- polskibus 13y agoI tried QGis 2 with built-in OSM support but I was unable to properly download data through it. Perhaps I was doing something wrong, I'd love to read a good tutorial on this. If you happen to find one, let me know!
- zmjones 13y agoThis is exactly why I prefer R for static maps. Would have taken like a quarter of the time, if that.
- urschrei 13y agoA) The article's (quite clearly) not geared towards concision. B) Personally, I'm delighted that there are various ways to do this. It's good for innovation.
- deleted 13y ago[deleted]
- gjreda 13y agoThere's also Vincent[1], which has some mapping capabilities and is built on top of Vega (a "visualization grammar" for d3js). [1]: https://github.com/wrobstory/vincent https://github.com/wrobstory/vincent
- urschrei 13y agoYep, I'm very interested in exploring the (Geo)pandas / Vincent / Vega intersection.
- namelezz 13y agoCool! I have been looking for an article like this. Thank you for sharing.
- spiritplumber 13y agohttp://www.robots-everywhere.com/re_wiki/index.php?title=Gehandler http://www.robots-everywhere.com/re_wiki/index.php?title=Geh... I wrote a sort of google earth API wrapper thing in python if anyone wants it. Windows only though.
- cwal37 13y agoVery interesting, it had never occurred to me that there were probably python libraries for mapping. My ArcMap license expires in less than two weeks, perhaps I will give this a shot before I re-up.