2

I am using version 3.0 of python, I want to visualize GPS points in my dataset on interactive map. Is there any python library that can help me to visualize my data on maps.

The input dataset in given in the link https://drive.google.com/file/d/1JjvS7igTmrtLA4E5Rs5D6tsdAXqzpYqX/view

Three lines of the dataset:

lat,long,tep,ht,altitude,date,time,userid,date_time,Transportation_Mode,time_delta,trip_id,segmentid,Vincenty_distance,velocity,acceleration,jerk
39.97954667,116.3068133,0,0,40784.42587,8/29/2011,10:13:15,141,8/29/2011 10:13,walk,1,1,1,1.551676553,1.551676553,0.550163852,-1.017629555
39.97955833,116.3068233,0,0,40784.42588,8/29/2011,10:13:16,141,8/29/2011 10:13,walk,1,1,1,2.101840405,2.101840405,-0.467465704,0.732307066
  • Although I'm beginner here but my question was too specific so that I got the right answer by Mr. Kadir, I was looking for some library and tutorials that can serve my purpose. – Asif Khan Aug 7 '18 at 15:36
3

You can visualize your data on a map using folium. Please visit Documentation. (You must also have/install jupyter package. Installing Jupyter Notebook)

Then this script displays your data on an interactive map:

import pandas as pd
import folium

map_ = folium.Map(location=[40.13, 116.25], zoom_start=10)
df = pd.read_csv("PATH/YOUR/FILE/user141.csv") # edit path

locs = df[['lat', 'long']]
loc_list = locs.values.tolist()

# To display all data use the following two lines, but, since your data has
# so many points, this process will be time-consuming.
for point in range(0, len(loc_list)):
    folium.Marker(loc_list[point]).add_to(map_)

# To display first 1000 points
# for point in range(0, 1000):
#     folium.Marker(loc_list[point]).add_to(map_)

map_

enter image description here

Please also review Mapping Points with Folium.

  • It works good for limited set of points, but I need to display all points for analysis purpose. The given data is for one user only, but in actual, total dataset contains more than 100 users and a total number of points exceeds one million. – Asif Khan Aug 7 '18 at 4:32
  • It works actually for all points. I just set to display first 1000 points. I edited the code to display all points. – Kadir Şahbaz Aug 7 '18 at 16:25
  • yes it was working but very slow and didn't display the result even after an hour. Is there any other alternative for that like shape file that can process it quickly? – Asif Khan Aug 8 '18 at 3:03
1

Simplekml can create a kml file from a Pandas dataframe in four lines:

import simplekml
kml = simplekml.Kml()
df.apply(lambda X: kml.newpoint(name=X["name"], coords=[(                                     
X["longitude"],X["latitude"])]) ,axis=1)
kml.save(path = "data.kml")

Link

  • How can it help me to visualize GPS points? – Asif Khan Aug 7 '18 at 4:28
  • 1
    The code creates a kml file, that you can view on Google Earth, using a data frame (Pandas) defined in the code as df. – icypy Aug 10 '18 at 4:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.