Osmarender/Creating maps of Indian districts

From OpenStreetMap Wiki
Jump to navigation Jump to search

This page describes how to make simple modifications to osmarender rules files (e.g. osm-map-features-z11.xml) so as to create maps for individual districts of India. As described in the page Localized maps with Osmarender, the rules files can be set to show place names in any script if it is present in the name:xx tag in the OSM database. Examples of district maps in Kannada and Latin scripts can be seen in some of the files at Wikimedia Commons and similar categories for some of the neighbouring districts. (Look for the maps whose names start BagalkotDistrictMap..). It was necessary of course to add names in Kannada script for each place shown; ie, add values to name:kn tags.

The rules files used are based on the osmarender files, as described at Osmarender and Osmarender/Rules. The z11 zoom level is suitable for creating a district map, though others could also be used. For use in any other language, replace the language codes with the other language wanted; e.g. replace 'name:kn' with 'name:hi' for Hindi.

For the simplified district maps, the multiple colours of the standard Osmarender display are too intrusive, and hence it would be wise to show all roads in a similar colour, and to leave out forests, industrial areas, and other land usage. Because villages and towns could not be located precisely by the names alone at this scale, each was marked by a translucent circle.

For the districts that I have worked on, I modified the names in the districts I have been working on to consistently use a phonetic spelling in Latin script for the name tag. The common 'English' name, if different then goes as the value for the name:en. It also allows the creation of maps that use the English spelling. This allows some more flexibility than using the most common spelling for the name tag. Actually, I would like to use the name in IAST format for the name tag, but of course this takes more work in actually typing it out; but it would make the pronunciation quite unambiguous and add value to OSM as a reference. AMS maps use some of the IAST conventions for some village names, which was very handy in determining the actual names in other languages.

For finding the place names, [AMS] maps are a good first reference. Other sources should then be used to check that the village or place still exists (AMS maps seem to be entirely based on pre World War II data). Confirm the actual spelling in the selected language, e.g. by looking for the name in government records. In many cases, entering the Kannada text into a search engine was usually sufficient to bring up possible matches. When these could not be found, the ambiguity and general unreliability of 'English' spellings frequently caused problems.

Modifying a rules file for district maps

Modifications as described below were made to the z11 rules file. All instances of name:kn or name, can be replaced with name:hi or anything else, or they can be left out entirely.

Place names

The following will set town names in Kannada script if available, in Latin script (or whatever is in the name tag) if the Kannada is not available. The section starting with <rule e="node" k="place" v="town"> has to be repeated for villages, and anything else where the name is to be substituted. The line <circle r="80" class="locality-marker" /> creates a small blob at the location of the town.

        <rule k="osmarender:renderName" v="~|yes">
	    <rule e="node" k="place" v="town">
		<circle r="80" class="locality-marker" />
		<rule e="node" k="name:kn" v="*">
		    <text k="name:kn" class="town-caption-kn"/>
		    <text k="name" class="town-caption"/>

The css to go with this resembles

            .town-caption-kn {
                fill: black;
                stroke: none;
                font-family: "DejaVu Sans",sans-serif;
                font-size: 176px;
                font-weight: bold;
                text-anchor: middle;
            .town-caption {
                fill: black;
                stroke: none;
                font-family: "DejaVu Sans",sans-serif;
                font-size: 108px;
                text-anchor: middle;
            }  text-anchor: middle;

            /* Place markers */
            .locality-marker {
	      stroke-width: none;
	      stroke: #3333dd;
	      fill: #e8c375;
	      opacity: 0.6;

District boundary and outside fill

The following will select the district boundary, and set areas outside the boundary to have a grey fill. It is inelegant in programming terms - an if ... do nothing ... else ... do something construct, but my brain will not improve on it.

       <rule e="way" k="boundary" v="administrative"  >
	  <rule e="way" k="name" v="Bagalkot" >
	      <area class="district-outside-fill" />
	      <line class="district-stroke" />
            /* Indian district specific fill and stroke */
            .district-outside-fill {
                fill: #a29fa7;
                fill-opacity: 0.3;
            .district-stroke {
		stroke: #b3aeb8;
		stroke-width: 60px;
		stroke-opacity: 0.4;
		stroke-linejoin: round;
		stroke-linecap: butt;
		fill: none; 

In addition, for the maps I created, much of the area fill options have been disabled, and all roads shown in the same colour.

Clean up

The result will usually need to be cleaned up with Inkscape or other SVG editor, such as to move names of neighbouring villages that overlap. Depending on how the rules file is structured, some items might need to be moved up or down in the zorder of the SVG drawing.

Indian scripts

Providing the names in the correct scripts have been set for each town or village, and providing they are installed on the target system, they will appear on the output map. At the time of writing there are relatively few of these, the most numerous being name:kn (780 instances) followed by name:en (630) and name:hi (283). These exclude the names in other scripts that are included under the unqualified name tag, including most large cities in northern India.

After some experimentation I set the Kannada names to be displayed in a larger font than the Latin text to ensure readability (typically 50% more in font size). The font display will vary between computer systems because of the particular fonts used; this can be seen on the Kannada text on the Wikipedia generated displays of the Kannada svg files, which are distinctly larger and blockier than the ones that I see on my system (the excellent Mandriva Linux).