Wikivoyage:Geocoding

From Wikivoyage
Jump to: navigation, search

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.

Syntax[edit]

20148 of 23574 destination articles have a Geo parameter.

85.467 % complete

For a destination[edit]

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:

{{Geo|lat|long}}

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:

{{Geo|45.5|-73.6}}

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://tools.wmflabs.org/wikivoyage/w/artmap.php?lang=en

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

For an individual point of interest[edit]

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.

{{listing | name=Ingleside | alt= | url= | email= | address= | lat=45 | long=-75 | directions= | phone= | tollfree= | fax= | hours= | price= | content= }}

or:

{{marker |type=city |name=Ingleside |lat=45 |long=-75 }}

gives:

  •    Ingleside.

...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 Wikivoyage:How to use dynamic maps for details on using geocoded POI's and GPX paths to build dynamic maps.

Metadata[edit]

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:

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

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[edit]

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 http://maps.wikivoyage-ev.org/w/artmap.php?lang=en which uses the geo tags in Wikivoyage:database dumps.

With the hCard format, it is possible to assign points to individual listings in a guide using Project: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[edit]

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 "+"

Sources for lat/longs[edit]

There are a few Web sites that provide useful lat/long information.

See also[edit]

External links[edit]