Wikivoyage:Geocoding

It's possible to encode information about the latitude and longitude of a destination, or of individual points of interest at the destination, into the guide itself. This information is used to generate locator maps and special HTML tags (hCards) which relate a Web page to a geographic location.

For a destination
The easiest way to add lat/long information to a destination guide article is to use the Geo template. To do so, add the following code to a page:



Here, lat is the latitude and long is the longitude. Both coordinates must be in decimal form ("45.5", not "45 30 00")--see Converting from traditional format. For example, Montreal contains the code:



which renders the map link in the upper righthand corner of that page.

A world map showing all geocoded destinations in the English-language Wikivoyage appears at https://wikivoyage.toolforge.org/w/artmap.php?lang=en

Note that only one geo instance in a page makes sense.


 * find destination articles without a Geo parameter

For an individual point of interest
To encode GPS information for listings in Wikivoyage, use the lat and long attributes in the listing tags or template. Each listing item displays an icon with a link to a locator map with the supplied decimal co-ordinates.

A listing or marker typically locates a point of interest, such as an individual landmark or building.

or:

gives:

...with an icon linking to an OpenStreetMap-based locator map. The 'type' is normally one of (see, do, buy, eat, drink, sleep, listing); the use of cities as points of interest may occur in itinerary.

As this allows decimal co-ordinates to be specified for every individual listing, it can be useful for pinpointing locations with no street address (such as statues or markers surrounded by parkland). See How to use dynamic maps for details on using geocoded POI's and GPX paths to build dynamic maps.

Metadata
In the past, we used the Resource Description Framework (RDF) format to encode one pair of lat/long co-ordinates into each page; a template generated HTML code like:

&lt;rdf> <> dcterms:spatial [ pos:lat "45.5" ; pos:long "-73.6" ].

to indicate that "this page covers something with lat/long of 45.5/-73.6". Wikivoyage does not currently use RDF, instead using the hCard microformat to encode (lat, long) co-ordinates for each listing in a format which can be read (and downloaded as a .kml file) by the Firefox Operator extension. These also provides a vCard-like format for contact info for each templated listing.

The hCard microformat is generated automatically by the listing template.

Limitations
Because the RDF system assigned a single geographic point to the entire destination guide, it was only suited to locations that were a) big enough to have a whole guide to themselves and b) small enough that a single point is a reasonable approximation for the location; effectively, only city guides were amenable to geocoding in this way.

This functionality corresponded to the current geo tag. Wikivoyage eV now generates world maps based on these co-ordinates, for instance https://wikivoyage.toolforge.org/w/artmap.php?lang=en which uses the geo tags in database dumps.

With the hCard format, it is possible to assign points to individual listings in a guide using Listings. From these, mapframe may be used to place an automatically-generated locator map on-page at the local (city/town destination) level.

Converting from traditional format
To convert from traditional format like lat=N45°30'0", long=W73°36'0", the following can help:
 * X°Y'Z" = X+(Y/60)+(Z/3600)
 * for S, add "-" to lat; for N, assume "+"
 * for W, add "-" to long; for E, assume "+"