Created
August 10, 2017 16:53
-
-
Save chambbj/d2b38485dfc4ba3e8463ffc894408838 to your computer and use it in GitHub Desktop.
Searching Near a Point
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": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"X 512766.940\n", | |
"Y 5403705.460\n", | |
"Z 356.865\n", | |
"dtype: float64\n" | |
] | |
} | |
], | |
"source": [ | |
"med = samp11[['X','Y','Z']].median()\n", | |
"print(med)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[ 0.6213091 1.37645378 1.51757207]\n" | |
] | |
} | |
], | |
"source": [ | |
"from scipy import spatial\n", | |
"tree = spatial.cKDTree(samp11[['X','Y','Z']])\n", | |
"dists, idx = tree.query(med, k=3)\n", | |
"print(dists)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>X</th>\n", | |
" <th>Y</th>\n", | |
" <th>Z</th>\n", | |
" <th>Intensity</th>\n", | |
" <th>ReturnNumber</th>\n", | |
" <th>NumberOfReturns</th>\n", | |
" <th>ScanDirectionFlag</th>\n", | |
" <th>EdgeOfFlightLine</th>\n", | |
" <th>Classification</th>\n", | |
" <th>ScanAngleRank</th>\n", | |
" <th>UserData</th>\n", | |
" <th>PointSourceId</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>31897</th>\n", | |
" <td>512767.16</td>\n", | |
" <td>5403706.02</td>\n", | |
" <td>357.02</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0.0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31881</th>\n", | |
" <td>512767.93</td>\n", | |
" <td>5403706.29</td>\n", | |
" <td>356.39</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0.0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31972</th>\n", | |
" <td>512765.75</td>\n", | |
" <td>5403706.19</td>\n", | |
" <td>356.27</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0.0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" X Y Z Intensity ReturnNumber \\\n", | |
"31897 512767.16 5403706.02 357.02 1 1 \n", | |
"31881 512767.93 5403706.29 356.39 1 1 \n", | |
"31972 512765.75 5403706.19 356.27 1 1 \n", | |
"\n", | |
" NumberOfReturns ScanDirectionFlag EdgeOfFlightLine Classification \\\n", | |
"31897 1 0 0 0 \n", | |
"31881 1 0 0 0 \n", | |
"31972 1 0 0 0 \n", | |
"\n", | |
" ScanAngleRank UserData PointSourceId \n", | |
"31897 0.0 0 0 \n", | |
"31881 0.0 0 0 \n", | |
"31972 0.0 0 0 " | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"samp11.iloc[idx]" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.12" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment