Rendering map data with Mapnik and Python

Video thumbnail (Frame 0) Video thumbnail (Frame 1353) Video thumbnail (Frame 3577) Video thumbnail (Frame 11812) Video thumbnail (Frame 12944) Video thumbnail (Frame 26686) Video thumbnail (Frame 29688) Video thumbnail (Frame 30574) Video thumbnail (Frame 31844) Video thumbnail (Frame 33422) Video thumbnail (Frame 34250) Video thumbnail (Frame 46661) Video thumbnail (Frame 48526) Video thumbnail (Frame 50930) Video thumbnail (Frame 55169) Video thumbnail (Frame 56694)
Video in TIB AV-Portal: Rendering map data with Mapnik and Python

Formal Metadata

Rendering map data with Mapnik and Python
Title of Series
CC Attribution 4.0 International:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date

Content Metadata

Subject Area
Mapnik is an open source toolkit for rendering maps, probably best known for producing the map tiles for It provides a stylesheet language, input handlers for different GIS data formats, and C++ and Python API bindings.
Process (computing) Computer animation Set (mathematics) Formal language
Process (computing) Database
Program code Computer file Code Device driver Shape (magazine) Computer font Computer programming Scalability Formal language Medical imaging Latent heat Cuboid Diagram Form (programming) Potenz <Mathematik> Texture mapping Mapping File format Keyboard shortcut Data storage device Bit Database Line (geometry) Cartesian coordinate system Vector graphics Process (computing) Computer animation Graphics software Telecommunication Volumenvisualisierung Speech synthesis Configuration space output Library (computing) Probability density function
Building Group action Direction (geometry) 1 (number) Solid geometry Function (mathematics) Shape (magazine) Medical imaging Different (Kate Ryan album) Computer configuration Forest Square number Electronic visual display Arrow of time Circle Endliche Modelltheorie Physical system Area Simulation Meta element Texture mapping Mapping File format Digitizing Keyboard shortcut Moment (mathematics) Gradient Sound effect Type theory Digital photography Shooting method Repository (publishing) Triangle Volumenvisualisierung output Pattern language Quicksort Data type Point (geometry) Computer file Connectivity (graph theory) Graph coloring Rule of inference Attribute grammar Number Revision control Computing platform Metropolitan area network Form (programming) Dependent and independent variables Information Projective plane Polygon Physical law Line (geometry) Symbol table Computer animation Query language Personal digital assistant Network topology Object (grammar) Musical ensemble Window Library (computing)
Stapeldatei Functional (mathematics) Open source Computer file Mapping Polygon Physical law Similarity (geometry) Bit Line (geometry) Shape (magazine) Graph coloring Rule of inference System call Event horizon Computer animation output Object (grammar)
Voting Computer animation Code Water vapor Rule of inference Communications protocol Event horizon Field (computer science)
Mathematics Computer animation Information Logic Code File format System call Resultant Condition number
Particle system Computer animation Cartesian coordinate system Rule of inference
Complex (psychology) Context awareness Building Code View (database) Multiplication sign Combinational logic Medical imaging Mathematics Conjugacy class Different (Kate Ryan album) Forest Single-precision floating-point format Negative number Area Texture mapping Structural load Fitness function Bit Phase transition Volumenvisualisierung Right angle Quicksort Figurate number Resultant Probability density function Point (geometry) Slide rule Game controller Service (economics) Divisor Computer file Open source Student's t-test Event horizon Graph coloring Metadata Product (business) Number Energy level Form (programming) Physical law Line (geometry) Rectangle Symbol table Computer animation Personal digital assistant Network topology Light field Video game Library (computing)
Slide rule Addition Greatest element Group action Email Texture mapping Key (cryptography) Code Connectivity (graph theory) Neighbourhood (graph theory) Physical law Expert system Combinational logic Solid geometry Computer Cartesian coordinate system Revision control Subject indexing Medical imaging Computer animation Circle Summierbarkeit Position operator
Standard deviation Context awareness Mapping Multiplication sign Surface Data storage device Basis <Mathematik> Instance (computer science) Student's t-test Cartesian coordinate system Roundness (object) Computer configuration Damping Endliche Modelltheorie Cycle (graph theory) Routing Identity management
Addition Computer animation Personal digital assistant Order (biology) Entropie <Informationstheorie> Sound effect Database
hello and welcome to our 2nd set showing and I want to prove that to foster social set 1st it's English language ability of a you the and it OK so the technical difficulties are way also OK and that the process of social club the German chapter of the always feel and all of them um we're gonna make this conference together uh the frost counting here of a
fuel and all of them right and now we have to talk about from happened there are a lot of his talks last year here also a that cross from solid you maybe the whole of the presented with a here at the year on your talk to from from so if you have to know and I thought because they think you so my name's talk what we already know that the and size living beautiful to Germany really the the and I study so electric Engineering and Computer Science and its doing OpenStreetMap since almost 10 years now so next week and it's going to be 10 years for me the uh and that the few few it and see my primary job I do not really work with use Due data all that stuff on on a database support engineer for Maria DB informally for wide-scale some usually doing the boring database stuff might they dropped out try to do
other things on the side like what we have
now so I'm going to have to talks today around this 1 is describing the basic sirens while working on the application but I will present the 2nd 1 in the afternoon about printable OpenStreetMap which which this big printer you is hopefully being operational in the afternoon found so what is matic this will help the usual Computer Science diagram there's some big box in the middle is input coming in and but coming out at some configuration coming from the side and some code that use controlling what is happening and map Nick is actually library that sits in the middle and with use processing that data and is if converting it into pretty pictures that's the simple story so for this magnet can read several different so the kinds of input line couple shape files which is a specific form at fault you data and it can read so geo data that comes from a Moscow databases his native drivers for posters and for spatial light using the microphone the but and see of and it also has support for other database wires so that special extirpated library you can actively reheated G adjacent the and it can also read a lot of other formats wire 2 extra pockets 1 using the OGI library that these supporting both electron across the images so this can be used for example to read through all those that moved they talk and exponents this cheat all that is only there to recrossed images display pre-rendered images that he wanted and that in the map and on the other side we have different altered fonts that become support but this we can produce PNG files both full-color filed store reduced correlate fast like font smaller as maps you don't have that many countries become fact we can produce scalable vector graphics that's especially interesting if you want to go to create a map and then you start in graphics program like Inkscape all on the Adobe tools 2001 acts the most after it because produce printable PDFs right away and also still can produce printable PostScript that it's that defeated but as Postscript and PDF of our sort of of much and to so we have or input on the 1 side goes in and then there's a solid 1 to have pretty pictures so we need the 1st thing in that use the render starts the film the magnet how to take the input data and transform it into pretty pictures on for this they can either to the define render solvents directly in the program code or we can use the external XML style fonts that describe how want to all stuff renders and both have their advantages and disadvantages that we'll see later and there are also some other structured languages that can be converted into the mapmaker XML format like of cost is as for example that is used for the main OpenStreetMap style that are a bit more readable than the external this so and map it itself is not a stand-alone program it you use the library so we need at least a little bit of extra code around its to make full rendering application and the library itself was between the across + on and there it is python bindings so that you do not you have to use C + + code directly can use in imposing programs which is used to come to be easier and we also have experimental bindings speech which are found just and haven't tried yet so long the gun really tell how good that works at so the stock is only about the Python bindings don't few things we need to start is that obviously
need python and it works both ways by 2 and 3 that some features may only be in the latest version but only works with free we also have 2 different versions of Madnick written to inverted 3 but is not related to the post emerging sectors also 2 and 3 by coincidence I don't we have that python bindings in that need to be included in the main Maddox housecoat and automatic Mednick 3 it's 2 separate projects the talk to separate repositories you have the main libraries C + + and then the 2nd project that thus the Python bindings but
usually you don't really have to care about it like on TV and into you just install python that make and that falls in all the other things that are needed and this there to do it useless because it did not in other platforms and all that on micros and all the stuff is in the home brew system I know that there are in the spectra somewhere but I don't know anything about Windows all I have no idea how to install the don't so what yeah does on the input side is that all the inputs from ones we have deliver just for data types to the actual library and that is the points the expensive interest have some attributes that it's lines like for example street the polygons that's all kinds of areas for land use areas or the shape of a building so everything that is close to 1 that actually defines an area is a polygon and there's also the possibility to import images that are already pre renewed like for example this is used in some of the stigma on 1 maps to include hide information while making 1 solid all the moment the darker to have solid to the 3 D effect that is some not Mapic itself but but using pre-rendered images that have this the types all check the shuttle simulation data pre-rendered distinctive fire and this is not necessary the data form of the data used in the actual input files like use roles and faults in book form it's different so the input layer has to convert it into this formats and each of these objects can also have additional information not only that you photometry information but also different attributes can be used to be slot what gets from that and how it gets 100 like the most basic case almost every object that we're going to render it is going to have a name this name can be used inside rule to say I want the main displayed here we also see that later we it so then we have to start definition and not make but again consists of 3 different basic kinds of objects 1st the use of the layer so they defines what data we want to use and what style all what multiple sponsor used to display the data don't style can future work considered only want to to take the input data but only want remnants of the things that have a name for the purposes summaries of whatever attributes you have and then uses what's called symbolizes the use of all was that the meta components to the actual drawing of the things so we have 4 basic types of symbolizes the director mapped to the 4 basic kinds of objects response symbolizes 1 symbolizes 41 symbolizing restless and allows and these all pre you see what the points and by that just draws little square or you can move while the this the other candidates the name of a simplified you want so if line symbolizes the choose gets information on topic you want to grow drawing a line what color you want to draw 1 in and have some basic options like can have adopted line and described and the size of the gaps in the size Corrigan symbolizes just takes an area FIL stated with solid color roster of symbolize it just takes the input across the image the MIT resources it but otherwise just puts it directly into the output without modifying the and then we have more complex ones these markers symbolizes that can put markers on like when you have a 1 way street so you can put the little arrows this marker on the line to show that you can only use it in that direction we have what's called the line patterns and laws spending are expected to promote butter and that can be used to draw the simplest some of on the side of a line like when you have some an action landscape query the let's goes you have these little triangles in usually that starts to go but the side of the line these can be drawn use the line patterns symbolizes when there is very important thing the text that is so as the name says used to show text and it's usually uses the name attribute or whatever you have a the data that give something from object and the inputs that ensemble and they can be useful points for lines and for Portland 4 points that you just put the text next to the point 4 lines to put the text along the lines and for all because it just try to find the middle of the polygon put there depending on how complex trade is that can be proved far all perfectly summary don't expect it but if you have like a half-moon the text will not being that half-moon shape but it will in the middle of the circle that would be the full and then there's a special kind of democracy in its shoots symbolizes and like again but if a of the OK so you'd symbolizes is used mostly for of hiring numbers so that's was called Chiu symbolizes because you as maps user usually shown in little shields so opportune model does is that has a basic image of the and then it knows how to extend it to fit the number of attacks you want display in it so if you have on the digit number it's small 2 digits three-digit automatically get smarter In the final 1 we have is photograph patterns symbolizing How is similar to the basic building on symbolize about it can fill the polygon not only was so some color but with the background image so the small repeatable image was for forest you of 3 background and 1 2 trees on it use gives polygon pattern symbolizes inspection use this image just and put it into a polygon and its Our this very special long building symbolizing so for the new experimental 1 that draws buildings and sort of the symmetric sort of the the but you so you have sort of just direct and for building you have little so I do books in also going to take in account the height of the building so now let's get advice about again this the very basic use all of the library so you have to be imported yeah you have to define a map given size and then the end you call render to file for the man who created file name and the file types then it follows that so this obviously does nothing but the these grades and to follow this is
constant background not that interesting at
this so the we had a bit more here this to start with giving the matter that the matter the background color studio here then we define polygon symbolizes it also gets to come like the created rule objects we then the polygons symbolize at room to external objects and the rule style so stock and have wonderful reducing the rules that get stuck my drawing of when you want to draw roads might 1st draw white line then we draw slightly smaller line in a different color so you have a rope wants is batch and then the 3rd year rule you may then put text talks the rule at the top of the road to print the if you have 1 rule so once in the laws of 1 rule 1 style we found when we start the Mac similar object knows this rule called countries with the given style just creates a lot of things going on here and then we create layer of not combines the data and the style call that layer of world it's about about the source here the user trade 5 use a predefined file that has the shapes for countries in the world we have found that society defined to layer the event related to map you the mapping function in all of these yeah to zoom far enough that everything in the input file can be seen In the end of the pilot so note that already
here we have the blue background to the foreground we didn't give any rule fall from the borders Water Seal just artifacts you to analyzing and alive going on the edges of the protocols so the fall of the house and the realizing enabled that's what we see the edges here but you get and done that often we would only have the continents the the water so
next let's that 2nd rule the so the 41 symbolizes exam no but we don't know this what we had from the it's good so now we have 2nd voting on symbolizes the fields could in that and the other the 2nd rule you Germany this rule we define a theater that filter is supposed to only render things that have the name John the name of the is also said and chief of border so we events 2nd rule the following members of the code is the previous 1 something
else change because the borders of it but see now Germany is not meaning logic is that well we also see that they
have to write a lot of code here half so this
still quantitative to not do this bicycle use the the XML format and stuff so the
place we replace all the ruins violated conditions we had it's just a call to load map and give it next Metafont so this is what the x amount of notes this is exactly the same style as before 4 countries the green 1 comes to um the country information from the from to follow and so the result is obviously
also the same but you must
unreadable as is it's still more readable but this so we started
off doing things and particle directly is that you can change rules dynamically so in an interactive application that you want users to be able to change starts on the this back to the center of the work it would be more flexible was this is
more suitable when you have a predefined styles that you do not want to change the so for the rest of the examples of we use takes the form of trees this is a better fit for the service
so I have a few examples of symbolizes the fortunately was involved and finish to copy all of them over this thing it would you didn't finish has lots of time beauty but you you get the idea and the other all also described in the medical condition and for most of the symbolizes the code examples both fictional and for so we only do the basic things here the final verdicts in a year but the continents are different you want to see in the slide so we do here is to zoom into all the data but the you know data files only has a few points the and just assume on these 2 points which the 2 points at the edges and I thought of symbols for these 2 points you can only see half the point because the other half of the of the of the image so we do not assume called the as negatives olfactory things out factors 1 product wants to resume all but 10 % it's enough to see see all the features we want don't that is also a fine I point symbolizes that just shows the point of view that is PG funded just as if it's it and now I was a data source and what he's the drunk is shaped by anymore but it's all 2 adjacent file this is the case the farther you go you see it only has 2 points in different places so this is the final map to get used to point obviously not that useful this example works it's the most basic thing the thing to do so the reimagined would have several slots that each of the point would draw different things to people people the points of the sample and all this a bit more complex that's you that a total thinks that this is so in this example we have achieved on the duties and find it only has a single line use to symbolize the plants and local also to and 1 text symbolizes uses a certain forms so far as is the color of the light field the let's see what the deal is so so that's also fully correct here and it was on 3 this so the signal although they context there would this sort of actually rendered is just the blue line and the texture on top so the fixed lines with line um conceded is black text on blue this slide right figure around that's the so that these clinics for example you have that text on top of something else that is also like you can still read the text you so the other devil symbolizes sudden covering examples we we have a potent symbol of the 1st good example ready the total Marcus and a lot of the things he's always since on the side of his students and talk to symbolize the for highly numbers and stuff like that like that of symbolizes 4 lines that have small small things on the side I put a concordancer laws of fulfilling life of forest area in repeated forced on the image and the buildings and symbolizes of buildings in so on all of this we could have done it is just a standalone magnet that was nearly you in the to model but what makes the combination of Python that interesting is that you can also use other drawing attention to draw things around on top of you have lot you can use the car graphics tell that you not to render fights itself but the creative but PDF services suppose the young so that you can generate a PDF file and you create what's called a complex conjugates use what you actually drawing to Mr. create a map of certain size the load of side she is a woman now what is different is we do not run that will follow either way but you we render to sort phase we defined the actually rendered into all an image that has control over different library and which we can still use the change later that's what we're going here and going to do here Mr. the the color we want to use like it's the alignments we want to use to 5 points that the say you want to have a rectangle of a certain size and complex stroke is what actually draws a rectangle using the line with and color we find that the it's not that doesn't render the 5 anymore we tell the kinds of things but we finished in there it's is also supposed post about the PDF files so the result is we have a lot of points again here which fall from the metadata and we have the rectangle that is not needed at all of the people don't talk ourselves I can also use that to not only drops of directly but it can also be pretty easily put as the G images on top so we also need to import the artist you Liberia we draw maps as before then the reader are so this 95 here so the coordinates were going to draw it this image is actually too large for them the event level summary size it's so it's always only half of size remember it's to the current context of acres of in and again say finish but results all the file so now we get this will help to modify again knowledge have of the gene which also means more on them that it's so the summary
this is what a computer application looks like that uses all these components to drawn up so the other election that year the decorations and solid so the the top among the bottom so the the title talk we have some copyright notice of text in the bottom we have an index on the side and on top of a map if experts gene markers all the things in the next slide thus the best this year in map squared so this position and we have that circle which is you what you want all this was created using the we've seen this law but no knowledge application that will talk about in the afternoon in more detail and that's also printers here for the sole 3 going to be operational in the afternoon so all goes well if you want to have a map of the neighborhood arrangement in the afternoon you would expect you to talks so that the sum of those of this
talk what we learned about ITER and my 1st venture into Python and use once you've figured always told not to do it in such a reasonable you have not seen much code here a the w using the status of cold and obviously is always in all the details but most of the work is not on the correct side but on this side all the combination also not nearly all Python and but also for a very flexible not rendering and thinking things around the map on the top of the map addition to the action of the rendering and what about mostly these phonetic accommodation he is not as good as expected it to be the that is so mostly all of the key on the law of the it repository on describes all the stuff but sometimes we only have a header and images this this this company for the nation and what's more annoying is often enough you have this only works if this version so there's a group a version of now it doesn't mean what is replaced you don't really know what the often enough defined so so
that's what gives special kind of the way in which has helped to produce the store has not succeeded in preventing him from doing it so all this time for questions the the with you know that
the you like Erika can I get some stifled some predefined thought 1st for instance the models used on a horse and the things of label devoted only it's over the course of what yeah have also set up all the public psychologically it will off of visual signal expired in general students silence if it's such of the covering other talk in the afternoon the years and this has been the time-consuming this is that once you need to do is start from scratch so you usually either use 1 of the more extensive already exist what is called a cycle tools and bright which can be used as a basis so but this stuff on top or what I do in the application social afternoon is 1st use standard SPARQL to run the up and the use 2nd followed to just put on top so really interested in like of hiking routes for the fire-fighting facilities so that way you don't have to do with surface which just put on top of existing stock would industry so putting several styles the same care context all any more questions the the conclude you mean this OK and preventing started fires that mapping has its own style 5 from there enough to have that as the for the people of Taiwan from fortunately there is no option it is as if it it is I have long the style of really like to offer in the identication it is only coming next is a style and this dark emerges for converting and map it into that sees is not the other way round of that's so further questions the the
I what would have preferred the resource you use your stifled written restore not would I using the most of the predefined slots users actually on the cross entropy produce import of course and data into a posters databases but I wanted to have stand-alone examples here that you expect things that's wages it you can have something smaller self-contained but I guess it's not really feasible for large larger from your Europe other additional questions In order to the case so that for effect here and for the rest of the