{"id":1135272,"date":"2025-01-08T21:23:35","date_gmt":"2025-01-08T13:23:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1135272.html"},"modified":"2025-01-08T21:23:37","modified_gmt":"2025-01-08T13:23:37","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86%e7%bb%8f%e7%ba%ac%e5%ba%a6%e8%bd%ac%e6%8d%a2xyz%e5%9d%90%e6%a0%87","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1135272.html","title":{"rendered":"python\u5982\u4f55\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362xyz\u5750\u6807"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25103950\/9c1d4dd5-d187-499d-999c-d357ccc91856.webp\" alt=\"python\u5982\u4f55\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362xyz\u5750\u6807\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4e3b\u8981\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528\u5730\u7406\u5750\u6807\uff08\u7ecf\u5ea6\u3001\u7eac\u5ea6\uff09\u8f6c\u6362\u516c\u5f0f\u3001\u5e94\u7528Python\u7f16\u7a0b\u5b9e\u73b0\u3001\u9a8c\u8bc1\u7ed3\u679c\u3002<\/strong> \u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u516c\u5f0f\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528\u7403\u9762\u5750\u6807\u8f6c\u6362\u516c\u5f0f\u6765\u5b8c\u6210\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<ul>\n<li>x = R * cos(\u7eac\u5ea6) * cos(\u7ecf\u5ea6)<\/li>\n<li>y = R * cos(\u7eac\u5ea6) * sin(\u7ecf\u5ea6)<\/li>\n<li>z = R * sin(\u7eac\u5ea6)<\/li>\n<\/ul>\n<p><p>\u5176\u4e2d\uff0cR\u4e3a\u5730\u7403\u534a\u5f84\uff0c\u7eac\u5ea6\u548c\u7ecf\u5ea6\u9700\u8981\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728Python\u4e2d\u7f16\u5199\u4ee3\u7801\u5b9e\u73b0\u8f6c\u6362<\/strong>\uff1a\u4f7f\u7528Python\u4e2d\u7684\u6570\u5b66\u5e93\uff08\u5982math\uff09\u6765\u5b9e\u73b0\u4e0a\u8ff0\u516c\u5f0f\u7684\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u8f6c\u6362\u7ed3\u679c<\/strong>\uff1a\u901a\u8fc7\u5df2\u77e5\u7684\u7ecf\u7eac\u5ea6\u548cXYZ\u5750\u6807\u8fdb\u884c\u9a8c\u8bc1\uff0c\u786e\u4fdd\u8f6c\u6362\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e00\u3001\u516c\u5f0f\u8be6\u89e3<\/h3>\n<\/p>\n<p><p>\u5728\u5730\u7406\u5750\u6807\u7cfb\u4e2d\uff0c\u5730\u7403\u88ab\u8fd1\u4f3c\u4e3a\u4e00\u4e2a\u7403\u4f53\u3002\u7ecf\u5ea6\uff08Longitude\uff09\u548c\u7eac\u5ea6\uff08Latitude\uff09\u662f\u7528\u6765\u8868\u793a\u5730\u7403\u8868\u9762\u4e0a\u4efb\u610f\u4e00\u70b9\u7684\u4f4d\u7f6e\u7684\u89d2\u5ea6\u3002\u4e3a\u4e86\u5c06\u8fd9\u4e9b\u89d2\u5ea6\u8f6c\u6362\u4e3a\u4e09\u7ef4\u7a7a\u95f4\u4e2d\u7684XYZ\u5750\u6807\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u7403\u9762\u5750\u6807\u5230\u7b1b\u5361\u5c14\u5750\u6807\u7684\u8f6c\u6362\u516c\u5f0f\u3002<\/p>\n<\/p>\n<p><h4>1.1\u3001\u8f6c\u6362\u516c\u5f0f<\/h4>\n<\/p>\n<ul>\n<li>\u7ecf\u5ea6\uff08Longitude\uff09\uff0c\u8bb0\u4f5c\u03bb\uff08lambda\uff09\uff0c\u8303\u56f4\u4ece -180\u00b0 \u5230 180\u00b0\u3002<\/li>\n<li>\u7eac\u5ea6\uff08Latitude\uff09\uff0c\u8bb0\u4f5c\u03c6\uff08phi\uff09\uff0c\u8303\u56f4\u4ece -90\u00b0 \u5230 90\u00b0\u3002<\/li>\n<li>\u534a\u5f84\uff08R\uff09\uff0c\u5730\u7403\u7684\u5e73\u5747\u534a\u5f84\u7ea6\u4e3a6371\u516c\u91cc\u3002<\/li>\n<\/ul>\n<p><p>\u8f6c\u6362\u516c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>x = R * cos(\u03c6) * cos(\u03bb)<\/strong><\/li>\n<li><strong>y = R * cos(\u03c6) * sin(\u03bb)<\/strong><\/li>\n<li><strong>z = R * sin(\u03c6)<\/strong><\/li>\n<\/ul>\n<p><h4>1.2\u3001\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Python\u4e2d\u7684\u6570\u5b66\u51fd\u6570\uff08\u5982cos\u548csin\uff09\u65f6\uff0c\u9700\u8981\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5f27\u5ea6 = \u89d2\u5ea6 * \u03c0 \/ 180<\/strong><\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001Python\u5b9e\u73b0<\/h3>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684Python\u4ee3\u7801\u793a\u4f8b\uff0c\u7528\u4e8e\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>def lat_lon_to_xyz(latitude, longitude, radius=6371):<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    \u5c06\u5730\u7406\u5750\u6807\uff08\u7ecf\u7eac\u5ea6\uff09\u8f6c\u6362\u4e3a\u4e09\u7ef4\u7a7a\u95f4\u4e2d\u7684XYZ\u5750\u6807<\/p>\n<p>    \u53c2\u6570\uff1a<\/p>\n<p>    latitude -- \u7eac\u5ea6\uff0c\u8303\u56f4\u4ece -90\u00b0 \u5230 90\u00b0<\/p>\n<p>    longitude -- \u7ecf\u5ea6\uff0c\u8303\u56f4\u4ece -180\u00b0 \u5230 180\u00b0<\/p>\n<p>    radius -- \u5730\u7403\u534a\u5f84\uff0c\u9ed8\u8ba4\u4e3a6371\u516c\u91cc<\/p>\n<p>    \u8fd4\u56de\u503c\uff1a<\/p>\n<p>    (x, y, z) -- \u4e09\u7ef4\u7a7a\u95f4\u4e2d\u7684\u5750\u6807<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    # \u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<p>    phi = math.radians(latitude)<\/p>\n<p>    lambda_ = math.radians(longitude)<\/p>\n<p>    # \u4f7f\u7528\u8f6c\u6362\u516c\u5f0f\u8ba1\u7b97XYZ\u5750\u6807<\/p>\n<p>    x = radius * math.cos(phi) * math.cos(lambda_)<\/p>\n<p>    y = radius * math.cos(phi) * math.sin(lambda_)<\/p>\n<p>    z = radius * math.sin(phi)<\/p>\n<p>    return x, y, z<\/p>\n<h2><strong>\u793a\u4f8b\uff1a\u5c06\u67d0\u4e2a\u70b9\u7684\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807<\/strong><\/h2>\n<p>latitude = 37.7749  # \u65e7\u91d1\u5c71\u7684\u7eac\u5ea6<\/p>\n<p>longitude = -122.4194  # \u65e7\u91d1\u5c71\u7684\u7ecf\u5ea6<\/p>\n<p>x, y, z = lat_lon_to_xyz(latitude, longitude)<\/p>\n<p>print(f&quot;XYZ\u5750\u6807: x={x}, y={y}, z={z}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u9a8c\u8bc1\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u9a8c\u8bc1\u6211\u4eec\u7684\u8f6c\u6362\u7ed3\u679c\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u5df2\u77e5\u7684\u7ecf\u7eac\u5ea6\u548c\u5bf9\u5e94\u7684XYZ\u5750\u6807\uff0c\u786e\u4fdd\u6211\u4eec\u7684\u8ba1\u7b97\u662f\u6b63\u786e\u7684\u3002<\/p>\n<\/p>\n<p><h4>3.1\u3001\u5df2\u77e5\u70b9\u9a8c\u8bc1<\/h4>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5df2\u77e5\u67d0\u70b9\u7684\u7ecf\u7eac\u5ea6\u548cXYZ\u5750\u6807\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u7eac\u5ea6\uff1a0\u00b0\uff0c\u7ecf\u5ea6\uff1a0\u00b0\uff0c\u534a\u5f84\uff1a6371\u516c\u91cc<\/li>\n<li>\u9884\u671f\u7684XYZ\u5750\u6807\uff1a\uff086371, 0, 0\uff09<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u6211\u4eec\u7684\u51fd\u6570\u8ba1\u7b97\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">latitude = 0<\/p>\n<p>longitude = 0<\/p>\n<p>x, y, z = lat_lon_to_xyz(latitude, longitude)<\/p>\n<p>assert (round(x, 2), round(y, 2), round(z, 2)) == (6371, 0, 0), &quot;\u9a8c\u8bc1\u5931\u8d25&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2\u3001\u4e0d\u540c\u534a\u5f84\u7684\u9a8c\u8bc1<\/h4>\n<\/p>\n<p><p>\u4e0d\u540c\u7684\u534a\u5f84\u4e5f\u4f1a\u5f71\u54cdXYZ\u5750\u6807\u7684\u7ed3\u679c\u3002\u4f8b\u5982\uff0c\u67d0\u5730\u7403\u6a21\u578b\u7684\u534a\u5f84\u4e3a 6378.1 \u516c\u91cc\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">radius = 6378.1<\/p>\n<p>latitude = 45<\/p>\n<p>longitude = 45<\/p>\n<p>x, y, z = lat_lon_to_xyz(latitude, longitude, radius)<\/p>\n<p>print(f&quot;XYZ\u5750\u6807: x={x}, y={y}, z={z}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807\u5728\u5404\u79cd\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\uff08GIS\uff09\u3001\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u548c\u7269\u7406\u4eff\u771f\u4e2d\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><h4>4.1\u3001\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\uff08GIS\uff09<\/h4>\n<\/p>\n<p><p>\u5728GIS\u4e2d\uff0c\u7ecf\u7eac\u5ea6\u901a\u5e38\u7528\u4e8e\u8868\u793a\u5730\u7403\u8868\u9762\u4e0a\u7684\u70b9\u3002\u7136\u800c\uff0c\u5728\u8fdb\u884c\u4e09\u7ef4\u53ef\u89c6\u5316\u548c\u5206\u6790\u65f6\uff0c\u9700\u8981\u5c06\u8fd9\u4e9b\u70b9\u8f6c\u6362\u4e3aXYZ\u5750\u6807\u3002\u4f8b\u5982\uff0c\u5c55\u793a\u5730\u5f62\u9ad8\u5ea6\u6570\u636e\u6216\u8fdb\u884c\u5730\u9707\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h4>4.2\u3001\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66<\/h4>\n<\/p>\n<p><p>\u5728\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u4e2d\uff0c\u7403\u9762\u5750\u6807\u5230\u7b1b\u5361\u5c14\u5750\u6807\u7684\u8f6c\u6362\u7528\u4e8e\u7ed8\u5236\u7403\u4f53\u6216\u8fdb\u884c\u4e09\u7ef4\u5efa\u6a21\u3002\u4f8b\u5982\uff0c\u5728\u865a\u62df\u73b0\u5b9e\uff08VR\uff09\u548c\u589e\u5f3a\u73b0\u5b9e\uff08AR\uff09\u4e2d\u521b\u5efa\u5730\u7403\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><h4>4.3\u3001\u7269\u7406\u4eff\u771f<\/h4>\n<\/p>\n<p><p>\u5728\u7269\u7406\u4eff\u771f\u4e2d\uff0c\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807\u7528\u4e8e\u6a21\u62df\u5730\u7403\u4e0a\u7684\u7269\u4f53\u8fd0\u52a8\u3002\u4f8b\u5982\uff0c\u6a21\u62df\u536b\u661f\u8f68\u9053\u6216\u6c14\u8c61\u73b0\u8c61\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u6269\u5c55\u529f\u80fd<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u7ecf\u7eac\u5ea6\u5230XYZ\u5750\u6807\u7684\u8f6c\u6362\uff0c\u8fd8\u53ef\u4ee5\u6269\u5c55\u66f4\u591a\u529f\u80fd\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><h4>5.1\u3001\u6279\u91cf\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5927\u91cf\u7684\u5730\u7406\u6570\u636e\uff0c\u53ef\u4ee5\u7f16\u5199\u51fd\u6570\u6279\u91cf\u8f6c\u6362\u7ecf\u7eac\u5ea6\u5230XYZ\u5750\u6807\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def batch_lat_lon_to_xyz(coordinates, radius=6371):<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    \u6279\u91cf\u5c06\u5730\u7406\u5750\u6807\u8f6c\u6362\u4e3aXYZ\u5750\u6807<\/p>\n<p>    \u53c2\u6570\uff1a<\/p>\n<p>    coordinates -- \u5305\u542b\u591a\u4e2a\u5730\u7406\u5750\u6807\u7684\u5217\u8868\uff0c\u6bcf\u4e2a\u5730\u7406\u5750\u6807\u662f\u4e00\u4e2a\u5143\u7ec4 (latitude, longitude)<\/p>\n<p>    radius -- \u5730\u7403\u534a\u5f84\uff0c\u9ed8\u8ba4\u4e3a6371\u516c\u91cc<\/p>\n<p>    \u8fd4\u56de\u503c\uff1a<\/p>\n<p>    \u5305\u542b\u591a\u4e2aXYZ\u5750\u6807\u7684\u5217\u8868\uff0c\u6bcf\u4e2aXYZ\u5750\u6807\u662f\u4e00\u4e2a\u5143\u7ec4 (x, y, z)<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    xyz_coordinates = []<\/p>\n<p>    for latitude, longitude in coordinates:<\/p>\n<p>        xyz_coordinates.append(lat_lon_to_xyz(latitude, longitude, radius))<\/p>\n<p>    return xyz_coordinates<\/p>\n<h2><strong>\u793a\u4f8b\uff1a\u6279\u91cf\u8f6c\u6362\u591a\u4e2a\u70b9\u7684\u7ecf\u7eac\u5ea6<\/strong><\/h2>\n<p>coordinates = [(0, 0), (37.7749, -122.4194), (45, 45)]<\/p>\n<p>xyz_coordinates = batch_lat_lon_to_xyz(coordinates)<\/p>\n<p>print(f&quot;\u6279\u91cf\u8f6c\u6362\u7684XYZ\u5750\u6807: {xyz_coordinates}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.2\u3001\u53cd\u5411\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u4eceXYZ\u5750\u6807\u53cd\u5411\u8f6c\u6362\u4e3a\u7ecf\u7eac\u5ea6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def xyz_to_lat_lon(x, y, z):<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    \u5c06XYZ\u5750\u6807\u8f6c\u6362\u4e3a\u5730\u7406\u5750\u6807\uff08\u7ecf\u7eac\u5ea6\uff09<\/p>\n<p>    \u53c2\u6570\uff1a<\/p>\n<p>    x, y, z -- XYZ\u5750\u6807<\/p>\n<p>    \u8fd4\u56de\u503c\uff1a<\/p>\n<p>    (latitude, longitude) -- \u5730\u7406\u5750\u6807<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    radius = math.sqrt(x&lt;strong&gt;2 + y&lt;\/strong&gt;2 + z2)<\/p>\n<p>    latitude = math.degrees(math.asin(z \/ radius))<\/p>\n<p>    longitude = math.degrees(math.atan2(y, x))<\/p>\n<p>    return latitude, longitude<\/p>\n<h2><strong>\u793a\u4f8b\uff1a\u5c06XYZ\u5750\u6807\u8f6c\u6362\u4e3a\u7ecf\u7eac\u5ea6<\/strong><\/h2>\n<p>x, y, z = 6371, 0, 0<\/p>\n<p>latitude, longitude = xyz_to_lat_lon(x, y, z)<\/p>\n<p>print(f&quot;\u7ecf\u7eac\u5ea6: latitude={latitude}, longitude={longitude}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Python\u4e2d\u5c06\u5730\u7406\u5750\u6807\uff08\u7ecf\u7eac\u5ea6\uff09\u8f6c\u6362\u4e3aXYZ\u5750\u6807\uff0c\u5e76\u8fdb\u884c\u9a8c\u8bc1\u548c\u5e94\u7528\u3002<strong>\u5173\u952e\u6b65\u9aa4\u5305\u62ec\u4f7f\u7528\u8f6c\u6362\u516c\u5f0f\u3001\u7f16\u5199Python\u4ee3\u7801\u5b9e\u73b0\u8f6c\u6362\u3001\u9a8c\u8bc1\u7ed3\u679c\u4ee5\u53ca\u6269\u5c55\u529f\u80fd<\/strong>\u3002\u8fd9\u4e9b\u65b9\u6cd5\u548c\u5de5\u5177\u5728\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\u3001\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u548c\u7269\u7406\u4eff\u771f\u7b49\u9886\u57df\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u901a\u8fc7\u6279\u91cf\u8f6c\u6362\u548c\u53cd\u5411\u8f6c\u6362\u529f\u80fd\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6269\u5c55\u548c\u5e94\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5904\u7406\u66f4\u591a\u590d\u6742\u7684\u5730\u7406\u6570\u636e\u548c\u4e09\u7ef4\u6a21\u578b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3axyz\u5750\u6807\u7684\u57fa\u672c\u539f\u7406\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u7ecf\u7eac\u5ea6\u662f\u5730\u7403\u8868\u9762\u4f4d\u7f6e\u7684\u8868\u793a\u65b9\u5f0f\uff0c\u800cxyz\u5750\u6807\u5219\u662f\u4e09\u7ef4\u7a7a\u95f4\u4e2d\u7684\u4e00\u79cd\u8868\u793a\u65b9\u6cd5\u3002\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3axyz\u5750\u6807\u7684\u57fa\u672c\u539f\u7406\u662f\u5229\u7528\u5730\u7403\u7684\u534a\u5f84\u548c\u7ecf\u7eac\u5ea6\u7684\u6570\u5b66\u5173\u7cfb\uff0c\u5c06\u7403\u9762\u5750\u6807\u7cfb\u8f6c\u6362\u4e3a\u76f4\u89d2\u5750\u6807\u7cfb\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u516c\u5f0f\u8fdb\u884c\u8f6c\u6362\uff1a  <\/p>\n<ul>\n<li>x = R * cos(\u7eac\u5ea6) * cos(\u7ecf\u5ea6)  <\/li>\n<li>y = R * cos(\u7eac\u5ea6) * sin(\u7ecf\u5ea6)  <\/li>\n<li>z = R * sin(\u7eac\u5ea6)<br \/>\u5176\u4e2dR\u4e3a\u5730\u7403\u7684\u5e73\u5747\u534a\u5f84\uff08\u7ea66371\u516c\u91cc\uff09\u3002<\/li>\n<\/ul>\n<p><strong>\u5728Python\u4e2d\uff0c\u6709\u54ea\u4e9b\u5e93\u53ef\u4ee5\u5e2e\u52a9\u5b9e\u73b0\u7ecf\u7eac\u5ea6\u5230xyz\u5750\u6807\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u5e93\u6765\u5b9e\u73b0\u8fd9\u4e00\u8f6c\u6362\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecNumPy\u548cSciPy\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u5b66\u8ba1\u7b97\u529f\u80fd\u3002\u53e6\u4e00\u4e2a\u9009\u62e9\u662fpyproj\u5e93\uff0c\u5b83\u4e13\u95e8\u7528\u4e8e\u5750\u6807\u8f6c\u6362\u548c\u5730\u56fe\u6295\u5f71\uff0c\u80fd\u591f\u66f4\u65b9\u4fbf\u5730\u5904\u7406\u7ecf\u7eac\u5ea6\u4e0exyz\u5750\u6807\u4e4b\u95f4\u7684\u8f6c\u6362\u3002\u4f7f\u7528\u8fd9\u4e9b\u5e93\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u8ba1\u7b97\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u6548\u7387\u3002<\/p>\n<p><strong>\u8f6c\u6362\u540e\u7684xyz\u5750\u6807\u6709\u4ec0\u4e48\u5b9e\u9645\u5e94\u7528\uff1f<\/strong><br \/>\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3axyz\u5750\u6807\u5728\u591a\u4e2a\u9886\u57df\u90fd\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u5728\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\uff08GIS\uff09\u4e2d\uff0cxyz\u5750\u6807\u7528\u4e8e\u7a7a\u95f4\u5206\u6790\u548c\u6570\u636e\u53ef\u89c6\u5316\uff1b\u5728\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u4e2d\uff0cxyz\u5750\u6807\u7528\u4e8e3D\u5efa\u6a21\u548c\u6e32\u67d3\uff1b\u5728\u822a\u7a7a\u822a\u5929\u5de5\u7a0b\u4e2d\uff0c\u5b83\u4eec\u7528\u4e8e\u5b9a\u4f4d\u548c\u5bfc\u822a\u3002\u901a\u8fc7\u8fd9\u4e9b\u5750\u6807\uff0c\u80fd\u591f\u66f4\u7cbe\u786e\u5730\u8fdb\u884c\u4f4d\u7f6e\u8ba1\u7b97\u3001\u5efa\u6a21\u548c\u6570\u636e\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3aXYZ\u5750\u6807\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4e3b\u8981\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528\u5730\u7406\u5750\u6807\uff08\u7ecf\u5ea6\u3001\u7eac\u5ea6\uff09\u8f6c\u6362\u516c\u5f0f [&hellip;]","protected":false},"author":3,"featured_media":1135274,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1135272"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1135272"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1135272\/revisions"}],"predecessor-version":[{"id":1135275,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1135272\/revisions\/1135275"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1135274"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1135272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1135272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1135272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}