- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须根据包含以下列的表生成国家/地区名称:{"ID","LAT","LONG","DATE"}。必须为分布在世界各地的所有 ID 找到它。我想在 Snowflakes 中使用 sql 来完成它。如果我使用 Python,使用反向地理编码器包会更容易,但通过 sql 我面临困难。
最佳答案
ST_CONTAINS 将完成这项工作:
from (
select 'a' point_id, to_geography('POINT(-0.1278 51.5074)') point
union all select 'b', to_geography('POINT(44.8271 41.7151)')
) a
join countries_geo b
on st_contains(b.geog, a.point)
为此,您需要一个包含国家/地区地理位置的表格。
我像这样快速创建了一个:
create or replace table countries_geo
as
select parse_json(value):properties.name::string country, to_geography(trim(value, ',')) geog
from table(split_to_table('{"type":"Feature","id":"GBR","properties":{"name":"United Kingdom"},"geometry":{"type":"MultiPolygon","coordinates":[[[[-5.661949,54.554603],[-6.197885,53.867565],[-6.95373,54.073702],[-7.572168,54.059956],[-7.366031,54.595841],[-7.572168,55.131622],[-6.733847,55.17286],[-5.661949,54.554603]]],[[[-3.005005,58.635],[-4.073828,57.553025],[-3.055002,57.690019],[-1.959281,57.6848],[-2.219988,56.870017],[-3.119003,55.973793],[-2.085009,55.909998],[-2.005676,55.804903],[-1.114991,54.624986],[-0.430485,54.464376],[0.184981,53.325014],[0.469977,52.929999],[1.681531,52.73952],[1.559988,52.099998],[1.050562,51.806761],[1.449865,51.289428],[0.550334,50.765739],[-0.787517,50.774989],[-2.489998,50.500019],[-2.956274,50.69688],[-3.617448,50.228356],[-4.542508,50.341837],[-5.245023,49.96],[-5.776567,50.159678],[-4.30999,51.210001],[-3.414851,51.426009],[-3.422719,51.426848],[-4.984367,51.593466],[-5.267296,51.9914],[-4.222347,52.301356],[-4.770013,52.840005],[-4.579999,53.495004],[-3.093831,53.404547],[-3.09208,53.404441],[-2.945009,53.985],[-3.614701,54.600937],[-3.630005,54.615013],[-4.844169,54.790971],[-5.082527,55.061601],[-4.719112,55.508473],[-5.047981,55.783986],[-5.586398,55.311146],[-5.644999,56.275015],[-6.149981,56.78501],[-5.786825,57.818848],[-5.009999,58.630013],[-4.211495,58.550845],[-3.005005,58.635]]]]}},
{"type":"Feature","id":"GEO","properties":{"name":"Georgia"},"geometry":{"type":"Polygon","coordinates":[[[41.554084,41.535656],[41.703171,41.962943],[41.45347,42.645123],[40.875469,43.013628],[40.321394,43.128634],[39.955009,43.434998],[40.076965,43.553104],[40.922185,43.382159],[42.394395,43.220308],[43.756017,42.740828],[43.9312,42.554974],[44.537623,42.711993],[45.470279,42.502781],[45.77641,42.092444],[46.404951,41.860675],[46.145432,41.722802],[46.637908,41.181673],[46.501637,41.064445],[45.962601,41.123873],[45.217426,41.411452],[44.97248,41.248129],[43.582746,41.092143],[42.619549,41.583173],[41.554084,41.535656]]]}},
{"type":"Feature","id":"GHA","properties":{"name":"Ghana"},"geometry":{"type":"Polygon","coordinates":[[[1.060122,5.928837],[-0.507638,5.343473],[-1.063625,5.000548],[-1.964707,4.710462],[-2.856125,4.994476],[-2.810701,5.389051],[-3.24437,6.250472],[-2.983585,7.379705],[-2.56219,8.219628],[-2.827496,9.642461],[-2.963896,10.395335],[-2.940409,10.96269],[-1.203358,11.009819],[-0.761576,10.93693],[-0.438702,11.098341],[0.023803,11.018682],[-0.049785,10.706918],[0.36758,10.191213],[0.365901,9.465004],[0.461192,8.677223],[0.712029,8.312465],[0.490957,7.411744],[0.570384,6.914359],[0.836931,6.279979],[1.060122,5.928837]]]}},
{"type":"Feature","id":"GIN","properties":{"name":"Guinea"},"geometry":{"type":"Polygon","coordinates":[[[-8.439298,7.686043],[-8.722124,7.711674],[-8.926065,7.309037],[-9.208786,7.313921],[-9.403348,7.526905],[-9.33728,7.928534],[-9.755342,8.541055],[-10.016567,8.428504],[-10.230094,8.406206],[-10.505477,8.348896],[-10.494315,8.715541],[-10.65477,8.977178],[-10.622395,9.26791],[-10.839152,9.688246],[-11.117481,10.045873],[-11.917277,10.046984],[-12.150338,9.858572],[-12.425929,9.835834],[-12.596719,9.620188],[-12.711958,9.342712],[-13.24655,8.903049],[-13.685154,9.494744],[-14.074045,9.886167],[-14.330076,10.01572],[-14.579699,10.214467],[-14.693232,10.656301],[-14.839554,10.876572],[-15.130311,11.040412],[-14.685687,11.527824],[-14.382192,11.509272],[-14.121406,11.677117],[-13.9008,11.678719],[-13.743161,11.811269],[-13.828272,12.142644],[-13.718744,12.247186],[-13.700476,12.586183],[-13.217818,12.575874],[-12.499051,12.33209],[-12.278599,12.35444],[-12.203565,12.465648],[-11.658301,12.386583],[-11.513943,12.442988],[-11.456169,12.076834],[-11.297574,12.077971],[-11.036556,12.211245],[-10.87083,12.177887],[-10.593224,11.923975],[-10.165214,11.844084],[-9.890993,12.060479],[-9.567912,12.194243],[-9.327616,12.334286],[-9.127474,12.30806],[-8.905265,12.088358],[-8.786099,11.812561],[-8.376305,11.393646],[-8.581305,11.136246],[-8.620321,10.810891],[-8.407311,10.909257],[-8.282357,10.792597],[-8.335377,10.494812],[-8.029944,10.206535],[-8.229337,10.12902],[-8.309616,9.789532],[-8.079114,9.376224],[-7.8321,8.575704],[-8.203499,8.455453],[-8.299049,8.316444],[-8.221792,8.123329],[-8.280703,7.68718],[-8.439298,7.686043]]]}},
{"type":"Feature","id":"GMB","properties":{"name":"Gambia"},"geometry":{"type":"Polygon","coordinates":[[[-16.841525,13.151394],[-16.713729,13.594959],[-15.624596,13.623587],[-15.39877,13.860369],[-15.081735,13.876492],[-14.687031,13.630357],[-14.376714,13.62568],[-14.046992,13.794068],[-13.844963,13.505042],[-14.277702,13.280585],[-14.712197,13.298207],[-15.141163,13.509512],[-15.511813,13.27857],[-15.691001,13.270353],[-15.931296,13.130284],[-16.841525,13.151394]]]}},
{"type":"Feature","id":"GNB","properties":{"name":"Guinea Bissau"},"geometry":{"type":"Polygon","coordinates":[[[-15.130311,11.040412],[-15.66418,11.458474],[-16.085214,11.524594],[-16.314787,11.806515],[-16.308947,11.958702],[-16.613838,12.170911],[-16.677452,12.384852],[-16.147717,12.547762],[-15.816574,12.515567],[-15.548477,12.62817],[-13.700476,12.586183],[-13.718744,12.247186],[-13.828272,12.142644],[-13.743161,11.811269],[-13.9008,11.678719],[-14.121406,11.677117],[-14.382192,11.509272],[-14.685687,11.527824],[-15.130311,11.040412]]]}},
{"type":"Feature","id":"GNQ","properties":{"name":"Equatorial Guinea"},"geometry":{"type":"Polygon","coordinates":[[[9.492889,1.01012],[9.305613,1.160911],[9.649158,2.283866],[11.276449,2.261051],[11.285079,1.057662],[9.830284,1.067894],[9.492889,1.01012]]]}},
{"type":"Feature","id":"GRC","properties":{"name":"Greece"},"geometry":{"type":"MultiPolygon","coordinates":[[[[23.69998,35.705004],[24.246665,35.368022],[25.025015,35.424996],[25.769208,35.354018],[25.745023,35.179998],[26.290003,35.29999],[26.164998,35.004995],[24.724982,34.919988],[24.735007,35.084991],[23.514978,35.279992],[23.69998,35.705004]]],[[[26.604196,41.562115],[26.294602,40.936261],[26.056942,40.824123],[25.447677,40.852545],[24.925848,40.947062],[23.714811,40.687129],[24.407999,40.124993],[23.899968,39.962006],[23.342999,39.960998],[22.813988,40.476005],[22.626299,40.256561],[22.849748,39.659311],[23.350027,39.190011],[22.973099,38.970903],[23.530016,38.510001],[24.025025,38.219993],[24.040011,37.655015],[23.115003,37.920011],[23.409972,37.409991],[22.774972,37.30501],[23.154225,36.422506],[22.490028,36.41],[21.670026,36.844986],[21.295011,37.644989],[21.120034,38.310323],[20.730032,38.769985],[20.217712,39.340235],[20.150016,39.624998],[20.615,40.110007],[20.674997,40.435],[20.99999,40.580004],[21.02004,40.842727],[21.674161,40.931275],[22.055378,41.149866],[22.597308,41.130487],[22.76177,41.3048],[22.952377,41.337994],[23.692074,41.309081],[24.492645,41.583896],[25.197201,41.234486],[26.106138,41.328899],[26.117042,41.826905],[26.604196,41.562115]]]]}},', '\n'))
使用来自 https://github.com/johan/world.geo.json 的数据。
关于sql - 如何根据 ' Country Name' 和 'Lat' 生成一个 'Long' 字段 对于一个遍布全局的 unique_Id,在 SNOWFLAKES QUERY 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67472656/
我正在使用 MySQL 5.5.52。缩写:Lat = 纬度,Long = 经度,NE = 东北,SW = 西南。 我有两个 SQL 表: 第一个表包含“区域”。每个区域由 ID、NE Lat、NE
这个问题在这里已经有了答案: Measuring the distance between two coordinates in PHP (13 个答案) 关闭 9 年前。 我在数据库中存储了 fi
我试过以下方法,输入:纬度/经度数据然后我会计算它周围的一个方框,比方说 50 米,所以东距/北距值 +/- 50 米。 现在我将它重新转换为纬度/经度并使用脚本: http://robotics.a
我想在 Google map 标记完成拖动时检索正确的 lat/lng。 但是对于同一个精确点,它给出了两个不同的(非常近似)坐标。 同一掉落的示例结果: evt.latLng:39.82213542
我正在使用 proj4 将纬度/对数坐标投影到 UTM。但我无法从 UTM 投影回 lat/log。对于以下示例,我希望代码返回给定的经纬度/对数 [48.37966, 2.504635]。相反,它返
我有一个 mysql 插入语句,当系统无法获取用户的纬度/经度时,该语句会中断。sql 是这样的: INSERT INTO users(user_email, first_name , last_na
我有一个页面,用户可以在“邮政编码”字段中输入他们的地址。我还有一个“检测位置”按钮,可以对用户地址进行地理定位。当他们单击此按钮时,他们的城市名称和邮政编码将回显到“邮政编码”字段中,并且纬度和经度
添加位置并按回车键时出现错误 var lat = data.results[0].geometry.location.lat; 类型错误:无法读取未定义的属性“结果” 有时它会给出 cannot re
我有两个表:一个 map 表,其中包含大约 3,000 个纬度/经度对,代表现实世界的“标记”位置;还有一个建筑物表,其中有数百个纬度/经度对,也代表真实世界的建筑物位置。我想做的是获取所有建筑物可见
我正在尝试找到解决以下问题的最佳方法: 问题 我在集合 A 中有(最多)100,000 个纬度/经度点我在 B 组中有(最多)2000 个纬度/经度点 我需要找到集合 B 中的点与集合 A 中的点最近
我有一个圆圈,它实际上是一个以米为单位的半径的 latlon 位置。我还有一条道路 A-B 定义为两个经纬度位置。我如何找到那条路是否在圆圈内交叉。如果没有将 latlon 位置投影到 xy 位置是否
假设我有一个 lat lng 坐标,我想把它放在一个 10 公里宽的正方形的中心,然后得到最小的 lat/lng 和最大的 lat/lng。 有没有一种简单的方法可以做到这一点已经存在? 最佳答案 如
我有一个类型为 (com.vividsolutions.jts.geom.Geometry) 的几何对象。它目前处于纬度、经度形式,我想翻转坐标,以便它的经度纬度,以便我可以将它以 GeoJSON 格
我想在android中制作一个应用程序。在此应用程序中,用户必须在此应用程序中注册。注册后,GPS 位置(纬度和经度)将与用户信息一起存储在数据库表中。在这个应用程序中,我想添加一个功能,即“搜索根目
在过去的几天里,我一直在努力寻找这个问题的答案。我有一个 GPS 数据路线表。和一张积分表。我需要的是一个 MySql 语句,对于给定的路线,将告诉我两个端点的 Point.Name。我可以写 4 个
我正在尝试从我的解析后端查询一组坐标(纬度和经度)。然后将它们用作 map 上的注释。虽然一旦我从解析中查询后,我不确定如何将坐标转换为 CLLocation。 查询使用的代码: var usersL
我见过这个问题的许多变体,但我无法将他们的答案与我的具体需求联系起来。 我有几组 3 纬度/经度坐标对。任何集合中的坐标彼此之间都在几公里之内。 对于每个集合,我想将坐标转换为 x/y 值,以便我可以
我希望能够找到离经度/纬度元组最近的位置的经度/纬度坐标索引。这已经在 Java API 中作为 GridCoordSystem.findXYindexFromLatLon() 提供,但我还没有在
我对这些字段的数据类型感到困惑。我想获取存储在手机上的图像的经度和纬度,并将其表示为地理点。我的代码是: double long_ = imageCursor.getDouble(imageCurso
我有以下交通表,其中包含数千条火车、巴士站和机场的记录。 ID Lon Lat Name 1 0.375
我是一名优秀的程序员,十分优秀!