Hacker News new | past | comments | ask | show | jobs | submit login
So You'd Like to Make a Map using Python (sensitivecities.com)
265 points by urschrei on Oct 24, 2013 | hide | past | favorite | 40 comments



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.


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.


I 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.


This 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)


Tilemill 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

(Then you just have the task of pulling the data out of OSM and translating it into a format that you can work with)


Also, 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 :)


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.


You can generate images from TileMill. https://dl.dropboxusercontent.com/u/602885/hot-pink.png


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.


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.


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


Openstreetmap?

Just requires a simple attribution.

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


The 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.


I 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.


I 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!


It's been a while since I played with OSM data. OGR 1.10.0 supports OSM, and you can grab it from various sources (gdal.org or gisinternals.com/sdk/ if you want latest windows binaries).

Converting OSM -> SHP should be relatively similar to other formats, and there are a good number of tutorials out there for using OGR. Here's their page on OSM: http://www.gdal.org/ogr/drv_osm.html



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.


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.


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.


Doing the same thing using Cartopy is next on my list!


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


Yep, I'm very interested in exploring the (Geo)pandas / Vincent / Vega intersection.


Cartography? Hasn't everything already sort of been discovered, though by, like, Magellan and Cortés?


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?


Man, you can't get no respect for Arrested Development on HN.


I think the blue parts are plaques...


Cartography is about making maps, not discoveries.


Except for figuring out about Pangaea and continental drift.


That 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"! :)


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.


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.


What are blue plaques?


Historical markers: "on this spot in 18xx something happened" kind of thing.

https://en.wikipedia.org/wiki/Blue_plaque



Any Amercians think it was some hideous British dental condition? ;)


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.


This is exactly why I prefer R for static maps. Would have taken like a quarter of the time, if that.


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.


Cool! I have been looking for an article like this. Thank you for sharing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: