Message Boards Message Boards

0
|
4051 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

How can I get WolframAlpha to give me information for each line of a file?

Posted 10 years ago

Let's say I have a text file with n geographical locations, with 1 on each line. I want WolframAlpha to give me the longitude and latitude of each location. How can I do this? I've tried using the file upload feature on WolframAlpha but I can't get WolframAlpha to understand that this is a list of geographical locations, and that I want to get the longitude and latitude of each one.

POSTED BY: Edward R
5 Replies

This should be possible:

http://www.wolframalpha.com/input/?i=tokyo%2C+beijing%2C+Cairo%2C+Rio+De+janeiro%2C+Champaign+IL+

Use the show coordinate button. But this usually takes longer time. The corresponding API call from within Wolfram Language is:

WolframAlpha[
    "tokyo, beijing, Cairo, Rio De janeiro, Champaign IL ", {{"Path:CityData", 2}, "ComputableData"},  
    PodStates -> {"Path:CityData__Show coordinates"}
]

enter image description here

POSTED BY: Shenghui Yang
Posted 10 years ago

I have already done that, but the length of the query is severely limited. I have hundreds of thousands of locations, and I can do maybe ten at a time by specifying a URL, because of limits on its length. That is why I want to use the file upload feature of WolframAlpha. (I.e. when you go to wolframalpha.com, you have as options "extended keyboard," "image input," "data input," "file upload.") I want to select file upload (or use the API to upload a file), and have WolframAlpha give me the coordinates of each location in the file.

POSTED BY: Edward R

Would you mind to share part of the file? I think calling directly from web is still harsh but relying on API could be possible. The only issue you could have is that such frequent usages of API will require pre-paid account and developer account.

You may contact support@wolfram.com for more details.

POSTED BY: Shenghui Yang
Posted 10 years ago

Would the approach you link to allow me to get the coordinate data for many locations with a single API call?

EDIT: The approach you have linked to is not quite what I am looking for. I do not want to query WolframAlpha's API once for each line in a text file. Rather, I want to use the file upload feature of WolframAlpha. (E.g. when you go to wolframalpha.com, you have as options "extended keyboard," "image input," "data input," "file upload." I want to select file upload (or use the API to upload a file), and have WolframAlpha give me the coordinates of each location in the file.

POSTED BY: Edward R

This type of question is usually require API access. In Wolfram Language you can handle this with

In[3]:= WolframAlpha["tokyo", {{"Location:CityData", 2}, "ComputableData"}, PodStates -> {"Location:CityData__Show coordinates"}]
Out[3]= GeoPosition[{35.67, 139.77}]

If you know how to work with python, you can follow this link to call W|A and extract data via API.

This link shows how to get the above WL query.

POSTED BY: Shenghui Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract