Created
April 4, 2021 11:26
-
-
Save lmeulen/f51344abfe4939d06de52e0b0e178e80 to your computer and use it in GitHub Desktop.
crowdedness_create_features
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
features=[] | |
for rn in timedata.ritnumber.unique(): | |
total_trip = timedata[timedata.ritnumber == rn].dropna() | |
for sq in total_trip.sequence.unique(): | |
trip = total_trip[total_trip.sequence == sq] | |
tripfirst = trip.iloc[0] | |
triplast = trip.iloc[-1] | |
name = str(tripfirst["ritnumber"]) + " : " + tripfirst["stop_code"] + \ | |
" - " + triplast["stop_code"] | |
ls = LineString(trip[['lon', 'lat', 'elevation', 'timestamp']]. \ | |
to_numpy().tolist()) | |
features.append( | |
Feature(geometry=ls , | |
properties=dict(label=str(tripfirst["ritnumber"]), | |
name=name, | |
capacity=str(tripfirst["seats"]), | |
passengers=str(tripfirst["passengers"]), | |
crowding=str(tripfirst["classification"]))) | |
) | |
with open('trainpag.geojson', 'w') as outfile: | |
dump(FeatureCollection(features), outfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment