我有一组地理点,我的任务是弄清楚每个点属于哪个美国邮政编码边界。每个点都有一个geo_point
字段,我已经成功导入/索引了这些点,并在Kibana(本地运行)中创建了带有这些点和内置EMS“美国邮政编码”层的 map 。有没有办法找出这些点位于哪个邮政编码边界? (对于Elasticsearch / Kibana来说相对较新,因此感谢您的帮助!)
最佳答案
尽管美国邮政编码可能是可见的,但我认为您无法对其进行查询。通常要做的是拥有自己的邮政编码收集/索引(既有商业包装,也有OSS软件包),然后查询这些邮政编码。
让我们接受90210 CA
。
创建一个索引:
PUT zipcodes
{
"mappings": {
"properties": {
"boundary": {
"type": "geo_shape"
}
}
}
}
找到边界并同步它:
POST zipcodes/_doc
{"boundary":{"type":"polygon","coordinates":[[[-118.3964,34.0951],[-118.3961,34.0949],[-118.3958,34.0936],[-118.3955,34.0933],[-118.3958,34.0928],[-118.3957,34.0921],[-118.3952,34.0906],[-118.3957,34.0906],[-118.3954,34.0901],[-118.395,34.0901],[-118.3947,34.09],[-118.3943,34.0893],[-118.3942,34.0892],[-118.3938,34.0895],[-118.3936,34.0896],[-118.3911,34.0889],[-118.3898,34.0885],[-118.3898,34.0873],[-118.3898,34.0842],[-118.3898,34.0817],[-118.3898,34.0808],[-118.3897,34.0807],[-118.3897,34.0772],[-118.3903,34.0772],[-118.391,34.0772],[-118.391,34.0736],[-118.3897,34.0736],[-118.3897,34.0723],[-118.3897,34.0721],[-118.3897,34.067],[-118.3918,34.0671],[-118.3935,34.0671],[-118.3938,34.0671],[-118.394,34.0671],[-118.3959,34.0671],[-118.3966,34.0671],[-118.3969,34.0671],[-118.3983,34.0671],[-118.401,34.0671],[-118.4013,34.0671],[-118.4023,34.0671],[-118.4027,34.0671],[-118.4035,34.0671],[-118.4045,34.0671],[-118.4046,34.0671],[-118.4053,34.0671],[-118.4056,34.0671],[-118.4058,34.0671],[-118.406,34.0671],[-118.4061,34.0673],[-118.4074,34.0685],[-118.4084,34.0678],[-118.4077,34.0671],[-118.4103,34.0671],[-118.4105,34.067],[-118.4164,34.067],[-118.4172,34.0683],[-118.4169,34.0686],[-118.4187,34.0724],[-118.4197,34.0726],[-118.4202,34.0741],[-118.4214,34.0765],[-118.4215,34.0764],[-118.4218,34.0751],[-118.4226,34.0751],[-118.4235,34.0757],[-118.423,34.077],[-118.4236,34.0783],[-118.4236,34.0791],[-118.4231,34.08],[-118.4227,34.0803],[-118.4228,34.0805],[-118.4229,34.0811],[-118.4253,34.0814],[-118.4282,34.0836],[-118.4281,34.0839],[-118.427,34.0837],[-118.4275,34.0843],[-118.4272,34.0849],[-118.427,34.0859],[-118.4286,34.0866],[-118.4288,34.087],[-118.432,34.088],[-118.4343,34.0914],[-118.4369,34.0914],[-118.4401,34.0992],[-118.4428,34.1119],[-118.4395,34.1185],[-118.4405,34.1273],[-118.4421,34.1307],[-118.4394,34.1316],[-118.4407,34.133],[-118.4422,34.1336],[-118.4388,34.1378],[-118.4366,34.1392],[-118.436,34.1389],[-118.4353,34.138],[-118.4346,34.137],[-118.4329,34.1368],[-118.4315,34.1328],[-118.4327,34.1323],[-118.4325,34.1318],[-118.432,34.132],[-118.4291,34.1345],[-118.4288,34.1338],[-118.4287,34.1327],[-118.4284,34.1323],[-118.4281,34.1313],[-118.4275,34.1311],[-118.4268,34.1312],[-118.4247,34.1301],[-118.4232,34.1302],[-118.4229,34.1299],[-118.4225,34.1297],[-118.4218,34.1299],[-118.4194,34.1275],[-118.4148,34.1265],[-118.4139,34.129],[-118.4128,34.1292],[-118.4137,34.134],[-118.4124,34.1349],[-118.4113,34.1324],[-118.4103,34.1335],[-118.4088,34.1322],[-118.408,34.1299],[-118.4067,34.1288],[-118.4049,34.1297],[-118.4028,34.1296],[-118.4009,34.1304],[-118.4,34.1293],[-118.3971,34.1284],[-118.3986,34.1271],[-118.3964,34.1254],[-118.3945,34.1266],[-118.3949,34.1257],[-118.3943,34.1242],[-118.3906,34.1222],[-118.3921,34.1207],[-118.3937,34.1192],[-118.3935,34.1185],[-118.3921,34.119],[-118.3922,34.1138],[-118.3916,34.1124],[-118.3916,34.1119],[-118.3905,34.1091],[-118.3918,34.1062],[-118.3922,34.1052],[-118.392,34.1009],[-118.3923,34.1005],[-118.3919,34.0988],[-118.3934,34.0986],[-118.3958,34.0959],[-118.3962,34.096],[-118.3964,34.0951]]]}}
检查一个点是否位于:
GET zipcodes/_search
{
"query": {
"geo_shape": {
"boundary": {
"shape": {
"type": "point",
"coordinates": [
-118.40188980102539,
34.109388376579645
]
},
"relation": "intersects"
}
}
}
}
视觉提示:
关于elasticsearch - 确定哪些点在Kibana上的Elastic Map Service边界内,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61687142/