19.4 bing geocode

20210525 The geocode command will take a supplied address and produce specific location details.

$ ml geocode bing [options] <address>
     -b            --bing               Generate Bing Maps URL.
     -g            --google             Generate Google Maps URL.
     -m <int>      --max=<int>          Maximum number of matches.
     -o            --osm                Generate Open Street Map URL.
     -u            --url                Generate Open Street Map URL.

The output, separated by commas, consists of the latitude:longitude (north/south : east/west) location, a bounding box for the region (south latitude : west longitude : north latitude : east longitude), the confidence that the identified location is a match, a match code (good, ambiguous, uphierarchy), the entity type. The remaining output is the identified address (which will generally has commas within it). In summary, that is:


If the location is ambiguous then several rows will be returned, one for each possible location.

You can control the maximum number of matches (1-20) with the default being 5, through -m or --max=.

Instead of providing the output described above you can request a URL (universal resource locator) be returned. The URL is a link to a map using either Open Street Map (preferred and default for -u, --url, -o or --osm``), Bing Maps (-bor–bing), or Google Maps (-gor–google`).

The following example splits the single line of output across several lines here for presentation. We geocode a specific locality:

$ ml geocode bing --max=1 anzac parade

This identifies it as:

Anzac Parade, NSW, Australia

The URL generation defaults to producing a URL link to Open Street Maps:

$ ml geocode bing --url anzac parade

There are actually three matches for this address.


You can copy and paste the URL into a browser. But suppose you want to display the second match above directly into the browser:

$ brave-browser `ml geocode --url bing anzac parade | sed '2q;d'`

The sed command (the stream editor) operates on the second line sent through the pipeline, printing it but deleting the other lines, and quits. Change 2 to 3 in the sed, for example, to get the third match.

Other examples:

$ ml geocode bing bunnings mentone 23-27 nepean hwy mentone vic 3194
$ ml geocode bing back creek --max=3
$ ml geocode bing back creek --neighbourhood
$ ml geocode bing back creek --url

$ brave-browser `ml geocode bing --max=1 --url albany creek`

$ brave-browser `ml geocode bing bunnings mentone 23-27 nepean hwy mentone vic 3194 --url`

You can get further details about the web service from the Bing Maps web site.

Your donation will support ongoing development and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.