Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
traffic_dataproc/nb_005_processing-regions.ipynb
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
65 lines (65 sloc)
1.63 KB
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"from math import floor, ceil\n", | |
"from matplotlib import path\n", | |
"\n", | |
"def process_line(line):\n", | |
" # Not sure what these values are\n", | |
" val1 = line[0]\n", | |
" val2 = line[1]\n", | |
" polyline = [float(v) for v in line[2:]]\n", | |
" polyline = np.array(list(zip(polyline[0::2], polyline[1::2])))\n", | |
" return val1, val2, polyline \n", | |
"\n", | |
"with open(\"./DataForUConn/DecideRegion/area.txt\") as f:\n", | |
" area = [process_line(line.split(\",\")) for line in f.read().strip().split(\"\\n\")]\n", | |
"\n", | |
"polypaths = [path.Path(line[2][1:]) for line in area]\n", | |
"\n", | |
"def point_to_rids(point, polypaths=polypaths, radius=0.0):\n", | |
" RIDs = []\n", | |
" for rid, polypath in enumerate(polypaths):\n", | |
" if polypath.contains_point(point, radius=radius):\n", | |
" RIDs.append(rid)\n", | |
" \n", | |
" return RIDs" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |