Python判断坐标点在五环线以内

爬取高德地图五环坐标数据

import requests
import json
def get_coordinates(name="五环"):url = "https://www.amap.com/service/poiInfo"querystring = {"query_type":"TQUERY","pagesize":"20","pagenum":"1","qii":"true","cluster_state":"5","need_utd":"true","utd_sceneid":"1000","div":"PC1000","addr_poi_merge":"true","is_classify":"true","zoom":"10.59","city":"110000","geoobj":"115.714446|39.806938|117.024755|40.037228","keywords":name}# cookie 必须填写,使用自己的既可以headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0",'Cookie': "cna=HGKwG2zeNAUCAbfyL9r25+N+; guid=f342-dfba-e71a-24ba; isg=BH19BEYlwsuqzmY_D1YaPAvqjNl3GrFsLu4XXz_C6FQDdpyoB2vxPGNkJKowdskk; l=eBSEG5GVTsf6NjtDKOfZFurza779TIRVguPzaNbMiOCP_45y5FCfW6ykUwT2CnGVHsTwR3-T6YgYBWYHTyCqaM70eyIAhKHmnwC..; oauth_state=b8297a9720a5d341ee8e0b0fe40bcd26; passport_login=NjM3OTk4Mjg4LGFtYXBfMTg1MDA2ODY0NTJDMnZSQWFwc0sscnVncWJ4cnB0ZGE3NmhsNmpuem9obzJqMzNxbWtsbXosMTY2NjY2ODE1NSxNall6WkRNNU4yTmxNV1l4WlRaaE56ZGpZemt6WVdVM1pXTXpaR0kxT0dRPQ%3D%3D; tfstk=cX2lBuZPn7l7qq6LlzM5Cx01vPUhZN9ESJyb3icwb3pnvl2Vi2A2_xgdm4b1zB1..; xlly_s=1; _uab_collina=166667906108871325514159; x-csrf-token=48f6a576ead3218f0a65a79256d305dd; x5sec=7b227761676272696467652d616c69626162612d616d61703b32223a223731356433633561373530666461636465316433396331633735626465663234434b694333706f47454a69687635445039363232494444656c35757041304144227d;dev_help=cjtdLgiHm4%2FlzXo9RB0Cm2U1MzhjYWRhMmFhZjk0MTZkZWNkNDZiMjAyZWM2NzEwNmVkMTAzMWVmYmFjMDZiMmMxZWVkMmY1ZDVhY2IxZTixcHpgx7qPlBVNEkxz6HY6%2BINj37titG%2BJ6muxw82%2BoxQF5rg2BMJr3SDJ0XLc%2F7a1rS5GE4ygNKfI2YtZ8to%2FreMW2VnUEFuvZrGdx0hJOBGuvpM6jtl%2FAbLxfq31Wp05WJzuMai1vkwwJmgfdU8v;gray_auth=2"}response = requests.request("GET", url, headers=headers, params=querystring)print(response.text)data=json.loads(response.text)['data']['poi_list'][0]['domain_list'][3]['value']print(data)results=[]for ddd in data.replace('|','_').split('_'):results.append([float(ddd.split(',')[1]),float(ddd.split(',')[0])])return results

五环坐标数据

results=[[39.817829, 116.499994], [39.819416, 116.504384], [39.822015, 116.51134], [39.822675, 116.512705], [39.823293, 116.513761], [39.824444, 116.51539], [39.830318, 116.523247], [39.831286, 116.524607], [39.833475, 116.52749], [39.836135, 116.531104], [39.84648, 116.544942], [39.847563, 116.546328], [39.848586, 116.547435], [39.849167, 116.547927], [39.849979, 116.548501], [39.850778, 116.548934], [39.85137, 116.549199], [39.852585, 116.549529], [39.853769, 116.549656], [39.854415, 116.549648], [39.8559, 116.549506], [39.862323, 116.548319], [39.863539, 116.548169], [39.864393, 116.548124], [39.865605, 116.548134], [39.866407, 116.54819], [39.871106, 116.548718], [39.874372, 116.54893], [39.880726, 116.548868], [39.883066, 116.548773], [39.8856, 116.548511], [39.892606, 116.547615], [39.894973, 116.547197], [39.906131, 116.544942], [39.9088, 116.544463], [39.911365, 116.544112], [39.913224, 116.543913], [39.915205, 116.543757], [39.937701, 116.542412], [39.939088, 116.542262], [39.940227, 116.54201], [39.941269, 116.541685], [39.942464, 116.541167], [39.943695, 116.540476], [39.944479, 116.539934], [39.945426, 116.539169], [39.94633, 116.538379], [39.950367, 116.534459], [39.951432, 116.533492], [39.952467, 116.532638], [39.953285, 116.532052], [39.954403, 116.531338], [39.955325, 116.530813], [39.956746, 116.530116], [39.964402, 116.526898], [39.966161, 116.526108], [39.969087, 116.524593], [39.971476, 116.523155], [39.973003, 116.522119], [39.975237, 116.520478], [39.981333, 116.51564], [39.98864, 116.509914], [39.98982, 116.50895], [39.991786, 116.507216], [39.993929, 116.505201], [39.996216, 116.502909], [40.003477, 116.495869], [40.011254, 116.488242], [40.011907, 116.487472], [40.012487, 116.486687], [40.013443, 116.485084], [40.01385, 116.484191], [40.014331, 116.482926], [40.014639, 116.481832], [40.014987, 116.480191], [40.015165, 116.478569], [40.015203, 116.477477], [40.015232, 116.472629], [40.015243, 116.462642], [40.015286, 116.461044], [40.015525, 116.458987], [40.016008, 116.45707], [40.017474, 116.452003], [40.017582, 116.451795], [40.021291, 116.439271], [40.021812, 116.436766], [40.022057, 116.43448], [40.022126, 116.432412], [40.02232, 116.420747], [40.022728, 116.390419], [40.023149, 116.353905], [40.023293, 116.337954], [40.023205, 116.336275], [40.023046, 116.335203],
[40.022754, 116.333936], [40.020567, 116.327049], [40.019599, 116.323443], [40.019203, 116.321601], [40.018726, 116.319075], [40.01722, 116.308968], [40.016903, 116.307233], [40.015197, 116.300609], [40.014897, 116.299243], [40.014649, 116.297595], [40.012434, 116.278587], [40.01213, 116.276525], [40.011933, 116.275711], [40.011635, 116.274887], [40.011264, 116.274107], [40.010687, 116.27321], [40.010042, 116.272478], [40.009436, 116.271972], [40.009015, 116.271693], [40.006945, 116.270506], [40.006486, 116.2702], [40.005849, 116.269667], [40.005479, 116.269301], [40.004701,
116.268269], [40.004186, 116.267331], [40.003838, 116.266462], [40.003524, 116.265333], [40.00321, 116.263126], [40.003113, 116.261441], [40.002853, 116.253675], [40.002747, 116.251597], [40.002567, 116.249963], [40.002342, 116.248738], [40.00203, 116.247567], [40.001732, 116.246675], [40.001111, 116.245113], [39.99933, 116.240986], [39.998825, 116.239684], [39.998501, 116.238643], [39.998263, 116.237708], [39.997958, 116.236189], [39.996878, 116.22994], [39.996434, 116.228008], [39.996154, 116.227096], [39.995814, 116.22619], [39.995397, 116.225314], [39.994944, 116.224548], [39.994306, 116.22369], [39.993369, 116.222715], [39.992561, 116.222112], [39.991561, 116.221588], [39.991239, 116.221465], [39.990244, 116.221213], [39.989658, 116.221109], [39.98819, 116.221016], [39.983716, 116.221016], [39.982327, 116.220979], [39.98081, 116.220897], [39.979003, 116.220716], [39.977649, 116.220548], [39.976512, 116.220352], [39.971288, 116.219336], [39.969768, 116.219106], [39.963499, 116.217938], [39.963152, 116.217877], [39.95277, 116.215942], [39.950934, 116.215585], [39.950148, 116.215365], [39.949269, 116.215047], [39.948312, 116.214574], [39.94602, 116.213126], [39.945105, 116.212613], [39.944292, 116.212271], [39.943405, 116.211995], [39.942147, 116.211779], [39.941148, 116.21173], [39.940366, 116.211737], [39.928194, 116.212095], [39.925178, 116.212111], [39.922976, 116.212004], [39.921265, 116.211871], [39.916407, 116.21127], [39.914511, 116.211072], [39.911803, 116.210944], [39.895209, 116.211048], [39.891897, 116.211274], [39.890614, 116.211264], [39.889332, 116.211088], [39.888344, 116.210805], [39.887136, 116.21031], [39.885192, 116.209411], [39.883646, 116.208752], [39.882052, 116.208222], [39.880811, 116.207953], [39.879427, 116.207783], [39.878518, 116.207744], [39.877794, 116.207767], [39.87688, 116.207843], [39.875924, 116.207998], [39.874292, 116.208416], [39.87262, 116.209098], [39.871915, 116.209456], [39.870477, 116.210308], [39.867218, 116.21269], [39.85917, 116.218832], [39.857964, 116.219591], [39.85716, 116.219953], [39.856334, 116.220212], [39.855251, 116.220429], [39.851551, 116.221001], [39.850238, 116.221343], [39.849283, 116.22176], [39.848665, 116.222106], [39.847933, 116.222614], [39.847203, 116.223221], [39.842137, 116.227999], [39.841103, 116.229036], [39.839045, 116.231344], [39.838388, 116.232027], [39.837775, 116.232572], [39.836102, 116.233929], [39.834906, 116.234988], [39.834572, 116.235329], [39.833885, 116.236218], [39.833586, 116.236694], [39.833094, 116.237651], [39.832626, 116.238948], [39.83142, 116.243435], [39.830774, 116.245342], [39.830217, 116.246458], [39.829798, 116.247101], [39.829141, 116.24793], [39.828229, 116.248844], [39.827607, 116.249393], [39.815824, 116.259618], [39.814019, 116.261146], [39.812526, 116.262291], [39.811034, 116.263265], [39.80994, 116.26385], [39.808953, 116.264296], [39.807389, 116.264838], [39.806202, 116.265119], [39.804752, 116.265352], [39.802409, 116.265551], [39.800393, 116.265653], [39.7993, 116.265748], [39.798324, 116.265901], [39.79716, 116.266168], [39.795985, 116.266541], [39.786792, 116.269823], [39.782428, 116.271441], [39.781342, 116.2719], [39.779926, 116.272629], [39.778952, 116.273241], [39.778384, 116.273647], [39.777733, 116.27419], [39.777091, 116.274801], [39.77637, 116.275645], [39.775602, 116.276751], [39.77511, 116.277634], [39.774563, 116.27886], [39.774129, 116.280172], [39.773825, 116.281545], [39.773678, 116.282479], [39.773577, 116.283589], [39.773556, 116.284717], [39.773594, 116.285502], [39.773736, 116.286795], [39.773983, 116.288066], [39.774218, 116.289033], [39.774688, 116.290457], [39.775261, 116.291847], [39.77568, 116.29274], [39.776839, 116.29496], [39.779318, 116.299331], [39.779899, 116.300427], [39.780466, 116.301597], [39.78087, 116.302539], [39.781289, 116.303874], [39.781584, 116.305205], [39.781741, 116.306413], [39.78179, 116.307305], [39.78179, 116.308708], [39.781597, 116.311055], [39.77961, 116.327783], [39.779342, 116.330543], [39.778648, 116.341975], [39.777497, 116.363894],
[39.777378, 116.365448], [39.777179, 116.367014], [39.777001, 116.367865], [39.776621, 116.369072], [39.776417, 116.369536], [39.775892, 116.370525], [39.775419, 116.371205], [39.774682, 116.37202], [39.773739, 116.372735], [39.773051, 116.373102], [39.771789, 116.373585], [39.770624, 116.373874], [39.763443, 116.375436], [39.762464, 116.375704], [39.761633, 116.37602], [39.761141, 116.376264], [39.760681, 116.376569], [39.759995, 116.377147], [39.759336, 116.377928], [39.758838, 116.378765], [39.758506, 116.379536], [39.75822, 116.380493], [39.758038, 116.381659], [39.75799, 116.382627], [39.75812, 116.384178], [39.758263, 116.385034], [39.764408, 116.41114], [39.764826, 116.412667], [39.765398, 116.414435], [39.766206, 116.416331], [39.766621, 116.417185], [39.767454, 116.418539], [39.768434, 116.419838], [39.768937, 116.42041], [39.76954, 116.420992], [39.770538, 116.421838], [39.771715, 116.422642], [39.772968, 116.423325], [39.774588, 116.424066], [39.77937, 116.425997], [39.78117, 116.426878], [39.782671, 116.427749], [39.783273, 116.428142], [39.784193, 116.428845], [39.785471, 116.429999], [39.785981, 116.430534], [39.786744, 116.431462], [39.78725, 116.432151], [39.787878, 116.433121], [39.788283, 116.433812], [39.788968, 116.435229], [39.789287, 116.435987], [39.789727, 116.437203], [39.789951, 116.437944], [39.790274, 116.439274], [39.790605, 116.441122], [39.790829, 116.443214], [39.79094, 116.445835], [39.790918, 116.448341], [39.790738, 116.454128], [39.790778, 116.4562], [39.790915, 116.457511], [39.79117, 116.458844], [39.791453, 116.459873], [39.792106, 116.461547], [39.792648, 116.462599], [39.792941, 116.463069], [39.793535, 116.463925], [39.794458, 116.465], [39.796014, 116.466556], [39.808336, 116.478279], [39.809279, 116.479266], [39.81019, 116.480459], [39.810811, 116.481458], [39.811321, 116.482448], [39.812048, 116.484218], [39.817829, 116.499994], [39.817991, 116.500007], [39.821922, 116.510702], [39.82223, 116.511463], [39.822772, 116.51258], [39.823637, 116.513996], [39.824961, 116.515832], [39.830899, 116.523754], [39.834519, 116.528679], [39.846901, 116.545237], [39.847833, 116.546396], [39.84825, 116.546843], [39.84898, 116.547536], [39.849545, 116.547984], [39.850685, 116.548704], [39.851648, 116.54912], [39.852794, 116.549384], [39.853776, 116.549511], [39.85497, 116.549452], [39.855921, 116.549313], [39.862427, 116.548143], [39.864522, 116.547912], [39.865417, 116.547916], [39.866296, 116.547979], [39.8718, 116.548598], [39.8744, 116.548754], [39.881448, 116.548672], [39.883979, 116.548526], [39.891884, 116.547548], [39.893962, 116.547233], [39.905417, 116.544896], [39.90872, 116.544306], [39.910891, 116.543997], [39.913185, 116.543711], [39.916125, 116.543517], [39.937476, 116.542254], [39.938708, 116.542104], [39.940043, 116.541854], [39.941214, 116.541486], [39.94233, 116.541034], [39.943302, 116.540515], [39.943841, 116.540177], [39.944428, 116.539761], [39.945365, 116.539009], [39.946325, 116.538146], [39.948985, 116.535564], [39.951347, 116.53334], [39.952287, 116.532562], [39.953574, 116.531656], [39.955269, 116.530642], [39.956635, 116.529972], [39.965463, 116.526239], [39.967445, 116.525268], [39.96902, 116.52443], [39.971407, 116.522983], [39.972956, 116.521945], [39.975239, 116.520271], [39.977081, 116.518833], [39.97908, 116.517215], [39.989245, 116.509187], [39.990987, 116.507726], [39.992843, 116.506017], [39.99611, 116.502769], [39.99981, 116.499192], [40.011068, 116.488146], [40.011776, 116.487343], [40.012259, 116.486688], [40.012802, 116.485822], [40.013341, 116.484835], [40.0138, 116.483816], [40.014329, 116.482297], [40.014469, 116.481797], [40.014736, 116.480484],
[40.014942, 116.479148], [40.01503, 116.477403], [40.015076, 116.470463], [40.015073, 116.462769], [40.015126, 116.461016], [40.015359, 116.459175], [40.015737, 116.457448], [40.017935, 116.449911], [40.02, 116.443103], [40.021139, 116.4392], [40.02143, 116.43801], [40.021611, 116.437073], [40.021896, 116.43476], [40.021977, 116.4328], [40.022131, 116.423648], [40.022345, 116.406118],
[40.02251, 116.396206], [40.022839, 116.366075], [40.022948, 116.359259], [40.02299, 116.349839], [40.023095, 116.344345], [40.023159, 116.338015], [40.02312, 116.336938], [40.023043, 116.336139], [40.022748, 116.334453], [40.022399, 116.333246], [40.020678, 116.327869], [40.020076, 116.325817], [40.019434, 116.323387], [40.018839, 116.320468], [40.018513, 116.31859], [40.017215, 116.309787], [40.016838, 116.307558], [40.016576, 116.306404], [40.01507, 116.30069], [40.014633, 116.298445], [40.014308, 116.295938], [40.012293, 116.278305], [40.012019, 116.27666], [40.011754, 116.275609], [40.011425, 116.274726], [40.010877, 116.273737], [40.010382, 116.273074], [40.009846, 116.272518], [40.00926, 116.272052], [40.00861, 116.271633], [40.007118, 116.270798], [40.006215, 116.270187], [40.005843, 116.269877], [40.005241, 116.26925], [40.004632, 116.268414], [40.004237, 116.267728], [40.003743, 116.266615], [40.003495, 116.265808], [40.003291, 116.264941], [40.003065, 116.26313], [40.002601, 116.251612], [40.002422, 116.250007], [40.002167, 116.248744], [40.001864, 116.247581], [40.001125, 116.245503], [39.999068, 116.240705], [39.998437, 116.238865],
[39.998144, 116.237752], [39.997856, 116.236348], [39.996759, 116.230056], [39.996498, 116.228836], [39.996115, 116.227433], [39.995837, 116.226643], [39.995358, 116.225503], [39.994848, 116.224665], [39.994216, 116.223805], [39.99373, 116.223276], [39.993404, 116.222981], [39.992723, 116.222437], [39.992231, 116.222129], [39.99169, 116.221863], [39.990889, 116.221554], [39.98997, 116.22134], [39.988654, 116.221209], [39.987944, 116.221184], [39.982566, 116.221142], [39.980398, 116.221031], [39.978868, 116.220874], [39.977643, 116.220709], [39.975305, 116.220304], [39.969765, 116.219244], [39.963432, 116.218095], [39.962996, 116.218013], [39.952739, 116.216123], [39.95129, 116.215833], [39.950064, 116.215515], [39.949108, 116.21514], [39.948395, 116.21477], [39.946404, 116.213541], [39.945055, 116.212787], [39.944216, 116.21245], [39.943557, 116.212239], [39.94254, 116.21202], [39.941622, 116.211944], [39.940713, 116.211921], [39.931959, 116.212152], [39.928032, 116.212301], [39.92433, 116.212267], [39.921168, 116.212031], [39.916401, 116.211437], [39.914541, 116.211242], [39.911491, 116.211095], [39.896086, 116.211217], [39.894204, 116.211272],
[39.892176, 116.211435], [39.890563, 116.211444], [39.889312, 116.211253], [39.888171, 116.21094], [39.887702, 116.210763], [39.884576, 116.209326], [39.883724, 116.208975], [39.882373, 116.208497], [39.880856, 116.208146], [39.879156, 116.207939], [39.878025, 116.207933], [39.8769, 116.208018], [39.87606, 116.208155], [39.875168, 116.208348], [39.874513, 116.208547], [39.873162, 116.20904], [39.871959, 116.209613], [39.871328, 116.20997], [39.870025, 116.210812], [39.86944, 116.211221], [39.859638, 116.218685], [39.85881, 116.219273], [39.858054, 116.219724], [39.857272, 116.22009], [39.856346, 116.220387], [39.855274, 116.220598], [39.851558, 116.22116], [39.850534, 116.221447], [39.849641, 116.221782], [39.849156, 116.222024], [39.848368, 116.222522], [39.847578, 116.223121], [39.845812, 116.224729], [39.842199, 116.228152], [39.838324, 116.232282], [39.834956, 116.235147], [39.83439, 116.235766], [39.833645, 116.236855], [39.833274, 116.237584], [39.832944, 116.238403], [39.832442, 116.240093], [39.831737, 116.242746], [39.831213, 116.244524], [39.830973, 116.245189], [39.830719, 116.245776], [39.830253, 116.246645], [39.829597, 116.247616],
[39.829203, 116.248091], [39.828477, 116.248816], [39.826718, 116.250377], [39.816804, 116.258979], [39.814529, 116.260933], [39.813228, 116.261975], [39.812546, 116.262472], [39.811074, 116.263437], [39.810127, 116.263936], [39.808953, 116.264475], [39.80787, 116.264865], [39.806251, 116.26529], [39.80504, 116.265485], [39.802407, 116.265728], [39.79935, 116.265914], [39.798353, 116.266069], [39.79746, 116.266268], [39.796134, 116.266673], [39.788313, 116.26947], [39.783361, 116.271254], [39.781756, 116.271899], [39.78051, 116.272499], [39.779621, 116.273032], [39.778079, 116.274183], [39.777461, 116.27473], [39.776559, 116.275648], [39.776372, 116.275895], [39.775832, 116.276667], [39.775234, 116.277716], [39.774691, 116.278907], [39.77427, 116.280216], [39.774023, 116.28123], [39.773774, 116.282823], [39.773691, 116.284174], [39.773729, 116.285583], [39.773878, 116.286877], [39.774154, 116.288236], [39.774334, 116.288923], [39.774853, 116.290483], [39.775353, 116.291713], [39.775822, 116.292742], [39.776643, 116.294342], [39.780016, 116.300316], [39.7805, 116.301276], [39.780921, 116.302255], [39.7813, 116.303366], [39.781636, 116.304663], [39.781819, 116.305734], [39.78194, 116.307456], [39.781904, 116.309227], [39.781726, 116.311216], [39.779686, 116.328581], [39.779414, 116.331671], [39.777658, 116.363917], [39.777479, 116.36617], [39.777392, 116.366802], [39.777182, 116.367866], [39.77679, 116.369087], [39.776352, 116.37006], [39.775887, 116.370858], [39.775403, 116.371496], [39.774811, 116.372132], [39.774142, 116.372692], [39.773747, 116.372954], [39.773063, 116.373317], [39.772563, 116.373531], [39.77133, 116.373913], [39.763428, 116.375617], [39.762851, 116.37577], [39.761878, 116.376117], [39.761251, 116.376421], [39.760675, 116.376797], [39.760127, 116.377253], [39.759401, 116.378114], [39.758954, 116.378905], [39.758544, 116.379901], [39.758305, 116.380805], [39.758233, 116.381205], [39.758143, 116.382571], [39.758219, 116.383719], [39.758415, 116.384967], [39.76033, 116.39326], [39.764545, 116.411086], [39.765012, 116.412792], [39.765522, 116.414353], [39.766316, 116.416242], [39.766643, 116.416892], [39.767217, 116.417906], [39.767579, 116.41845], [39.768532, 116.419705], [39.769207, 116.420439], [39.769845, 116.42105], [39.770599, 116.421673], [39.771682, 116.422414], [39.773031, 116.423162], [39.77465, 116.423898], [39.779506, 116.425865], [39.780709, 116.426432], [39.782747, 116.427593], [39.784183, 116.428621], [39.785553, 116.429848], [39.786572, 116.430988], [39.78714, 116.431724], [39.787694, 116.432527], [39.7884, 116.433694], [39.789093, 116.435145], [39.789614, 116.436433], [39.790087, 116.437892], [39.79027, 116.438595], [39.790667, 116.440575], [39.790791, 116.44143], [39.790968, 116.443217], [39.791076, 116.445854], [39.791056, 116.448456], [39.790878, 116.454143], [39.790887, 116.455694], [39.790949, 116.456568], [39.791123, 116.457926], [39.791312, 116.45883], [39.791813, 116.460488], [39.792222, 116.461459], [39.792901, 116.462726], [39.79352, 116.463625], [39.793933, 116.464162], [39.795021, 116.465352], [39.808638, 116.478352], [39.809626, 116.479427], [39.810512, 116.480645], [39.810784, 116.481064], [39.811227, 116.481916], [39.81202, 116.483732], [39.817991, 116.500007]]

获取的五环坐标是双线数据(巨坑),拆分成单线数据即可

def res_split(bounding_pointsgon):"""拆分为单线数据"""q = []index = 0for  p in  bounding_pointsgon:q.append(p)if index != 0 and p == bounding_pointsgon[0]:breakindex += 1return q

五环坐标点合成坐标线


import matplotlib.pyplot as plt
import numpy as np
def plotPolygenAndPoints(bounding_points, bounding_box_positions, ray=False):"""做图bounding_points : 五环坐标数据bounding_box_positions : 判断坐标点"""index=1x_start=0x_end=0y_start=0y_end=0for r in bounding_points:if index == 1:print("index = 1")else:x_start=bounding_points[index-2][0]x_end=r[0]y_start=bounding_points[index-2][1]y_end=r[1]X = np.linspace(x_start,x_end,100)Y = np.linspace(y_start,y_end,100)plt.plot(X,Y) index+=1for x,y in bounding_box_positions:plt.plot(x,y,'o')        if ray:plt.plot((0,x),(y,y))plt.arrow(x, y, 0.3, 0, shape='full', lw=1, length_includes_head=True, head_width=.1)plt.show()

判断坐标点在环线内

def estimate_coordinate(bounding_points,bounding_box_positions):"""判断 坐标点在环线区域内bounding_points : 五环坐标数据bounding_box_positions : 判断坐标点"""c = Falsei = -1l = len(poly)j = l - 1while i < l-1:i += 1if ((poly[i][0] <= pt[0] and pt[0] < poly[j][0]) or (poly[j][0] <= pt[0] and pt[0] < poly[i][0])):if (pt[1] < (poly[j][1] - poly[i][1]) * (pt[0] - poly[i][0]) / (poly[j][0] - poly[i][0]) + poly[i][1]):c = not cj = ireturn c

Python判断坐标点在五环线以内

爬取高德地图五环坐标数据

import requests
import json
def get_coordinates(name="五环"):url = "https://www.amap.com/service/poiInfo"querystring = {"query_type":"TQUERY","pagesize":"20","pagenum":"1","qii":"true","cluster_state":"5","need_utd":"true","utd_sceneid":"1000","div":"PC1000","addr_poi_merge":"true","is_classify":"true","zoom":"10.59","city":"110000","geoobj":"115.714446|39.806938|117.024755|40.037228","keywords":name}# cookie 必须填写,使用自己的既可以headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0",'Cookie': "cna=HGKwG2zeNAUCAbfyL9r25+N+; guid=f342-dfba-e71a-24ba; isg=BH19BEYlwsuqzmY_D1YaPAvqjNl3GrFsLu4XXz_C6FQDdpyoB2vxPGNkJKowdskk; l=eBSEG5GVTsf6NjtDKOfZFurza779TIRVguPzaNbMiOCP_45y5FCfW6ykUwT2CnGVHsTwR3-T6YgYBWYHTyCqaM70eyIAhKHmnwC..; oauth_state=b8297a9720a5d341ee8e0b0fe40bcd26; passport_login=NjM3OTk4Mjg4LGFtYXBfMTg1MDA2ODY0NTJDMnZSQWFwc0sscnVncWJ4cnB0ZGE3NmhsNmpuem9obzJqMzNxbWtsbXosMTY2NjY2ODE1NSxNall6WkRNNU4yTmxNV1l4WlRaaE56ZGpZemt6WVdVM1pXTXpaR0kxT0dRPQ%3D%3D; tfstk=cX2lBuZPn7l7qq6LlzM5Cx01vPUhZN9ESJyb3icwb3pnvl2Vi2A2_xgdm4b1zB1..; xlly_s=1; _uab_collina=166667906108871325514159; x-csrf-token=48f6a576ead3218f0a65a79256d305dd; x5sec=7b227761676272696467652d616c69626162612d616d61703b32223a223731356433633561373530666461636465316433396331633735626465663234434b694333706f47454a69687635445039363232494444656c35757041304144227d;dev_help=cjtdLgiHm4%2FlzXo9RB0Cm2U1MzhjYWRhMmFhZjk0MTZkZWNkNDZiMjAyZWM2NzEwNmVkMTAzMWVmYmFjMDZiMmMxZWVkMmY1ZDVhY2IxZTixcHpgx7qPlBVNEkxz6HY6%2BINj37titG%2BJ6muxw82%2BoxQF5rg2BMJr3SDJ0XLc%2F7a1rS5GE4ygNKfI2YtZ8to%2FreMW2VnUEFuvZrGdx0hJOBGuvpM6jtl%2FAbLxfq31Wp05WJzuMai1vkwwJmgfdU8v;gray_auth=2"}response = requests.request("GET", url, headers=headers, params=querystring)print(response.text)data=json.loads(response.text)['data']['poi_list'][0]['domain_list'][3]['value']print(data)results=[]for ddd in data.replace('|','_').split('_'):results.append([float(ddd.split(',')[1]),float(ddd.split(',')[0])])return results

五环坐标数据

results=[[39.817829, 116.499994], [39.819416, 116.504384], [39.822015, 116.51134], [39.822675, 116.512705], [39.823293, 116.513761], [39.824444, 116.51539], [39.830318, 116.523247], [39.831286, 116.524607], [39.833475, 116.52749], [39.836135, 116.531104], [39.84648, 116.544942], [39.847563, 116.546328], [39.848586, 116.547435], [39.849167, 116.547927], [39.849979, 116.548501], [39.850778, 116.548934], [39.85137, 116.549199], [39.852585, 116.549529], [39.853769, 116.549656], [39.854415, 116.549648], [39.8559, 116.549506], [39.862323, 116.548319], [39.863539, 116.548169], [39.864393, 116.548124], [39.865605, 116.548134], [39.866407, 116.54819], [39.871106, 116.548718], [39.874372, 116.54893], [39.880726, 116.548868], [39.883066, 116.548773], [39.8856, 116.548511], [39.892606, 116.547615], [39.894973, 116.547197], [39.906131, 116.544942], [39.9088, 116.544463], [39.911365, 116.544112], [39.913224, 116.543913], [39.915205, 116.543757], [39.937701, 116.542412], [39.939088, 116.542262], [39.940227, 116.54201], [39.941269, 116.541685], [39.942464, 116.541167], [39.943695, 116.540476], [39.944479, 116.539934], [39.945426, 116.539169], [39.94633, 116.538379], [39.950367, 116.534459], [39.951432, 116.533492], [39.952467, 116.532638], [39.953285, 116.532052], [39.954403, 116.531338], [39.955325, 116.530813], [39.956746, 116.530116], [39.964402, 116.526898], [39.966161, 116.526108], [39.969087, 116.524593], [39.971476, 116.523155], [39.973003, 116.522119], [39.975237, 116.520478], [39.981333, 116.51564], [39.98864, 116.509914], [39.98982, 116.50895], [39.991786, 116.507216], [39.993929, 116.505201], [39.996216, 116.502909], [40.003477, 116.495869], [40.011254, 116.488242], [40.011907, 116.487472], [40.012487, 116.486687], [40.013443, 116.485084], [40.01385, 116.484191], [40.014331, 116.482926], [40.014639, 116.481832], [40.014987, 116.480191], [40.015165, 116.478569], [40.015203, 116.477477], [40.015232, 116.472629], [40.015243, 116.462642], [40.015286, 116.461044], [40.015525, 116.458987], [40.016008, 116.45707], [40.017474, 116.452003], [40.017582, 116.451795], [40.021291, 116.439271], [40.021812, 116.436766], [40.022057, 116.43448], [40.022126, 116.432412], [40.02232, 116.420747], [40.022728, 116.390419], [40.023149, 116.353905], [40.023293, 116.337954], [40.023205, 116.336275], [40.023046, 116.335203],
[40.022754, 116.333936], [40.020567, 116.327049], [40.019599, 116.323443], [40.019203, 116.321601], [40.018726, 116.319075], [40.01722, 116.308968], [40.016903, 116.307233], [40.015197, 116.300609], [40.014897, 116.299243], [40.014649, 116.297595], [40.012434, 116.278587], [40.01213, 116.276525], [40.011933, 116.275711], [40.011635, 116.274887], [40.011264, 116.274107], [40.010687, 116.27321], [40.010042, 116.272478], [40.009436, 116.271972], [40.009015, 116.271693], [40.006945, 116.270506], [40.006486, 116.2702], [40.005849, 116.269667], [40.005479, 116.269301], [40.004701,
116.268269], [40.004186, 116.267331], [40.003838, 116.266462], [40.003524, 116.265333], [40.00321, 116.263126], [40.003113, 116.261441], [40.002853, 116.253675], [40.002747, 116.251597], [40.002567, 116.249963], [40.002342, 116.248738], [40.00203, 116.247567], [40.001732, 116.246675], [40.001111, 116.245113], [39.99933, 116.240986], [39.998825, 116.239684], [39.998501, 116.238643], [39.998263, 116.237708], [39.997958, 116.236189], [39.996878, 116.22994], [39.996434, 116.228008], [39.996154, 116.227096], [39.995814, 116.22619], [39.995397, 116.225314], [39.994944, 116.224548], [39.994306, 116.22369], [39.993369, 116.222715], [39.992561, 116.222112], [39.991561, 116.221588], [39.991239, 116.221465], [39.990244, 116.221213], [39.989658, 116.221109], [39.98819, 116.221016], [39.983716, 116.221016], [39.982327, 116.220979], [39.98081, 116.220897], [39.979003, 116.220716], [39.977649, 116.220548], [39.976512, 116.220352], [39.971288, 116.219336], [39.969768, 116.219106], [39.963499, 116.217938], [39.963152, 116.217877], [39.95277, 116.215942], [39.950934, 116.215585], [39.950148, 116.215365], [39.949269, 116.215047], [39.948312, 116.214574], [39.94602, 116.213126], [39.945105, 116.212613], [39.944292, 116.212271], [39.943405, 116.211995], [39.942147, 116.211779], [39.941148, 116.21173], [39.940366, 116.211737], [39.928194, 116.212095], [39.925178, 116.212111], [39.922976, 116.212004], [39.921265, 116.211871], [39.916407, 116.21127], [39.914511, 116.211072], [39.911803, 116.210944], [39.895209, 116.211048], [39.891897, 116.211274], [39.890614, 116.211264], [39.889332, 116.211088], [39.888344, 116.210805], [39.887136, 116.21031], [39.885192, 116.209411], [39.883646, 116.208752], [39.882052, 116.208222], [39.880811, 116.207953], [39.879427, 116.207783], [39.878518, 116.207744], [39.877794, 116.207767], [39.87688, 116.207843], [39.875924, 116.207998], [39.874292, 116.208416], [39.87262, 116.209098], [39.871915, 116.209456], [39.870477, 116.210308], [39.867218, 116.21269], [39.85917, 116.218832], [39.857964, 116.219591], [39.85716, 116.219953], [39.856334, 116.220212], [39.855251, 116.220429], [39.851551, 116.221001], [39.850238, 116.221343], [39.849283, 116.22176], [39.848665, 116.222106], [39.847933, 116.222614], [39.847203, 116.223221], [39.842137, 116.227999], [39.841103, 116.229036], [39.839045, 116.231344], [39.838388, 116.232027], [39.837775, 116.232572], [39.836102, 116.233929], [39.834906, 116.234988], [39.834572, 116.235329], [39.833885, 116.236218], [39.833586, 116.236694], [39.833094, 116.237651], [39.832626, 116.238948], [39.83142, 116.243435], [39.830774, 116.245342], [39.830217, 116.246458], [39.829798, 116.247101], [39.829141, 116.24793], [39.828229, 116.248844], [39.827607, 116.249393], [39.815824, 116.259618], [39.814019, 116.261146], [39.812526, 116.262291], [39.811034, 116.263265], [39.80994, 116.26385], [39.808953, 116.264296], [39.807389, 116.264838], [39.806202, 116.265119], [39.804752, 116.265352], [39.802409, 116.265551], [39.800393, 116.265653], [39.7993, 116.265748], [39.798324, 116.265901], [39.79716, 116.266168], [39.795985, 116.266541], [39.786792, 116.269823], [39.782428, 116.271441], [39.781342, 116.2719], [39.779926, 116.272629], [39.778952, 116.273241], [39.778384, 116.273647], [39.777733, 116.27419], [39.777091, 116.274801], [39.77637, 116.275645], [39.775602, 116.276751], [39.77511, 116.277634], [39.774563, 116.27886], [39.774129, 116.280172], [39.773825, 116.281545], [39.773678, 116.282479], [39.773577, 116.283589], [39.773556, 116.284717], [39.773594, 116.285502], [39.773736, 116.286795], [39.773983, 116.288066], [39.774218, 116.289033], [39.774688, 116.290457], [39.775261, 116.291847], [39.77568, 116.29274], [39.776839, 116.29496], [39.779318, 116.299331], [39.779899, 116.300427], [39.780466, 116.301597], [39.78087, 116.302539], [39.781289, 116.303874], [39.781584, 116.305205], [39.781741, 116.306413], [39.78179, 116.307305], [39.78179, 116.308708], [39.781597, 116.311055], [39.77961, 116.327783], [39.779342, 116.330543], [39.778648, 116.341975], [39.777497, 116.363894],
[39.777378, 116.365448], [39.777179, 116.367014], [39.777001, 116.367865], [39.776621, 116.369072], [39.776417, 116.369536], [39.775892, 116.370525], [39.775419, 116.371205], [39.774682, 116.37202], [39.773739, 116.372735], [39.773051, 116.373102], [39.771789, 116.373585], [39.770624, 116.373874], [39.763443, 116.375436], [39.762464, 116.375704], [39.761633, 116.37602], [39.761141, 116.376264], [39.760681, 116.376569], [39.759995, 116.377147], [39.759336, 116.377928], [39.758838, 116.378765], [39.758506, 116.379536], [39.75822, 116.380493], [39.758038, 116.381659], [39.75799, 116.382627], [39.75812, 116.384178], [39.758263, 116.385034], [39.764408, 116.41114], [39.764826, 116.412667], [39.765398, 116.414435], [39.766206, 116.416331], [39.766621, 116.417185], [39.767454, 116.418539], [39.768434, 116.419838], [39.768937, 116.42041], [39.76954, 116.420992], [39.770538, 116.421838], [39.771715, 116.422642], [39.772968, 116.423325], [39.774588, 116.424066], [39.77937, 116.425997], [39.78117, 116.426878], [39.782671, 116.427749], [39.783273, 116.428142], [39.784193, 116.428845], [39.785471, 116.429999], [39.785981, 116.430534], [39.786744, 116.431462], [39.78725, 116.432151], [39.787878, 116.433121], [39.788283, 116.433812], [39.788968, 116.435229], [39.789287, 116.435987], [39.789727, 116.437203], [39.789951, 116.437944], [39.790274, 116.439274], [39.790605, 116.441122], [39.790829, 116.443214], [39.79094, 116.445835], [39.790918, 116.448341], [39.790738, 116.454128], [39.790778, 116.4562], [39.790915, 116.457511], [39.79117, 116.458844], [39.791453, 116.459873], [39.792106, 116.461547], [39.792648, 116.462599], [39.792941, 116.463069], [39.793535, 116.463925], [39.794458, 116.465], [39.796014, 116.466556], [39.808336, 116.478279], [39.809279, 116.479266], [39.81019, 116.480459], [39.810811, 116.481458], [39.811321, 116.482448], [39.812048, 116.484218], [39.817829, 116.499994], [39.817991, 116.500007], [39.821922, 116.510702], [39.82223, 116.511463], [39.822772, 116.51258], [39.823637, 116.513996], [39.824961, 116.515832], [39.830899, 116.523754], [39.834519, 116.528679], [39.846901, 116.545237], [39.847833, 116.546396], [39.84825, 116.546843], [39.84898, 116.547536], [39.849545, 116.547984], [39.850685, 116.548704], [39.851648, 116.54912], [39.852794, 116.549384], [39.853776, 116.549511], [39.85497, 116.549452], [39.855921, 116.549313], [39.862427, 116.548143], [39.864522, 116.547912], [39.865417, 116.547916], [39.866296, 116.547979], [39.8718, 116.548598], [39.8744, 116.548754], [39.881448, 116.548672], [39.883979, 116.548526], [39.891884, 116.547548], [39.893962, 116.547233], [39.905417, 116.544896], [39.90872, 116.544306], [39.910891, 116.543997], [39.913185, 116.543711], [39.916125, 116.543517], [39.937476, 116.542254], [39.938708, 116.542104], [39.940043, 116.541854], [39.941214, 116.541486], [39.94233, 116.541034], [39.943302, 116.540515], [39.943841, 116.540177], [39.944428, 116.539761], [39.945365, 116.539009], [39.946325, 116.538146], [39.948985, 116.535564], [39.951347, 116.53334], [39.952287, 116.532562], [39.953574, 116.531656], [39.955269, 116.530642], [39.956635, 116.529972], [39.965463, 116.526239], [39.967445, 116.525268], [39.96902, 116.52443], [39.971407, 116.522983], [39.972956, 116.521945], [39.975239, 116.520271], [39.977081, 116.518833], [39.97908, 116.517215], [39.989245, 116.509187], [39.990987, 116.507726], [39.992843, 116.506017], [39.99611, 116.502769], [39.99981, 116.499192], [40.011068, 116.488146], [40.011776, 116.487343], [40.012259, 116.486688], [40.012802, 116.485822], [40.013341, 116.484835], [40.0138, 116.483816], [40.014329, 116.482297], [40.014469, 116.481797], [40.014736, 116.480484],
[40.014942, 116.479148], [40.01503, 116.477403], [40.015076, 116.470463], [40.015073, 116.462769], [40.015126, 116.461016], [40.015359, 116.459175], [40.015737, 116.457448], [40.017935, 116.449911], [40.02, 116.443103], [40.021139, 116.4392], [40.02143, 116.43801], [40.021611, 116.437073], [40.021896, 116.43476], [40.021977, 116.4328], [40.022131, 116.423648], [40.022345, 116.406118],
[40.02251, 116.396206], [40.022839, 116.366075], [40.022948, 116.359259], [40.02299, 116.349839], [40.023095, 116.344345], [40.023159, 116.338015], [40.02312, 116.336938], [40.023043, 116.336139], [40.022748, 116.334453], [40.022399, 116.333246], [40.020678, 116.327869], [40.020076, 116.325817], [40.019434, 116.323387], [40.018839, 116.320468], [40.018513, 116.31859], [40.017215, 116.309787], [40.016838, 116.307558], [40.016576, 116.306404], [40.01507, 116.30069], [40.014633, 116.298445], [40.014308, 116.295938], [40.012293, 116.278305], [40.012019, 116.27666], [40.011754, 116.275609], [40.011425, 116.274726], [40.010877, 116.273737], [40.010382, 116.273074], [40.009846, 116.272518], [40.00926, 116.272052], [40.00861, 116.271633], [40.007118, 116.270798], [40.006215, 116.270187], [40.005843, 116.269877], [40.005241, 116.26925], [40.004632, 116.268414], [40.004237, 116.267728], [40.003743, 116.266615], [40.003495, 116.265808], [40.003291, 116.264941], [40.003065, 116.26313], [40.002601, 116.251612], [40.002422, 116.250007], [40.002167, 116.248744], [40.001864, 116.247581], [40.001125, 116.245503], [39.999068, 116.240705], [39.998437, 116.238865],
[39.998144, 116.237752], [39.997856, 116.236348], [39.996759, 116.230056], [39.996498, 116.228836], [39.996115, 116.227433], [39.995837, 116.226643], [39.995358, 116.225503], [39.994848, 116.224665], [39.994216, 116.223805], [39.99373, 116.223276], [39.993404, 116.222981], [39.992723, 116.222437], [39.992231, 116.222129], [39.99169, 116.221863], [39.990889, 116.221554], [39.98997, 116.22134], [39.988654, 116.221209], [39.987944, 116.221184], [39.982566, 116.221142], [39.980398, 116.221031], [39.978868, 116.220874], [39.977643, 116.220709], [39.975305, 116.220304], [39.969765, 116.219244], [39.963432, 116.218095], [39.962996, 116.218013], [39.952739, 116.216123], [39.95129, 116.215833], [39.950064, 116.215515], [39.949108, 116.21514], [39.948395, 116.21477], [39.946404, 116.213541], [39.945055, 116.212787], [39.944216, 116.21245], [39.943557, 116.212239], [39.94254, 116.21202], [39.941622, 116.211944], [39.940713, 116.211921], [39.931959, 116.212152], [39.928032, 116.212301], [39.92433, 116.212267], [39.921168, 116.212031], [39.916401, 116.211437], [39.914541, 116.211242], [39.911491, 116.211095], [39.896086, 116.211217], [39.894204, 116.211272],
[39.892176, 116.211435], [39.890563, 116.211444], [39.889312, 116.211253], [39.888171, 116.21094], [39.887702, 116.210763], [39.884576, 116.209326], [39.883724, 116.208975], [39.882373, 116.208497], [39.880856, 116.208146], [39.879156, 116.207939], [39.878025, 116.207933], [39.8769, 116.208018], [39.87606, 116.208155], [39.875168, 116.208348], [39.874513, 116.208547], [39.873162, 116.20904], [39.871959, 116.209613], [39.871328, 116.20997], [39.870025, 116.210812], [39.86944, 116.211221], [39.859638, 116.218685], [39.85881, 116.219273], [39.858054, 116.219724], [39.857272, 116.22009], [39.856346, 116.220387], [39.855274, 116.220598], [39.851558, 116.22116], [39.850534, 116.221447], [39.849641, 116.221782], [39.849156, 116.222024], [39.848368, 116.222522], [39.847578, 116.223121], [39.845812, 116.224729], [39.842199, 116.228152], [39.838324, 116.232282], [39.834956, 116.235147], [39.83439, 116.235766], [39.833645, 116.236855], [39.833274, 116.237584], [39.832944, 116.238403], [39.832442, 116.240093], [39.831737, 116.242746], [39.831213, 116.244524], [39.830973, 116.245189], [39.830719, 116.245776], [39.830253, 116.246645], [39.829597, 116.247616],
[39.829203, 116.248091], [39.828477, 116.248816], [39.826718, 116.250377], [39.816804, 116.258979], [39.814529, 116.260933], [39.813228, 116.261975], [39.812546, 116.262472], [39.811074, 116.263437], [39.810127, 116.263936], [39.808953, 116.264475], [39.80787, 116.264865], [39.806251, 116.26529], [39.80504, 116.265485], [39.802407, 116.265728], [39.79935, 116.265914], [39.798353, 116.266069], [39.79746, 116.266268], [39.796134, 116.266673], [39.788313, 116.26947], [39.783361, 116.271254], [39.781756, 116.271899], [39.78051, 116.272499], [39.779621, 116.273032], [39.778079, 116.274183], [39.777461, 116.27473], [39.776559, 116.275648], [39.776372, 116.275895], [39.775832, 116.276667], [39.775234, 116.277716], [39.774691, 116.278907], [39.77427, 116.280216], [39.774023, 116.28123], [39.773774, 116.282823], [39.773691, 116.284174], [39.773729, 116.285583], [39.773878, 116.286877], [39.774154, 116.288236], [39.774334, 116.288923], [39.774853, 116.290483], [39.775353, 116.291713], [39.775822, 116.292742], [39.776643, 116.294342], [39.780016, 116.300316], [39.7805, 116.301276], [39.780921, 116.302255], [39.7813, 116.303366], [39.781636, 116.304663], [39.781819, 116.305734], [39.78194, 116.307456], [39.781904, 116.309227], [39.781726, 116.311216], [39.779686, 116.328581], [39.779414, 116.331671], [39.777658, 116.363917], [39.777479, 116.36617], [39.777392, 116.366802], [39.777182, 116.367866], [39.77679, 116.369087], [39.776352, 116.37006], [39.775887, 116.370858], [39.775403, 116.371496], [39.774811, 116.372132], [39.774142, 116.372692], [39.773747, 116.372954], [39.773063, 116.373317], [39.772563, 116.373531], [39.77133, 116.373913], [39.763428, 116.375617], [39.762851, 116.37577], [39.761878, 116.376117], [39.761251, 116.376421], [39.760675, 116.376797], [39.760127, 116.377253], [39.759401, 116.378114], [39.758954, 116.378905], [39.758544, 116.379901], [39.758305, 116.380805], [39.758233, 116.381205], [39.758143, 116.382571], [39.758219, 116.383719], [39.758415, 116.384967], [39.76033, 116.39326], [39.764545, 116.411086], [39.765012, 116.412792], [39.765522, 116.414353], [39.766316, 116.416242], [39.766643, 116.416892], [39.767217, 116.417906], [39.767579, 116.41845], [39.768532, 116.419705], [39.769207, 116.420439], [39.769845, 116.42105], [39.770599, 116.421673], [39.771682, 116.422414], [39.773031, 116.423162], [39.77465, 116.423898], [39.779506, 116.425865], [39.780709, 116.426432], [39.782747, 116.427593], [39.784183, 116.428621], [39.785553, 116.429848], [39.786572, 116.430988], [39.78714, 116.431724], [39.787694, 116.432527], [39.7884, 116.433694], [39.789093, 116.435145], [39.789614, 116.436433], [39.790087, 116.437892], [39.79027, 116.438595], [39.790667, 116.440575], [39.790791, 116.44143], [39.790968, 116.443217], [39.791076, 116.445854], [39.791056, 116.448456], [39.790878, 116.454143], [39.790887, 116.455694], [39.790949, 116.456568], [39.791123, 116.457926], [39.791312, 116.45883], [39.791813, 116.460488], [39.792222, 116.461459], [39.792901, 116.462726], [39.79352, 116.463625], [39.793933, 116.464162], [39.795021, 116.465352], [39.808638, 116.478352], [39.809626, 116.479427], [39.810512, 116.480645], [39.810784, 116.481064], [39.811227, 116.481916], [39.81202, 116.483732], [39.817991, 116.500007]]

