In [1]:
import os,sys,inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
import loadOSCdata
import pandas as pd
import numpy as np
import geopandas as gpd
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
data = loadOSCdata.downloadData(OSCid=367385, X = True, Y = True, Z = True, output = 'csv', outputFile = 'data.csv')
data.head()
Out[2]:
In [3]:
bufers = gpd.read_file('../data/nyc-bike-routes/nyc_bike_30mbuffer_epsg=3857.shp')
bikelanes=gpd.read_file('../data/nyc-bike-routes/nyc_bike_routes_2017.shp')
In [4]:
pointsDF = loadOSCdata.snapToBikelane(bikelaneDF = bikelanes, bufersDF = bufers, pointsDF = data)
pointsDF.head()
Out[4]:
In [5]:
#pointsDF['original_x'] = pointsDF.geometry.map(lambda coord: coord.x)
In [6]:
pointsDF.head()
Out[6]:
In [8]:
(~pointsDF.geometry.isnull()).sum()
Out[8]:
In [ ]:
'''
pointsDF.timestamp = pointsDF.timestamp.map(lambda x: str(x))
point = pointsDF.drop(['line','pointOnLine'],axis=1)
point = point.to_crs(epsg=4326)
point.to_file('point')
line = pointsDF.drop(['geometry','pointOnLine','image_lab'],axis=1)
line.columns = [u'timestamp', u'point_id', u'v_value', u'image_url',
u'trip_id', u'geometry', u'bikelanesID']
line = line.dropna().to_crs(epsg=4326)
line.to_file('line')
newPoint = pointsDF.drop(['geometry','line','image_lab'],axis=1)
newPoint.columns = [u'timestamp', u'point_id', u'v_value', u'image_url', u'trip_id',
u'bikelanesID', u'geometry']
newPoint = newPoint.dropna().to_crs(epsg=4326)
newPoint.to_file('newPoint')
newPoint.head()
'''
In [ ]:
In [ ]:
In [ ]: