{"id":1180628,"date":"2025-01-15T18:39:54","date_gmt":"2025-01-15T10:39:54","guid":{"rendered":""},"modified":"2025-01-15T18:40:14","modified_gmt":"2025-01-15T10:40:14","slug":"python%e5%a6%82%e4%bd%95%e8%bd%ac%e5%8c%96%e5%9d%90%e6%a0%87%e7%b3%bb","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1180628.html","title":{"rendered":"python\u5982\u4f55\u8f6c\u5316\u5750\u6807\u7cfb"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25125301\/c317ef7f-9220-451e-adb4-2cd20f12347e.webp\" alt=\"python\u5982\u4f55\u8f6c\u5316\u5750\u6807\u7cfb\" \/><\/p>\n<p><p> <strong>Python \u8f6c\u5316\u5750\u6807\u7cfb\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u6570\u5b66\u516c\u5f0f\u3001\u5229\u7528\u7b2c\u4e09\u65b9\u5e93\u5982Numpy\u548cScipy\u3001\u4ee5\u53ca\u4e13\u95e8\u5904\u7406\u5730\u7406\u7a7a\u95f4\u6570\u636e\u7684\u5e93\u5982Geopandas\u548cPyproj\u3002<\/strong> \u5176\u4e2d\uff0c<strong>\u4f7f\u7528Pyproj\u5e93<\/strong> \u662f\u8f83\u4e3a\u7b80\u4fbf\u548c\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5750\u6807\u7cfb\u8f6c\u6362\u5de5\u5177\u548c\u652f\u6301\u591a\u79cd\u5730\u7406\u5750\u6807\u7cfb\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Pyproj\u5e93\u6765\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001PYPROJ \u5e93\u6982\u8ff0<\/h2>\n<\/p>\n<p><p>Pyproj\u662f\u4e00\u4e2aPython\u5e93\uff0c\u7528\u4e8e\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u548c\u5176\u4ed6\u5730\u7406\u7a7a\u95f4\u8ba1\u7b97\u3002\u5b83\u662fProj\u5e93\u7684Python\u7ed1\u5b9a\uff0cProj\u662f\u4e00\u4e2a\u5f00\u6e90\u5e93\uff0c\u7528\u4e8e\u5730\u56fe\u6295\u5f71\u548c\u5750\u6807\u8f6c\u6362\u3002Pyproj\u5e93\u53ef\u4ee5\u5904\u7406\u5404\u79cd\u5730\u7406\u5750\u6807\u7cfb\u7edf\uff0c\u5305\u62ec\u5927\u5730\u5750\u6807\u7cfb\u3001\u6295\u5f71\u5750\u6807\u7cfb\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Pyproj<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Pyproj\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528pip\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyproj<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>Pyproj \u57fa\u672c\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>Pyproj\u5e93\u7684\u6838\u5fc3\u529f\u80fd\u662f\u901a\u8fc7<code>Transformer<\/code>\u7c7b\u6765\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u3002<code>Transformer<\/code>\u7c7b\u7684\u4e3b\u8981\u65b9\u6cd5\u662f<code>transform<\/code>\uff0c\u7528\u4e8e\u5c06\u4e00\u7ec4\u5750\u6807\u4ece\u4e00\u4e2a\u5750\u6807\u7cfb\u8f6c\u6362\u5230\u53e6\u4e00\u4e2a\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Pyproj\u5e93\u5c06WGS84\u5750\u6807\u7cfb\uff08\u901a\u5e38\u7528\u4e8eGPS\uff09\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(&quot;EPSG:4326&quot;, &quot;EPSG:32633&quot;)<\/p>\n<h2><strong>WGS84\u5750\u6807\u7cfb\u7684\u7ecf\u7eac\u5ea6\u5750\u6807<\/strong><\/h2>\n<p>latitude = 60.0<\/p>\n<p>longitude = 10.0<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>easting, northing = transformer.transform(latitude, longitude)<\/p>\n<p>print(f&quot;Easting: {easting}, Northing: {northing}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u4eceWGS84\u5750\u6807\u7cfb\uff08EPSG:4326\uff09\u5230UTM\u5750\u6807\u7cfb\uff08EPSG:32633\uff09\u7684Transformer\u5bf9\u8c61\uff0c\u5e76\u4f7f\u7528\u8fd9\u4e2a\u5bf9\u8c61\u5c06\u4e00\u5bf9\u7ecf\u7eac\u5ea6\u5750\u6807\u8f6c\u6362\u4e3aUTM\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001COORDINATE TRANSFORMATION \u6982\u5ff5<\/h2>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u4e4b\u524d\uff0c\u6709\u5fc5\u8981\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u7684\u6982\u5ff5\u548c\u672f\u8bed\u3002<\/p>\n<\/p>\n<p><h3>\u5750\u6807\u7cfb<\/h3>\n<\/p>\n<p><p>\u5750\u6807\u7cfb\uff08Coordinate System\uff09\u662f\u7528\u4e8e\u8868\u793a\u5730\u7403\u8868\u9762\u4f4d\u7f6e\u7684\u4e00\u79cd\u7cfb\u7edf\u3002\u5e38\u89c1\u7684\u5750\u6807\u7cfb\u5305\u62ec\u5927\u5730\u5750\u6807\u7cfb\u548c\u6295\u5f71\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5927\u5730\u5750\u6807\u7cfb<\/strong>\uff1a\u57fa\u4e8e\u5730\u7403\u692d\u7403\u4f53\u7684\u5750\u6807\u7cfb\u7edf\uff0c\u901a\u5e38\u4f7f\u7528\u7ecf\u7eac\u5ea6\uff08Latitude, Longitude\uff09\u6765\u8868\u793a\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0cWGS84\uff08World Geodetic System 1984\uff09\u662f\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684\u5927\u5730\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6295\u5f71\u5750\u6807\u7cfb<\/strong>\uff1a\u5c06\u5730\u7403\u8868\u9762\u7684\u4e09\u7ef4\u5750\u6807\u6295\u5f71\u5230\u4e8c\u7ef4\u5e73\u9762\u4e0a\u7684\u5750\u6807\u7cfb\u7edf\uff0c\u901a\u5e38\u4f7f\u7528\u5e73\u9762\u5750\u6807\uff08Easting, Northing\uff09\u6765\u8868\u793a\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0cUTM\uff08Universal Transverse Mercator\uff09\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u6295\u5f71\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5750\u6807\u7cfb\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u5750\u6807\u7cfb\u8f6c\u6362\uff08Coordinate Transformation\uff09\u662f\u5c06\u4e00\u7ec4\u5750\u6807\u4ece\u4e00\u4e2a\u5750\u6807\u7cfb\u8f6c\u6362\u5230\u53e6\u4e00\u4e2a\u5750\u6807\u7cfb\u7684\u8fc7\u7a0b\u3002\u8fd9\u901a\u5e38\u6d89\u53ca\u5230\u590d\u6742\u7684\u6570\u5b66\u8ba1\u7b97\uff0c\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5927\u5730\u5750\u6807\u8f6c\u6362<\/strong>\uff1a\u5728\u4e0d\u540c\u7684\u5927\u5730\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\u4eceWGS84\u8f6c\u6362\u5230NAD83\uff08North American Datum 1983\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6295\u5f71\u8f6c\u6362<\/strong>\uff1a\u5728\u5927\u5730\u5750\u6807\u7cfb\u548c\u6295\u5f71\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\u4eceWGS84\u8f6c\u6362\u5230UTM\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u590d\u5408\u8f6c\u6362<\/strong>\uff1a\u540c\u65f6\u8fdb\u884c\u5927\u5730\u5750\u6807\u8f6c\u6362\u548c\u6295\u5f71\u8f6c\u6362\uff0c\u4f8b\u5982\u4eceWGS84\u8f6c\u6362\u5230\u67d0\u4e2a\u7279\u5b9a\u533a\u57df\u7684\u6295\u5f71\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4f7f\u7528Pyproj\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>Pyproj\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5750\u6807\u7cfb\u8f6c\u6362\u529f\u80fd\uff0c\u53ef\u4ee5\u5904\u7406\u5404\u79cd\u7c7b\u578b\u7684\u5750\u6807\u7cfb\u8f6c\u6362\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u4f7f\u7528\u573a\u666f\u548c\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u5e38\u89c1\u7684\u5750\u6807\u7cfb\u8f6c\u6362<\/h2>\n<\/p>\n<p><h3>\u5927\u5730\u5750\u6807\u7cfb\u4e4b\u95f4\u7684\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u5728\u4e0d\u540c\u7684\u5927\u5730\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u4eceWGS84\u8f6c\u6362\u5230NAD83\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(&quot;EPSG:4326&quot;, &quot;EPSG:4269&quot;)<\/p>\n<h2><strong>WGS84\u5750\u6807\u7cfb\u7684\u7ecf\u7eac\u5ea6\u5750\u6807<\/strong><\/h2>\n<p>latitude = 40.7128<\/p>\n<p>longitude = -74.0060<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aNAD83\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>latitude_nad83, longitude_nad83 = transformer.transform(latitude, longitude)<\/p>\n<p>print(f&quot;NAD83 Latitude: {latitude_nad83}, Longitude: {longitude_nad83}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u5bf9WGS84\u5750\u6807\u8f6c\u6362\u4e3aNAD83\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h3>\u5927\u5730\u5750\u6807\u7cfb\u5230\u6295\u5f71\u5750\u6807\u7cfb\u7684\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u5c06\u5927\u5730\u5750\u6807\u7cfb\u8f6c\u6362\u4e3a\u6295\u5f71\u5750\u6807\u7cfb\u662f\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\uff08GIS\uff09\u4e2d\u7684\u5e38\u89c1\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u4eceWGS84\u8f6c\u6362\u5230UTM\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(&quot;EPSG:4326&quot;, &quot;EPSG:32633&quot;)<\/p>\n<h2><strong>WGS84\u5750\u6807\u7cfb\u7684\u7ecf\u7eac\u5ea6\u5750\u6807<\/strong><\/h2>\n<p>latitude = 60.0<\/p>\n<p>longitude = 10.0<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>easting, northing = transformer.transform(latitude, longitude)<\/p>\n<p>print(f&quot;Easting: {easting}, Northing: {northing}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u5bf9WGS84\u5750\u6807\u8f6c\u6362\u4e3aUTM\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h3>\u6295\u5f71\u5750\u6807\u7cfb\u4e4b\u95f4\u7684\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u5728\u4e0d\u540c\u7684\u6295\u5f71\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u4e5f\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u4eceUTM\u8f6c\u6362\u5230State Plane\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(&quot;EPSG:32633&quot;, &quot;EPSG:32118&quot;)<\/p>\n<h2><strong>UTM\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>easting = 500000<\/p>\n<p>northing = 4649776<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aState Plane\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>easting_sp, northing_sp = transformer.transform(easting, northing)<\/p>\n<p>print(f&quot;State Plane Easting: {easting_sp}, Northing: {northing_sp}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u5bf9UTM\u5750\u6807\u8f6c\u6362\u4e3aState Plane\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u6279\u91cf\u5750\u6807\u8f6c\u6362<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u5bf9\u5927\u91cf\u7684\u5750\u6807\u8fdb\u884c\u8f6c\u6362\u3002Pyproj\u5e93\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6279\u91cf\u8f6c\u6362\u529f\u80fd\uff0c\u53ef\u4ee5\u4e00\u6b21\u6027\u5904\u7406\u5927\u91cf\u7684\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Pyproj\u5e93\u5bf9\u4e00\u7ec4\u5750\u6807\u8fdb\u884c\u6279\u91cf\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(&quot;EPSG:4326&quot;, &quot;EPSG:32633&quot;)<\/p>\n<h2><strong>\u4e00\u7ec4WGS84\u5750\u6807\u7cfb\u7684\u7ecf\u7eac\u5ea6\u5750\u6807<\/strong><\/h2>\n<p>coordinates = [<\/p>\n<p>    (60.0, 10.0),<\/p>\n<p>    (61.0, 11.0),<\/p>\n<p>    (62.0, 12.0),<\/p>\n<p>    (63.0, 13.0)<\/p>\n<p>]<\/p>\n<h2><strong>\u6279\u91cf\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>utm_coordinates = [transformer.transform(lat, lon) for lat, lon in coordinates]<\/p>\n<p>for lat, lon, (easting, northing) in zip(coordinates, utm_coordinates):<\/p>\n<p>    print(f&quot;Latitude: {lat}, Longitude: {lon} -&gt; Easting: {easting}, Northing: {northing}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u7ec4WGS84\u5750\u6807\u6279\u91cf\u8f6c\u6362\u4e3aUTM\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u5904\u7406\u9ad8\u5ea6\u4fe1\u606f<\/h2>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u65f6\uff0c\u6709\u65f6\u9700\u8981\u8003\u8651\u9ad8\u5ea6\u4fe1\u606f\uff08Elevation\uff09\u3002Pyproj\u5e93\u652f\u6301\u5904\u7406\u4e09\u7ef4\u5750\u6807\uff0c\u5305\u62ec\u7ecf\u5ea6\u3001\u7eac\u5ea6\u548c\u9ad8\u5ea6\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Pyproj\u5e93\u5c06\u5e26\u6709\u9ad8\u5ea6\u4fe1\u606f\u7684WGS84\u5750\u6807\u8f6c\u6362\u4e3aUTM\u5750\u6807\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(&quot;EPSG:4326&quot;, &quot;EPSG:32633&quot;)<\/p>\n<h2><strong>WGS84\u5750\u6807\u7cfb\u7684\u7ecf\u7eac\u5ea6\u548c\u9ad8\u5ea6\u5750\u6807<\/strong><\/h2>\n<p>latitude = 60.0<\/p>\n<p>longitude = 10.0<\/p>\n<p>elevation = 500.0<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>easting, northing, elevation_utm = transformer.transform(latitude, longitude, elevation)<\/p>\n<p>print(f&quot;Easting: {easting}, Northing: {northing}, Elevation: {elevation_utm}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u5e26\u6709\u9ad8\u5ea6\u4fe1\u606f\u7684\u4e00\u5bf9WGS84\u5750\u6807\u8f6c\u6362\u4e3aUTM\u5750\u6807\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u5750\u6807\u7cfb\u8f6c\u6362\u7684\u8bef\u5dee\u4e0e\u7cbe\u5ea6<\/h2>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u65f6\uff0c\u4e86\u89e3\u8f6c\u6362\u8bef\u5dee\u548c\u7cbe\u5ea6\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4e0d\u540c\u7684\u5750\u6807\u7cfb\u4e4b\u95f4\u5b58\u5728\u4e00\u5b9a\u7684\u8f6c\u6362\u8bef\u5dee\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5f71\u54cd\u5230\u5e94\u7528\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u8f6c\u6362\u8bef\u5dee\u7684\u6765\u6e90<\/h3>\n<\/p>\n<p><p>\u8f6c\u6362\u8bef\u5dee\u7684\u6765\u6e90\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u692d\u7403\u6a21\u578b\u5dee\u5f02<\/strong>\uff1a\u4e0d\u540c\u7684\u5927\u5730\u5750\u6807\u7cfb\u4f7f\u7528\u4e0d\u540c\u7684\u692d\u7403\u6a21\u578b\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u4e00\u5b9a\u7684\u8bef\u5dee\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6295\u5f71\u65b9\u6cd5<\/strong>\uff1a\u4e0d\u540c\u7684\u6295\u5f71\u65b9\u6cd5\u4f1a\u5f15\u5165\u4e0d\u540c\u7a0b\u5ea6\u7684\u8bef\u5dee\uff0c\u5c24\u5176\u662f\u5728\u5927\u9762\u79ef\u6216\u6781\u7aef\u5730\u5f62\u533a\u57df\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u503c\u8ba1\u7b97\u8bef\u5dee<\/strong>\uff1a\u5728\u8fdb\u884c\u5750\u6807\u8f6c\u6362\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6570\u503c\u8ba1\u7b97\u8bef\u5dee\u4e5f\u4f1a\u7d2f\u79ef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u7cbe\u5ea6\u8bc4\u4f30<\/h3>\n<\/p>\n<p><p>\u8bc4\u4f30\u8f6c\u6362\u7cbe\u5ea6\u7684\u4e00\u79cd\u65b9\u6cd5\u662f\u6bd4\u8f83\u8f6c\u6362\u524d\u540e\u7684\u5750\u6807\u5dee\u5f02\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u8bc4\u4f30\u4eceWGS84\u8f6c\u6362\u5230UTM\u7684\u7cbe\u5ea6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u521b\u5efaTransformer\u5bf9\u8c61<\/strong><\/h2>\n<p>transformer_to_utm = Transformer.from_crs(&quot;EPSG:4326&quot;, &quot;EPSG:32633&quot;)<\/p>\n<p>transformer_to_wgs84 = Transformer.from_crs(&quot;EPSG:32633&quot;, &quot;EPSG:4326&quot;)<\/p>\n<h2><strong>WGS84\u5750\u6807\u7cfb\u7684\u7ecf\u7eac\u5ea6\u5750\u6807<\/strong><\/h2>\n<p>latitude = 60.0<\/p>\n<p>longitude = 10.0<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>easting, northing = transformer_to_utm.transform(latitude, longitude)<\/p>\n<h2><strong>\u8f6c\u6362\u56deWGS84\u5750\u6807\u7cfb\u7684\u5750\u6807<\/strong><\/h2>\n<p>latitude_back, longitude_back = transformer_to_wgs84.transform(easting, northing)<\/p>\n<h2><strong>\u8ba1\u7b97\u8bef\u5dee<\/strong><\/h2>\n<p>latitude_error = latitude_back - latitude<\/p>\n<p>longitude_error = longitude_back - longitude<\/p>\n<p>print(f&quot;Latitude Error: {latitude_error}, Longitude Error: {longitude_error}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5c06\u4e00\u5bf9WGS84\u5750\u6807\u8f6c\u6362\u4e3aUTM\u5750\u6807\uff0c\u7136\u540e\u518d\u8f6c\u6362\u56deWGS84\u5750\u6807\uff0c\u5e76\u8ba1\u7b97\u8f6c\u6362\u524d\u540e\u5750\u6807\u7684\u8bef\u5dee\u3002<\/p>\n<\/p>\n<p><h2>\u4e03\u3001\u4f7f\u7528Geopandas\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362<\/h2>\n<\/p>\n<p><p>Geopandas\u662f\u4e00\u4e2a\u7528\u4e8e\u5904\u7406\u5730\u7406\u7a7a\u95f4\u6570\u636e\u7684Python\u5e93\uff0c\u5b83\u57fa\u4e8ePandas\u5e93\uff0c\u5e76\u6269\u5c55\u4e86\u5bf9\u5730\u7406\u6570\u636e\u7684\u652f\u6301\u3002Geopandas\u5185\u90e8\u4f7f\u7528Pyproj\u5e93\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Geopandas<\/h3>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528pip\u6765\u5b89\u88c5Geopandas\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install geopandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u793a\u4f8b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Geopandas\u5e93\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import geopandas as gpd<\/p>\n<p>from shapely.geometry import Point<\/p>\n<h2><strong>\u521b\u5efaGeoDataFrame<\/strong><\/h2>\n<p>data = {&#39;geometry&#39;: [Point(10.0, 60.0), Point(11.0, 61.0), Point(12.0, 62.0)]}<\/p>\n<p>gdf = gpd.GeoDataFrame(data, crs=&quot;EPSG:4326&quot;)<\/p>\n<h2><strong>\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb<\/strong><\/h2>\n<p>gdf_utm = gdf.to_crs(&quot;EPSG:32633&quot;)<\/p>\n<p>print(gdf_utm)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542bWGS84\u5750\u6807\u7684GeoDataFrame\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3aUTM\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<p><h2>\u516b\u3001\u5904\u7406\u5730\u7406\u7a7a\u95f4\u6570\u636e\u7684\u5176\u4ed6\u5e93<\/h2>\n<\/p>\n<p><p>\u9664\u4e86Pyproj\u548cGeopandas\uff0c\u8fd8\u6709\u5176\u4ed6\u4e00\u4e9b\u5e93\u53ef\u4ee5\u7528\u4e8e\u5904\u7406\u5730\u7406\u7a7a\u95f4\u6570\u636e\u548c\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h3>Fiona<\/h3>\n<\/p>\n<p><p>Fiona\u662f\u4e00\u4e2a\u7528\u4e8e\u8bfb\u5199\u5730\u7406\u7a7a\u95f4\u6587\u4ef6\u7684Python\u5e93\uff0c\u652f\u6301\u591a\u79cd\u6587\u4ef6\u683c\u5f0f\uff0c\u5305\u62ecShapefile\u3001GeoJSON\u7b49\u3002Fiona\u53ef\u4ee5\u4e0ePyproj\u548cGeopandas\u914d\u5408\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h3>Shapely<\/h3>\n<\/p>\n<p><p>Shapely\u662f\u4e00\u4e2a\u7528\u4e8e\u64cd\u4f5c\u548c\u5206\u6790\u51e0\u4f55\u5bf9\u8c61\u7684Python\u5e93\uff0c\u652f\u6301\u51e0\u4f55\u5bf9\u8c61\u7684\u521b\u5efa\u3001\u64cd\u4f5c\u548c\u5206\u6790\u3002Shapely\u53ef\u4ee5\u4e0ePyproj\u548cGeopandas\u914d\u5408\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h3>Rasterio<\/h3>\n<\/p>\n<p><p>Rasterio\u662f\u4e00\u4e2a\u7528\u4e8e\u8bfb\u5199\u6805\u683c\u6570\u636e\u7684Python\u5e93\uff0c\u652f\u6301\u591a\u79cd\u6805\u683c\u6587\u4ef6\u683c\u5f0f\u3002Rasterio\u53ef\u4ee5\u4e0ePyproj\u548cGeopandas\u914d\u5408\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h2>\u4e5d\u3001\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u5750\u6807\u7cfb\u8f6c\u6362<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5750\u6807\u7cfb\u8f6c\u6362\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u9886\u57df\uff0c\u5305\u62ec\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\uff08GIS\uff09\u3001\u9065\u611f\u3001\u5bfc\u822a\u3001\u5de5\u7a0b\u6d4b\u91cf\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u5730\u7406\u4fe1\u606f\u7cfb\u7edf\uff08GIS\uff09<\/h3>\n<\/p>\n<p><p>\u5728GIS\u5e94\u7528\u4e2d\uff0c\u5750\u6807\u7cfb\u8f6c\u6362\u7528\u4e8e\u5c06\u4e0d\u540c\u6765\u6e90\u7684\u5730\u7406\u7a7a\u95f4\u6570\u636e\u7edf\u4e00\u5230\u4e00\u4e2a\u5171\u540c\u7684\u5750\u6807\u7cfb\uff0c\u4ee5\u4fbf\u8fdb\u884c\u7a7a\u95f4\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><h3>\u9065\u611f<\/h3>\n<\/p>\n<p><p>\u5728\u9065\u611f\u5e94\u7528\u4e2d\uff0c\u5750\u6807\u7cfb\u8f6c\u6362\u7528\u4e8e\u5c06\u536b\u661f\u5f71\u50cf\u548c\u5176\u4ed6\u9065\u611f\u6570\u636e\u4ece\u539f\u59cb\u6295\u5f71\u8f6c\u6362\u5230\u76ee\u6807\u533a\u57df\u7684\u5750\u6807\u7cfb\uff0c\u4ee5\u4fbf\u8fdb\u884c\u56fe\u50cf\u914d\u51c6\u548c\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h3>\u5bfc\u822a<\/h3>\n<\/p>\n<p><p>\u5728\u5bfc\u822a\u5e94\u7528\u4e2d\uff0c\u5750\u6807\u7cfb\u8f6c\u6362\u7528\u4e8e\u5c06GPS\u5750\u6807\u8f6c\u6362\u4e3a\u5f53\u5730\u7684\u6295\u5f71\u5750\u6807\u7cfb\uff0c\u4ee5\u4fbf\u8fdb\u884c\u8def\u5f84\u89c4\u5212\u548c\u5bfc\u822a\u3002<\/p>\n<\/p>\n<p><h3>\u5de5\u7a0b\u6d4b\u91cf<\/h3>\n<\/p>\n<p><p>\u5728\u5de5\u7a0b\u6d4b\u91cf\u5e94\u7528\u4e2d\uff0c\u5750\u6807\u7cfb\u8f6c\u6362\u7528\u4e8e\u5c06\u6d4b\u91cf\u6570\u636e\u4ece\u73b0\u573a\u5750\u6807\u7cfb\u8f6c\u6362\u4e3a\u5de5\u7a0b\u8bbe\u8ba1\u5750\u6807\u7cfb\uff0c\u4ee5\u4fbf\u8fdb\u884c\u8bbe\u8ba1\u548c\u65bd\u5de5\u3002<\/p>\n<\/p>\n<p><h2>\u5341\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\uff0c\u91cd\u70b9\u4ecb\u7ecd\u4e86Pyproj\u5e93\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u4ee5\u53ca\u5e38\u89c1\u7684\u5750\u6807\u7cfb\u8f6c\u6362\u573a\u666f\u3002\u6211\u4eec\u8fd8\u8ba8\u8bba\u4e86\u6279\u91cf\u5750\u6807\u8f6c\u6362\u3001\u5904\u7406\u9ad8\u5ea6\u4fe1\u606f\u3001\u8f6c\u6362\u8bef\u5dee\u4e0e\u7cbe\u5ea6\u8bc4\u4f30\uff0c\u4ee5\u53ca\u4f7f\u7528Geopandas\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u7b49\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u76f8\u4fe1\u8bfb\u8005\u5df2\u7ecf\u638c\u63e1\u4e86Python\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u7684\u57fa\u672c\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u9002\u5408\u7684\u5e93\u548c\u65b9\u6cd5\uff0c\u8fdb\u884c\u9ad8\u6548\u3001\u51c6\u786e\u7684\u5750\u6807\u7cfb\u8f6c\u6362\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u5750\u6807\u7cfb\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5750\u6807\u7cfb\u8f6c\u6362\u901a\u5e38\u4f7f\u7528\u6570\u5b66\u5e93\u8fdb\u884c\u5904\u7406\uff0c\u5982NumPy\u6216SciPy\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u8fdb\u884c\u5750\u6807\u53d8\u6362\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u8f6c\u6362\u77e9\u9635\u6765\u6539\u53d8\u5750\u6807\u7cfb\uff0c\u6216\u8005\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u6765\u8f6c\u6362\u6781\u5750\u6807\u548c\u7b1b\u5361\u5c14\u5750\u6807\u3002\u5177\u4f53\u5b9e\u73b0\u53ef\u4ee5\u53c2\u8003\u76f8\u5173\u6587\u6863\u6216\u5728\u7ebf\u6559\u7a0b\uff0c\u4e86\u89e3\u5982\u4f55\u5e94\u7528\u8fd9\u4e9b\u5e93\u8fdb\u884c\u5750\u6807\u7cfb\u7684\u8f6c\u6362\u3002<\/p>\n<p><strong>\u5728\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u65f6\uff0c\u5e38\u89c1\u7684\u6ce8\u610f\u4e8b\u9879\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u8fdb\u884c\u5750\u6807\u7cfb\u8f6c\u6362\u65f6\uff0c\u9700\u6ce8\u610f\u5750\u6807\u7cfb\u7684\u539f\u70b9\u548c\u65b9\u5411\u3002\u4e0d\u540c\u7684\u5750\u6807\u7cfb\u53ef\u80fd\u4f1a\u6709\u4e0d\u540c\u7684\u539f\u70b9\u5b9a\u4e49\u548c\u5750\u6807\u8f74\u65b9\u5411\uff0c\u56e0\u6b64\u5728\u8f6c\u6362\u4e4b\u524d\uff0c\u786e\u4fdd\u5bf9\u8fd9\u4e9b\u53c2\u6570\u6709\u6e05\u6670\u7684\u7406\u89e3\u3002\u6b64\u5916\uff0c\u6d6e\u70b9\u6570\u8fd0\u7b97\u53ef\u80fd\u4f1a\u5f15\u5165\u8bef\u5dee\uff0c\u56e0\u6b64\u5728\u8fdb\u884c\u8ba1\u7b97\u65f6\u5e94\u8003\u8651\u5230\u7cbe\u5ea6\u95ee\u9898\uff0c\u5c3d\u91cf\u4f7f\u7528\u9ad8\u7cbe\u5ea6\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<p><strong>\u662f\u5426\u6709\u53ef\u89c6\u5316\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u5750\u6807\u7cfb\u8f6c\u6362\u8fc7\u7a0b\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u6709\u591a\u79cd\u53ef\u89c6\u5316\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u5750\u6807\u7cfb\u8f6c\u6362\u3002\u4f8b\u5982\uff0cMatplotlib\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u53ef\u89c6\u5316\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u7ed8\u5236\u4e0d\u540c\u5750\u6807\u7cfb\u4e0b\u7684\u56fe\u5f62\uff0c\u5e2e\u52a9\u7528\u6237\u76f4\u89c2\u7406\u89e3\u8f6c\u6362\u8fc7\u7a0b\u3002\u6b64\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u4e13\u95e8\u7684\u56fe\u5f62\u754c\u9762\u5de5\u5177\uff0c\u5982GeoGebra\uff0c\u80fd\u591f\u5c55\u793a\u5750\u6807\u7cfb\u7684\u53d8\u5316\u53ca\u5176\u5f71\u54cd\uff0c\u9002\u5408\u6559\u5b66\u548c\u5b66\u4e60\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python \u8f6c\u5316\u5750\u6807\u7cfb\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u6570\u5b66\u516c\u5f0f\u3001\u5229\u7528\u7b2c\u4e09\u65b9\u5e93\u5982Numpy\u548cScipy\u3001\u4ee5\u53ca\u4e13\u95e8\u5904\u7406\u5730\u7406 [&hellip;]","protected":false},"author":3,"featured_media":1180654,"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\/1180628"}],"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=1180628"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1180628\/revisions"}],"predecessor-version":[{"id":1180655,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1180628\/revisions\/1180655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1180654"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1180628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1180628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1180628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}