获取的五环坐标是双线数据(巨坑),拆分成单线数据即可

def res_split(bounding_pointsgon):"""拆分为单线数据"""q = []index = 0for  p in  bounding_pointsgon:q.append(p)if index != 0 and p == bounding_pointsgon[0]:breakindex += 1return q

五环坐标点合成坐标线


import matplotlib.pyplot as plt
import numpy as np
def plotPolygenAndPoints(bounding_points, bounding_box_positions, ray=False):"""做图bounding_points : 五环坐标数据bounding_box_positions : 判断坐标点"""index=1x_start=0x_end=0y_start=0y_end=0for r in bounding_points:if index == 1:print("index = 1")else:x_start=bounding_points[index-2][0]x_end=r[0]y_start=bounding_points[index-2][1]y_end=r[1]X = np.linspace(x_start,x_end,100)Y = np.linspace(y_start,y_end,100)plt.plot(X,Y) index+=1for x,y in bounding_box_positions:plt.plot(x,y,'o')        if ray:plt.plot((0,x),(y,y))plt.arrow(x, y, 0.3, 0, shape='full', lw=1, length_includes_head=True, head_width=.1)plt.show()

判断坐标点在环线内

def estimate_coordinate(bounding_points,bounding_box_positions):"""判断 坐标点在环线区域内bounding_points : 五环坐标数据bounding_box_positions : 判断坐标点"""c = Falsei = -1l = len(poly)j = l - 1while i < l-1:i += 1if ((poly[i][0] <= pt[0] and pt[0] < poly[j][0]) or (poly[j][0] <= pt[0] and pt[0] < poly[i][0])):if (pt[1] < (poly[j][1] - poly[i][1]) * (pt[0] - poly[i][0]) / (poly[j][0] - poly[i][0]) + poly[i][1]):c = not cj = ireturn c

