GeoListPlot exact addresses












9












$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:



enter image description here



Is there an "address to lat/long" conversion tool on the web accessible though MMA?










share|improve this question









$endgroup$

















    9












    $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:



    enter image description here



    Is there an "address to lat/long" conversion tool on the web accessible though MMA?










    share|improve this question









    $endgroup$















      9












      9








      9


      3



      $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:



      enter image description here



      Is there an "address to lat/long" conversion tool on the web accessible though MMA?










      share|improve this question









      $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:



      enter image description here



      Is there an "address to lat/long" conversion tool on the web accessible though MMA?







      geography






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 22 at 16:39









      M.R.M.R.

      15.6k558188




      15.6k558188






















          1 Answer
          1






          active

          oldest

          votes


















          9












          $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]]


          enter image description here



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


          enter image description here



          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.






          share|improve this answer











          $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











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          9












          $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]]


          enter image description here



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


          enter image description here



          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.






          share|improve this answer











          $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
















          9












          $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]]


          enter image description here



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


          enter image description here



          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.






          share|improve this answer











          $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














          9












          9








          9





          $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]]


          enter image description here



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


          enter image description here



          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.






          share|improve this answer











          $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]]


          enter image description here



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


          enter image description here



          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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


















          • $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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          Npm cannot find a required file even through it is in the searched directory