How can I retrieve a school name from a CSV file using latitude from the same row?

0
11
Asked By CuriousCoder42 On

I'm working on a school finder project where I need to locate the nearest school based on a user's coordinates (latitude and longitude). I've successfully converted Eastings and Northings to latitude and longitude using the pyproj library. Now, I've managed to find the nearest latitude, but I'm struggling to get the 'EstablishmentName' from the CSV file corresponding to this latitude. I'm currently looping through the dataframe but can't figure out how to identify the correct row to retrieve the school's name. Any ideas on how to achieve this?

2 Answers

Answered By DataGuru88 On

It might be more effective to calculate the distance between your user's coordinates and all the schools' coordinates instead of just matching latitude directly. You can store each school along with its distance to the user in a list, sort this list by distance, and then easily retrieve the nearest school. This way, you'll have a reliable method to find the school's name based on proximity.

Answered By CodeWhisperer92 On

If you still want to use the latitude directly, you would have to search through your DataFrame again to find the matching entry. Instead of checking if 'nearest_latitude' is in the row, consider directly comparing it to the latitude column. A suggestion might be to calculate a unique distance score using both latitude and longitude to determine proximity.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.