GeoListPlot exact addresses
$begingroup$
In GeoListPlot
the locations are supposed to be GeoPosition
or Entity
objects representing entities with geographic coordinates.
But say I have a few exact addresses that I'd like to plot (with callout labels):
addresses = <|
"Land's End Bed and Breakfast" ->
"22 Commercial St, Provincetown, MA 02657",
"Favorite Restaurant" -> "9 Park St, Boston, MA 02108"|>;
If wolfram alpha can't find them, then how can I get this to work:
Is there an "address to lat/long" conversion tool on the web accessible though MMA?
geography
$endgroup$
add a comment |
$begingroup$
In GeoListPlot
the locations are supposed to be GeoPosition
or Entity
objects representing entities with geographic coordinates.
But say I have a few exact addresses that I'd like to plot (with callout labels):
addresses = <|
"Land's End Bed and Breakfast" ->
"22 Commercial St, Provincetown, MA 02657",
"Favorite Restaurant" -> "9 Park St, Boston, MA 02108"|>;
If wolfram alpha can't find them, then how can I get this to work:
Is there an "address to lat/long" conversion tool on the web accessible though MMA?
geography
$endgroup$
add a comment |
$begingroup$
In GeoListPlot
the locations are supposed to be GeoPosition
or Entity
objects representing entities with geographic coordinates.
But say I have a few exact addresses that I'd like to plot (with callout labels):
addresses = <|
"Land's End Bed and Breakfast" ->
"22 Commercial St, Provincetown, MA 02657",
"Favorite Restaurant" -> "9 Park St, Boston, MA 02108"|>;
If wolfram alpha can't find them, then how can I get this to work:
Is there an "address to lat/long" conversion tool on the web accessible though MMA?
geography
$endgroup$
In GeoListPlot
the locations are supposed to be GeoPosition
or Entity
objects representing entities with geographic coordinates.
But say I have a few exact addresses that I'd like to plot (with callout labels):
addresses = <|
"Land's End Bed and Breakfast" ->
"22 Commercial St, Provincetown, MA 02657",
"Favorite Restaurant" -> "9 Park St, Boston, MA 02108"|>;
If wolfram alpha can't find them, then how can I get this to work:
Is there an "address to lat/long" conversion tool on the web accessible though MMA?
geography
geography
asked Jan 22 at 16:39
M.R.M.R.
15.6k558188
15.6k558188
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
"address to lat/long" is usually called Geocoding, in case that helps with your research. Some options for a Geocoding API include OpenStreetMaps' Nominatim, Google Maps' API, and many others. Beware that virtually every option will either require payment or have a very stringent usage quota.
FindGeoLocation or Interpreter
FindGeoLocation["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Another official Wolfram Language way to do this is by using Interpreter
, like so:
Interpreter["StreetAddress"]["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Both of those functions work for the addresses you have, so you can plot them like so:
GeoListPlot[
KeyValueMap[
GeoMarker[Interpreter["StreetAddress"][#2], #1] &,
addresses]]
or
GeoListPlot[
KeyValueMap[
GeoMarker[FindGeoLocation[#2], #1] &,
addresses]]
You can experiment with different marker styling and so on - check the documentation for GeoMarker
. Many of the typical Plot
labeling functions like Callout
aren't supported in GeoGraphics
functions, however.
Nominatim
You might consider using Nominatim, in which case you could do it the following way:
First, query the service:
result = Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" -> URLQueryEncode[<|
"format" -> "xml",
"q" -> "9 Park St, Boston, MA 02108",
"limit" -> 1
|>]|>], "XML"]
Extract the attributes of the first place
:
attrs = Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]]
Finally, the actual position can be determined:
position = GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
Simply do this for each address you have and plot it like above.
We can bundle it into a single function:
geocode[address_] := Module[{result =
Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" ->
URLQueryEncode[<|"format" -> "xml", "q" -> address,
"limit" -> 1|>]|>], "XML"],
attrs
},
attrs =
Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]];
GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
]
And now we can do this:
geocode["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3576, -71.0629}]
That's extremely close to the Nominatim result. So close that I bet Wolfram have their own Nominatim deployment for this functionality.
Anyway, since we have this function, we can plot things the same way as if we used Interpreter:
GeoListPlot[KeyValueMap[GeoMarker[geocode[#2], #1] &, addresses]]
As I said above: You can experiment with different marker styling and so on - check the documentation for GeoMarker. Many of the typical Plot labeling functions like Callout aren't supported in GeoGraphics functions, however.
$endgroup$
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190010%2fgeolistplot-exact-addresses%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
"address to lat/long" is usually called Geocoding, in case that helps with your research. Some options for a Geocoding API include OpenStreetMaps' Nominatim, Google Maps' API, and many others. Beware that virtually every option will either require payment or have a very stringent usage quota.
FindGeoLocation or Interpreter
FindGeoLocation["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Another official Wolfram Language way to do this is by using Interpreter
, like so:
Interpreter["StreetAddress"]["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Both of those functions work for the addresses you have, so you can plot them like so:
GeoListPlot[
KeyValueMap[
GeoMarker[Interpreter["StreetAddress"][#2], #1] &,
addresses]]
or
GeoListPlot[
KeyValueMap[
GeoMarker[FindGeoLocation[#2], #1] &,
addresses]]
You can experiment with different marker styling and so on - check the documentation for GeoMarker
. Many of the typical Plot
labeling functions like Callout
aren't supported in GeoGraphics
functions, however.
Nominatim
You might consider using Nominatim, in which case you could do it the following way:
First, query the service:
result = Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" -> URLQueryEncode[<|
"format" -> "xml",
"q" -> "9 Park St, Boston, MA 02108",
"limit" -> 1
|>]|>], "XML"]
Extract the attributes of the first place
:
attrs = Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]]
Finally, the actual position can be determined:
position = GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
Simply do this for each address you have and plot it like above.
We can bundle it into a single function:
geocode[address_] := Module[{result =
Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" ->
URLQueryEncode[<|"format" -> "xml", "q" -> address,
"limit" -> 1|>]|>], "XML"],
attrs
},
attrs =
Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]];
GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
]
And now we can do this:
geocode["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3576, -71.0629}]
That's extremely close to the Nominatim result. So close that I bet Wolfram have their own Nominatim deployment for this functionality.
Anyway, since we have this function, we can plot things the same way as if we used Interpreter:
GeoListPlot[KeyValueMap[GeoMarker[geocode[#2], #1] &, addresses]]
As I said above: You can experiment with different marker styling and so on - check the documentation for GeoMarker. Many of the typical Plot labeling functions like Callout aren't supported in GeoGraphics functions, however.
$endgroup$
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
add a comment |
$begingroup$
"address to lat/long" is usually called Geocoding, in case that helps with your research. Some options for a Geocoding API include OpenStreetMaps' Nominatim, Google Maps' API, and many others. Beware that virtually every option will either require payment or have a very stringent usage quota.
FindGeoLocation or Interpreter
FindGeoLocation["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Another official Wolfram Language way to do this is by using Interpreter
, like so:
Interpreter["StreetAddress"]["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Both of those functions work for the addresses you have, so you can plot them like so:
GeoListPlot[
KeyValueMap[
GeoMarker[Interpreter["StreetAddress"][#2], #1] &,
addresses]]
or
GeoListPlot[
KeyValueMap[
GeoMarker[FindGeoLocation[#2], #1] &,
addresses]]
You can experiment with different marker styling and so on - check the documentation for GeoMarker
. Many of the typical Plot
labeling functions like Callout
aren't supported in GeoGraphics
functions, however.
Nominatim
You might consider using Nominatim, in which case you could do it the following way:
First, query the service:
result = Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" -> URLQueryEncode[<|
"format" -> "xml",
"q" -> "9 Park St, Boston, MA 02108",
"limit" -> 1
|>]|>], "XML"]
Extract the attributes of the first place
:
attrs = Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]]
Finally, the actual position can be determined:
position = GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
Simply do this for each address you have and plot it like above.
We can bundle it into a single function:
geocode[address_] := Module[{result =
Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" ->
URLQueryEncode[<|"format" -> "xml", "q" -> address,
"limit" -> 1|>]|>], "XML"],
attrs
},
attrs =
Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]];
GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
]
And now we can do this:
geocode["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3576, -71.0629}]
That's extremely close to the Nominatim result. So close that I bet Wolfram have their own Nominatim deployment for this functionality.
Anyway, since we have this function, we can plot things the same way as if we used Interpreter:
GeoListPlot[KeyValueMap[GeoMarker[geocode[#2], #1] &, addresses]]
As I said above: You can experiment with different marker styling and so on - check the documentation for GeoMarker. Many of the typical Plot labeling functions like Callout aren't supported in GeoGraphics functions, however.
$endgroup$
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
add a comment |
$begingroup$
"address to lat/long" is usually called Geocoding, in case that helps with your research. Some options for a Geocoding API include OpenStreetMaps' Nominatim, Google Maps' API, and many others. Beware that virtually every option will either require payment or have a very stringent usage quota.
FindGeoLocation or Interpreter
FindGeoLocation["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Another official Wolfram Language way to do this is by using Interpreter
, like so:
Interpreter["StreetAddress"]["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Both of those functions work for the addresses you have, so you can plot them like so:
GeoListPlot[
KeyValueMap[
GeoMarker[Interpreter["StreetAddress"][#2], #1] &,
addresses]]
or
GeoListPlot[
KeyValueMap[
GeoMarker[FindGeoLocation[#2], #1] &,
addresses]]
You can experiment with different marker styling and so on - check the documentation for GeoMarker
. Many of the typical Plot
labeling functions like Callout
aren't supported in GeoGraphics
functions, however.
Nominatim
You might consider using Nominatim, in which case you could do it the following way:
First, query the service:
result = Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" -> URLQueryEncode[<|
"format" -> "xml",
"q" -> "9 Park St, Boston, MA 02108",
"limit" -> 1
|>]|>], "XML"]
Extract the attributes of the first place
:
attrs = Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]]
Finally, the actual position can be determined:
position = GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
Simply do this for each address you have and plot it like above.
We can bundle it into a single function:
geocode[address_] := Module[{result =
Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" ->
URLQueryEncode[<|"format" -> "xml", "q" -> address,
"limit" -> 1|>]|>], "XML"],
attrs
},
attrs =
Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]];
GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
]
And now we can do this:
geocode["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3576, -71.0629}]
That's extremely close to the Nominatim result. So close that I bet Wolfram have their own Nominatim deployment for this functionality.
Anyway, since we have this function, we can plot things the same way as if we used Interpreter:
GeoListPlot[KeyValueMap[GeoMarker[geocode[#2], #1] &, addresses]]
As I said above: You can experiment with different marker styling and so on - check the documentation for GeoMarker. Many of the typical Plot labeling functions like Callout aren't supported in GeoGraphics functions, however.
$endgroup$
"address to lat/long" is usually called Geocoding, in case that helps with your research. Some options for a Geocoding API include OpenStreetMaps' Nominatim, Google Maps' API, and many others. Beware that virtually every option will either require payment or have a very stringent usage quota.
FindGeoLocation or Interpreter
FindGeoLocation["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Another official Wolfram Language way to do this is by using Interpreter
, like so:
Interpreter["StreetAddress"]["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3565, -71.062}]
Both of those functions work for the addresses you have, so you can plot them like so:
GeoListPlot[
KeyValueMap[
GeoMarker[Interpreter["StreetAddress"][#2], #1] &,
addresses]]
or
GeoListPlot[
KeyValueMap[
GeoMarker[FindGeoLocation[#2], #1] &,
addresses]]
You can experiment with different marker styling and so on - check the documentation for GeoMarker
. Many of the typical Plot
labeling functions like Callout
aren't supported in GeoGraphics
functions, however.
Nominatim
You might consider using Nominatim, in which case you could do it the following way:
First, query the service:
result = Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" -> URLQueryEncode[<|
"format" -> "xml",
"q" -> "9 Park St, Boston, MA 02108",
"limit" -> 1
|>]|>], "XML"]
Extract the attributes of the first place
:
attrs = Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]]
Finally, the actual position can be determined:
position = GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
Simply do this for each address you have and plot it like above.
We can bundle it into a single function:
geocode[address_] := Module[{result =
Import[
HTTPRequest[
"https://nominatim.openstreetmap.org/search", <|
"Query" ->
URLQueryEncode[<|"format" -> "xml", "q" -> address,
"limit" -> 1|>]|>], "XML"],
attrs
},
attrs =
Association[
Cases[result, XMLElement["place", attr_, _] -> attr, [Infinity]]];
GeoPosition@ToExpression@Values[attrs[[{"lat", "lon"}]]]
]
And now we can do this:
geocode["9 Park St, Boston, MA 02108"]
GeoPosition[{42.3576, -71.0629}]
That's extremely close to the Nominatim result. So close that I bet Wolfram have their own Nominatim deployment for this functionality.
Anyway, since we have this function, we can plot things the same way as if we used Interpreter:
GeoListPlot[KeyValueMap[GeoMarker[geocode[#2], #1] &, addresses]]
As I said above: You can experiment with different marker styling and so on - check the documentation for GeoMarker. Many of the typical Plot labeling functions like Callout aren't supported in GeoGraphics functions, however.
edited Jan 22 at 17:21
answered Jan 22 at 16:52


Carl LangeCarl Lange
4,3681735
4,3681735
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
add a comment |
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
I love learning new words... "Geocoding"! @Carl_Lange (ugh, not sure why when I type '@CarlLange' and press save - it disappears)
$endgroup$
– M.R.
Jan 22 at 17:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
$begingroup$
@M.R. It's been an important topic here in Ireland, because we didn't have postcodes until very recently, making geocoding an extremely lucrative business for the post office :)
$endgroup$
– Carl Lange
Jan 22 at 21:59
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190010%2fgeolistplot-exact-addresses%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown