Is there anyway that I can get Matlab to tell me a location based on the input of GPS coordinates? So, for example, if I gave it the coordinates (42.3899, -89.0366), how can I get Matlab to tell me that that's Roscoe, Illinois?
MATLAB: Get location from GPS coordinates
coordinatesgpslocation
Related Solutions
To do this in an automated where you click on a map point and a coordinate appears in MATLAB in real time would require a massive undertaking. I suggest 2 work arounds:
1) When you click a point in Google Maps, its location will pop up at the bottom in a rectangular window. Use screen capture, then process that image to extract the coordinates. Screenshot using MATLAB
2) Use Google Earth instead and save the points you selected into a KML file. Then write a MATLAB script that grabs the KML file and processes it. This should help a little.
There are several solutions, depending the amount of data that you have to process, the time that you are willing to spend on coding, the time that you can afford spending on processing data, etc. You have two main options (there might be newer tools that I am not aware of though):
1. You can use e.g. a dataset of cities with their coordinates (Shapefile, Excel file, DBF file, etc), and just look for the minimal distance between a point and cities locations. This has the advantage that it is fast and local (no internet), but the disadvantage that you probably won't find a dataset with finer information than significant town/cities. You might also need to buy a license for using "high quality" datasets (I don't know if you could use ESRI datasets without a license for example). EDIT: here are a few relevant links:
- ESRI Data and Maps (your university/company might have a site license for ArcGIS and DVDs for Data and Maps).
- Boutell Zip/Lat/Lon Database: here.
- Another "similar" here.
- GeoNames, that could be placed in the next category of solutions, but their data is available here as text files.
2. You can use some online service/API and manage sending requests and processing responses (XML, etc). This has the disadvantage that it requires an internet connection and that sending/processing requests/responses can be time consuming, especially if you have a limited access to the API (number/rate of requests). It has the advantage though that you can get much more information, because APIs can give you access to very large databases (e.g. Google). Here are a few relevant links:
- https://developers.google.com/maps/documentation/geocoding/?csw=1
- Example with your coordinates: http://maps.googleapis.com/maps/api/geocode/json?latlng=42.3899,-89.0366&sensor=true
FEX (untested, because I usually build my own tools on this matter):
- http://www.mathworks.com/matlabcentral/fileexchange/24126-google-geocode-api
- http://www.mathworks.com/matlabcentral/fileexchange/22565-yahoo-geocode-api
EDIT: to illustrate the issue with local datasets, here is the ESRI Data&Maps 9.3 dataset of 3557 cities. As you can see, if you have locations in e.g. Alaska, Montana, Nevada, chance is that the closest city will be quite far according to this dataset..
Best Answer