Home » Php » PHP/MySQL List of university coordinates

PHP/MySQL List of university coordinates

Posted by: admin July 12, 2020 Leave a comment

Questions:

I am trying to get the user’s coordinates and get a short list of the nearest universities in the area.

So my initial thoughts were to populate my own MySQL with a heck of a lot of universities and coordinates, so I can use a searching algorithm to match the closest handful of universities with the data in my database.

Is that realistic to accomplish? To find a list of all universities, I have looked at: this question, and when I went to the site, it seemed like the files were exported as .uid? I’m not sure how to deal with this. Also, if I have a list of universities, how can I get the coordinates of them? Would geocoder work? If it’s possible I would also like a list of high schools, but ignore that for now.

What do you think? Am I missing something? Is there a more efficient way to get a list of the closest universities to a user?

How to&Answers:

If you have the list of all universities with its address, you can use The Google Geocoding API https://developers.google.com/maps/documentation/geocoding/ to retrieve the coordinates. You can write a script that fill a table of a database with the information.

Edit:

I’ve found this site: http://www.a2zcolleges.com/address_phone/addressindex.htm, perhaps it may help.

Answer:

Have you tried looking at the Google Maps API? Perhaps you could do a search for universities, then parse the results.

Looks like you could do a Place Search, then use a Place Type of university.

Answer:

could you get away with just the latitude/longitude of the city a university is in, or is this for a local search where +/- a mile or 2 matters? Maxmind offers a free database of city coordintates you could cross reference against a list of universities by city

Maxmind world cities

Edit

Here is a list of US zipcode long/lat coordinates you can use to cross reference with the university address csv database link I posted in the comment above. If you need international mailing codes, they have several good links on the maxmind postal codes section

US Zip Codes

Answer:

The Google Geocoding API has usage limits, I believe. I have retrieved geo coordinates for colleges in bulk in two ways. The first is complicated and only mentioned for posterity.

(1) This way uses a very circuitous process that involves OpenRefine (http://openrefine.org/) — formerly Google Refine. It needs Java on your computer (Windows, Mac, Linux) to run. But because this is complex, all I’m going to say is that you need to:

  • (a) add the dbpedia.org reconciliation service in OpenRefine;
  • (b) run a reconciliation on your colleges list using the schema
    dbo:university;
  • (c) retrieve the dbpedia url from the reconciled column;
  • (d) convert the url to the .json version;
  • (e) run a “fetch urls” using the .json URLs;
  • (f) Parse the results for the coordinates using the GREL functions
    built-in (or Jython).

You can see how circuitous it is, but it suits me because I use OpenRefine daily.

(2) The less circuitous route is to run a SPARQL query directly on dbpedia.org using your colleges list. However, SPARQL is an acquired taste, with potentially confusing syntax. I had to do a lot of reading and hit-and-miss testing before getting it right.

Now, just to tie this altogether, dbpedia.org is the structured equivalent of wikipedia.org. You might sneer at that, but when it comes to college / university entries, some of the basic information is usually very accurate — and that includes geo coordinates, established date, location, website, etc.