Python判断坐标点在五环线以内相关推荐

  1. 《假如编程是魔法之零基础看得懂的Python入门教程 》——(五)我的魔法竟然有了一丝逻辑

    学习目标 了解魔法世界中的结构表现--缩进 了解魔法世界的逻辑判断--if 了解魔法世界的多次逻辑判断--ifelse嵌套 了解魔法世界中的逻辑运算--且 and 与或 or 推荐 1.<备受好 ...

  2. python判断质数用for循环_Day3.Python判断与循环语句

    Python判断与循环语句!!! 例题引导: Q:输入3个整数,按从小到大依次输出,用"->"符号相连: 例如:输入4,2,6,输出2 -> 4 -> 6 A: ...

  3. python判断是不是文件夹_Python判断文件和文件夹是否存在的方法

    一.python判断文件和文件夹是否存在.创建文件夹 复制代码代码如下: >>> import os >>> os.path.exists("d:/ass ...

  4. Python常用小技巧(五)——批量读取json文件

    Python常用小技巧(五)--批量读取json文件 前言:其实Python能够批量读取很多文件,这里,本人以json文件为例(json是标注图片时生成的文件,记录有标注的坐标和标签,友情推荐标注图片 ...

  5. python数据挖掘学习】十五.Matplotlib调用imshow()函数绘制热图

    python数据挖掘学习]十五.Matplotlib调用imshow()函数绘制热图 #2018-03-28 14:47:19 March Wednesday the 13 week, the 087 ...

  6. Python判断文件和文件夹是否存在的方法

    这篇文章主要介绍了Python判断文件和文件夹是否存在的方法,本文还讲解了判断是否为文件或者目录的方法.os.path.lexist的作用.FTP中判断文件或目录是否存在等内容,需要的朋友可以参考下 ...

  7. [Python从零到壹] 五十八.图像增强及运算篇之图像锐化Sobel、Laplacian算子实现边缘检测

    欢迎大家来到"Python从零到壹",在这里我将分享约200篇Python系列文章,带大家一起去学习和玩耍,看看Python这个有趣的世界.所有文章都将结合案例.代码和作者的经验讲 ...

  8. Python学习笔记 -一到五

    第一阶段 第一章 python入门 小技巧:上注释使用(ctrl+/) print("") 输出的时候是,输出的就是""内的内容 如果是使用变量的话,不加&qu ...

  9. python判断字符串合法,详解Python判定IP地址合法性的三种方法 python中判断一个字符串是否是IP地址...

    html 中 鼠标放在标签上会显示小手状,其它标签在其他标签上,美工给加了一些样式,鼠标放上去也显示小手状.有哪位大手状样式 有什么不懂的前端问题可以去菜鸟驿站.全都是泡沫,只一刹的花火,所谓的友情, ...

  10. [Python从零到壹] 五十六.图像增强及运算篇之图像平滑(中值滤波、双边滤波)

    欢迎大家来到"Python从零到壹",在这里我将分享约200篇Python系列文章,带大家一起去学习和玩耍,看看Python这个有趣的世界.所有文章都将结合案例.代码和作者的经验讲 ...

最新文章

  1. 使用yum管理软件包
  2. NLP学习笔记:word2vec
  3. access exex控制pc_ownCloud/Nextcloud文件访问控制(Files Access Control)
  4. 集线器级联增加了网络数量,效率降低了,形成了大的冲突域,怎么解决?
  5. Linux终端下翻页操作
  6. python处理excel表格-Python读写Excel表格(简单实用)
  7. Ubuntu18.04谷歌输入法中文候选此框消失问题
  8. python 怎么取对数_重新开始学习Python 第二十八天 Python 数学模块
  9. java压缩包上传,解压,预览(利用editor.md和Jstree实现)和下载
  10. 使用oss对象存储的ossutil工具
  11. 统计自然语言处理(第二版)学习笔记:第一章
  12. 单片机原理与接口技术期末总复习
  13. 数学中矩阵乘积转置等的相关求导
  14. 量子纠缠在量子计算机中的作用,解密量子计算机,量子叠加和量子纠缠是制胜关键...
  15. 联想ThinkBook解锁FN键
  16. seo网站优化技巧_新网站的10个SEO技巧
  17. html的abbr标签,html标签里有个abbr 请问这个标签是肿么使用的
  18. 速通~腾讯云学生gpu服务器安装TensorFlow
  19. 清华大学五道口金融学院2023年博士生招生简章(普博+直博)
  20. 【强烈推荐】原导师评价网上不去了,新版在这里

热门文章

  1. 颜色所代表的人的性格
  2. 问题 E: 【贪心】雷达问题
  3. MYSQL没有id字段的坑
  4. python的十句名言_程序员的二十句励志名言,看看你最喜欢哪句?
  5. ES实现自动补全查询
  6. 【笔记】个人博客建立(域名选择、网站备案、公安联网备案、安全评估报告)
  7. php+laravel 扫码二维码签到
  8. SpaceSyntax【空间句法】之DepthMapX学习:第三篇 软件介绍与一般分析流程图
  9. 运算放大器---转换速率(slew rate)
  10. hexo+yilia添加背景音乐