# Finding best representative point in a group of latitudes and longitudes

71
April 06, 2022, at 12:40 PM

I have a cluster of 10 Latitudes and Longitudes. I want to find the optimal location to do set up a lemonade stand.

So in other words, I need to find the best representative point of the group of latitudes and longitudes.

I’m aware of how to find the centroid (center), but I don’t necessarily want the centroid.

I just want to find what point (latitude, longitude) is best representative of the cluster.

Im a beginning python learner, so I’m having a little trouble finding some approaches. I’d really appreciate it if someone can link sources or name some methods as to how I can do this.

Centroid is basically average of your latitudes and longitudes so the easiest way to find one is by

``````latsum = sum(latitudes)
lonsum = sum(longitudes)
centroid = (latsum/len(latitudes) , lonsum/len(longitudes))
``````

The sum function does what it says and the len function gives you the length of list which in your case is 10. Since you mentioned that the best representative is what you need, you might need to clear out any outliers in your data.

https://machinelearningmastery.com/how-to-use-statistics-to-identify-outliers-in-data/

This is a good resource for you to start understanding making data science operations in python.

POPULAR ONLINE

### Changing python list size during iteration. Is it okay?

Above is simple code changes list size during iterating itself

79

### Django: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)

I'm trying to email using Python's smtplibThis is the email() function:

89

### Average using loops

Anyone know how to rearrange this code so that when the values that are inputted are 3 4 8 4 , the average is 475

53

### I think it's a basic question but I don't get why I get 0 in this function

I'm wondering why I get 0 for the print(a) call in the last lineI put 0 for the first loop of the add()function and it should return 1 and so on in the for loop

74