top | item 6604785

So You'd Like to Make a Map using Python

265 points| urschrei | 12 years ago |sensitivecities.com | reply

Use Pandas, Matplotlib, and Basemap to extract, clean and re-arrange data, before creating a series of thematic maps.

40 comments

order
[+] Demiurge|12 years ago|reply
Cool 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/) 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|12 years ago|reply
Can 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.
[+] hnha|12 years ago|reply
be 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.
[+] bennyg|12 years ago|reply
That 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.
[+] polskibus|12 years ago|reply
My 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.
[+] Thrymr|12 years ago|reply
Natural Earth data [0] is public domain. Their terms of use state "No permission is needed to use Natural Earth. Crediting the authors is unnecessary." But I think they only have down to admin level 1.

[0]: http://www.naturalearthdata.com/downloads

[+] maxerickson|12 years ago|reply
Openstreetmap?

Just requires a simple attribution.

(there are certainly lots of things to work on in the data)

[+] sivetic|12 years ago|reply
What kind of data are you looking for? Many governments provide data for their own country, with differing licenses (the Canadian ones I've used are commercial-friendly). There are a good number of open GIS data initiatives around the world, that you should be able to find exactly what you're looking for.

You can also check the data that ESRI provides, as some is free, and other is paid.

[+] pacofvf|12 years ago|reply
In 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|12 years ago|reply
Surprised 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|12 years ago|reply
Doing the same thing using Cartopy is next on my list!
[+] gjreda|12 years ago|reply
There'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

[+] urschrei|12 years ago|reply
Yep, I'm very interested in exploring the (Geo)pandas / Vincent / Vega intersection.
[+] dannypgh|12 years ago|reply
Cartography? Hasn't everything already sort of been discovered, though by, like, Magellan and Cortés?
[+] mapmeld|12 years ago|reply
In 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?
[+] herge|12 years ago|reply
Man, you can't get no respect for Arrested Development on HN.
[+] pwang|12 years ago|reply
I think the blue parts are plaques...
[+] sp332|12 years ago|reply
Cartography is about making maps, not discoveries.
[+] jaegerpicker|12 years ago|reply
Very 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.
[+] cwal37|12 years ago|reply
Very 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.
[+] zmjones|12 years ago|reply
This is exactly why I prefer R for static maps. Would have taken like a quarter of the time, if that.
[+] urschrei|12 years ago|reply
A) 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.

[+] namelezz|12 years ago|reply
Cool! I have been looking for an article like this. Thank you for sharing.