Get Low Consumption within 100m Radius?

Asked

Viewed 77 times

0

I have a database with consumption and coordinates in Excel, like:

Consumo e Coordenada

In this sense, I need to write a code that allows me to find, from place to place, consumptions below the average consumption within a radius of 100m. The 100m radius is intended to be calculated not once, but for each pair of coordinates.

code used:

R9 = []
R9_NaN = []

for index, row in df.iterrows():
    coord_1 = (row['X'], row['Y'])
    for index, row in df.iterrows():
        coord_2 = (row['X'], row['Y'])
        if coord_2 != coord_1:
            dist = geopy.distance.geodesic(coord_1, coord_2).km
            if dist <= 0.100:
                média=sum((row['Consumo2018']/12)/(len(coord_2)+1))
                if row['Consumo2018']/12 < 1.5*média:
                    R9_NaN.append(index)
                    R9.append(0)
                else:
                    R9.append(0)

print(R9)

geopy.Distance is a library that already calculates the distance between two coordinates.

In the code above; the "average" is supposed to be the average consumption of places within the radius of 100m which should also vary from place to place.

You’re making this mistake:

Typeerror: 'float' Object is not iterable

  • You already have some code or a table that you can, through the coordinates find out how far in M from one coordinate to another ?

  • I have the mathematical formula to figure this out but not the python code, although it is very easy to understand this java code and all the methods used you find inside the python Math library. https://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java

  • to find out how far in M from one coordinate to the other use the geopy bookstore.

  • You are calling the function sum passing only a numerical value as a parameter. It doesn’t make much sense to add only one number. If you already have the 2018 consumption and the number of records, wouldn’t the average be just the division? What do you need to add here?

  • here it is only supposed to add up the consumptions of the places within the radius of 100m; I am using the Row, in the purpose that it makes the sum of all these values...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.