-1

Hello I am currently working on a project revolving data frames and GPS coordinates in these data frames. I am currently trying to create a heat map based on the most common GPS values inside of my dataframe. I have so far made code that gives the most common values in a list that is structured as followed:

['(58.691025, 11.850659)', '(58.692577, 11.850225)', '(58.693832, 11.850458)', '(58.692238, 11.850263)', '(58.69257, 11.850225)', '(58.692585, 11.861971)', '(58.69313, 11.850346)', '(58.692593, 11.861978)', '(58.6927, 11.863436)', '(58.692448, 11.862158)']

As you can see, the list contains a series of GPS coordinates around the same area. However, I am using the gmaps package in order to get this gps data into a heatmap, and when importing gps data from a list into gmaps you use the following:

heatmap = gmaps.heatmap_layer(locations)

With the list structure:

locations = [(46.1, 5.2), (46.2, 5.3), (46.3, 5.4)]

As you can see my list and this structure does not match and therefore does not work in the gmaps line.

So, what I am trying to accomplish is to further convert my list into the same structure and type as the one above.

Is there any way to do this? Thank you in advance!

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252

1 Answers1

-1

Even simpler solution would be this:

coords = ['(58.691025, 11.850659)', '(58.692577, 11.850225)', '(58.693832, 11.850458)', '(58.692238, 11.850263)', '(58.69257, 11.850225)', '(58.692585, 11.861971)', '(58.69313, 11.850346)', '(58.692593, 11.861978)', '(58.6927, 11.863436)', '(58.692448, 11.862158)']

locations = [eval(c) for c in coords]

print(locations)
mbostic
  • 903
  • 8
  • 17