Wikivoyage:Geocoding

From Wikivoyage
Jump to: navigation, search
P writing.svg

This article is the collaboration of the month for December 2017. Find out how it can be improved, and plunge forward to make this an article we can be proud of!

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]

24275 of 25035 destination articles have a Geo parameter.

96.964 % 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:

  • 1 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.

  • Wikipedia gives co-ordinates for most articles about places
  • Geomap - search via OSM Nominatim, provides coordinates in WV templates formats
  • Geobatcher is a tool which can take an entire section of Wikivoyage listings, and insert coordinates for up to 100 listings at a time. More instructions in article, How to use dynamic maps.
  • Multimap lets you search for cities in many countries and returns lat/long info (some problems with non ASCII chars in the names)
  • The Getty Thesaurus of Names has lat/long info for most cities in its database
  • The Global Gazetteer from Falling Rain Genomics, Inc. is another database that gives decimal geocode values for many place names around the world.
  • Richard Cyganiak's FOAF mapper - Find co-ordinates using Google Maps.
  • GeoNames - Quick and thorough geocoding
  • Nominatim - OSM reverse geocoding
  • OpenStreetMap - Browse the map, click the share icon on the right side toolbar, check the box Include marker, move the marker where desired, the lat/long can be copied from the Geo URI link.
  • If the destination has a geo tag, there will be a map icon at the top right of the article. If you know the area then you can get co-ordinates for listings by going to that map, positioning the mouse pointer, then right-clicking to show lat and long info.

See also Wikivoyage:Dynamic maps Expedition#Sub-expedition: Fill all the latitudes!.

See also[edit]

External links[edit]