{"id":1181071,"date":"2025-01-15T18:46:31","date_gmt":"2025-01-15T10:46:31","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1181071.html"},"modified":"2025-01-15T18:46:33","modified_gmt":"2025-01-15T10:46:33","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%8a%a0%e8%bd%bd%e5%9c%b0%e5%9b%be%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1181071.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u52a0\u8f7d\u5730\u56fe\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25125531\/48862c51-77ae-4780-9641-89a47186fe65.webp\" alt=\"python\u4e2d\u5982\u4f55\u52a0\u8f7d\u5730\u56fe\u5e93\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u52a0\u8f7d\u5730\u56fe\u5e93\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c<strong>\u5e38\u89c1\u7684\u5730\u56fe\u5e93\u5305\u62ecBasemap\u3001Folium\u548cGeopandas<\/strong>\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5730\u7406\u7a7a\u95f4\u6570\u636e\u5904\u7406\u548c\u53ef\u89c6\u5316\u529f\u80fd\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5b89\u88c5\u548c\u4f7f\u7528\u8fd9\u4e9b\u5730\u56fe\u5e93\uff0c\u5e2e\u52a9\u4f60\u5728Python\u9879\u76ee\u4e2d\u52a0\u8f7d\u548c\u4f7f\u7528\u5730\u7406\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001Basemap\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Basemap\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Basemap\u662fmatplotlib\u5de5\u5177\u5305\u7684\u4e00\u90e8\u5206\uff0c\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7ed8\u5236\u5730\u7406\u5730\u56fe\u7684\u5de5\u5177\u3002\u867d\u7136Basemap\u5df2\u7ecf\u88ab\u65b0\u7684Cartopy\u5e93\u53d6\u4ee3\uff0c\u4f46\u8bb8\u591a\u73b0\u6709\u9879\u76ee\u4ecd\u5728\u4f7f\u7528\u5b83\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Basemap\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Basemap\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install basemap<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u4f7f\u7528Basemap\u7ed8\u5236\u5730\u56fe<\/h3>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Basemap\u7ed8\u5236\u57fa\u672c\u7684\u5730\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from mpl_toolkits.basemap import Basemap<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efaBasemap\u5b9e\u4f8b<\/strong><\/h2>\n<p>m = Basemap(projection=&#39;mill&#39;, llcrnrlat=-60, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180, resolution=&#39;c&#39;)<\/p>\n<h2><strong>\u7ed8\u5236\u6d77\u5cb8\u7ebf\u548c\u56fd\u5bb6\u8fb9\u754c<\/strong><\/h2>\n<p>m.drawcoastlines()<\/p>\n<p>m.drawcountries()<\/p>\n<h2><strong>\u663e\u793a\u5730\u56fe<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>projection<\/code>\u53c2\u6570\u6307\u5b9a\u4e86\u5730\u56fe\u7684\u6295\u5f71\u7c7b\u578b\uff0c<code>llcrnrlat<\/code>\u3001<code>urcrnrlat<\/code>\u3001<code>llcrnrlon<\/code>\u548c<code>urcrnrlon<\/code>\u53c2\u6570\u6307\u5b9a\u4e86\u5730\u56fe\u7684\u7ecf\u7eac\u5ea6\u8303\u56f4\uff0c<code>resolution<\/code>\u53c2\u6570\u6307\u5b9a\u4e86\u5730\u56fe\u5206\u8fa8\u7387\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u7ed8\u5236\u66f4\u591a\u5730\u7406\u7279\u5f81<\/h3>\n<\/p>\n<p><p>Basemap\u5e93\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5176\u4ed6\u529f\u80fd\uff0c\u4f8b\u5982\u7ed8\u5236\u6cb3\u6d41\u3001\u6e56\u6cca\u3001\u586b\u5145\u5927\u9646\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u7ed8\u5236\u66f4\u591a\u5730\u7406\u7279\u5f81\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from mpl_toolkits.basemap import Basemap<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efaBasemap\u5b9e\u4f8b<\/strong><\/h2>\n<p>m = Basemap(projection=&#39;mill&#39;, llcrnrlat=-60, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180, resolution=&#39;c&#39;)<\/p>\n<h2><strong>\u7ed8\u5236\u6d77\u5cb8\u7ebf\u548c\u56fd\u5bb6\u8fb9\u754c<\/strong><\/h2>\n<p>m.drawcoastlines()<\/p>\n<p>m.drawcountries()<\/p>\n<h2><strong>\u7ed8\u5236\u6cb3\u6d41\u548c\u6e56\u6cca<\/strong><\/h2>\n<p>m.drawrivers()<\/p>\n<p>m.drawlsmask()<\/p>\n<h2><strong>\u663e\u793a\u5730\u56fe<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>drawrivers()<\/code>\u65b9\u6cd5\u7ed8\u5236\u4e86\u6cb3\u6d41\uff0c<code>drawlsmask()<\/code>\u65b9\u6cd5\u586b\u5145\u4e86\u5927\u9646\u548c\u6e56\u6cca\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001Folium\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Folium\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Folium\u662f\u4e00\u4e2a\u57fa\u4e8eLeaflet.js\u7684Python\u5e93\uff0c\u7528\u4e8e\u521b\u5efa\u4ea4\u4e92\u5f0f\u5730\u56fe\u3002\u5b83\u53ef\u4ee5\u4e0eJupyter Notebook\u65e0\u7f1d\u96c6\u6210\uff0c\u975e\u5e38\u9002\u5408\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u9879\u76ee\u4e2d\u7684\u5730\u7406\u6570\u636e\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Folium\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Folium\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install folium<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u4f7f\u7528Folium\u521b\u5efa\u4ea4\u4e92\u5f0f\u5730\u56fe<\/h3>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Folium\u521b\u5efa\u57fa\u672c\u7684\u4ea4\u4e92\u5f0f\u5730\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import folium<\/p>\n<h2><strong>\u521b\u5efa\u5730\u56fe\u5bf9\u8c61<\/strong><\/h2>\n<p>m = folium.Map(location=[0, 0], zoom_start=2)<\/p>\n<h2><strong>\u4fdd\u5b58\u5730\u56fe\u5230HTML\u6587\u4ef6<\/strong><\/h2>\n<p>m.save(&#39;map.html&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>location<\/code>\u53c2\u6570\u6307\u5b9a\u4e86\u5730\u56fe\u7684\u4e2d\u5fc3\u4f4d\u7f6e\uff0c<code>zoom_start<\/code>\u53c2\u6570\u6307\u5b9a\u4e86\u5730\u56fe\u7684\u521d\u59cb\u7f29\u653e\u7ea7\u522b\u3002\u751f\u6210\u7684HTML\u6587\u4ef6\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u4ea4\u4e92\u5f0f\u5730\u56fe\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u6dfb\u52a0\u6807\u8bb0\u548c\u56fe\u5c42<\/h3>\n<\/p>\n<p><p>Folium\u5e93\u63d0\u4f9b\u4e86\u8bb8\u591a\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u5730\u56fe\u4e0a\u6dfb\u52a0\u6807\u8bb0\u3001\u56fe\u5c42\u548c\u5176\u4ed6\u5730\u7406\u7279\u5f81\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728\u5730\u56fe\u4e0a\u6dfb\u52a0\u6807\u8bb0\u548c\u56fe\u5c42\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import folium<\/p>\n<h2><strong>\u521b\u5efa\u5730\u56fe\u5bf9\u8c61<\/strong><\/h2>\n<p>m = folium.Map(location=[0, 0], zoom_start=2)<\/p>\n<h2><strong>\u6dfb\u52a0\u6807\u8bb0<\/strong><\/h2>\n<p>folium.Marker(location=[37.7749, -122.4194], popup=&#39;San Francisco&#39;).add_to(m)<\/p>\n<p>folium.Marker(location=[51.5074, -0.1278], popup=&#39;London&#39;).add_to(m)<\/p>\n<h2><strong>\u6dfb\u52a0\u5706\u5f62\u6807\u8bb0<\/strong><\/h2>\n<p>folium.CircleMarker(location=[34.0522, -118.2437], radius=50, color=&#39;blue&#39;, fill=True, fill_color=&#39;blue&#39;).add_to(m)<\/p>\n<h2><strong>\u4fdd\u5b58\u5730\u56fe\u5230HTML\u6587\u4ef6<\/strong><\/h2>\n<p>m.save(&#39;map_with_markers.html&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>Marker<\/code>\u7c7b\u7528\u4e8e\u6dfb\u52a0\u5e26\u6709\u5f39\u51fa\u7a97\u53e3\u7684\u6807\u8bb0\uff0c<code>CircleMarker<\/code>\u7c7b\u7528\u4e8e\u6dfb\u52a0\u5706\u5f62\u6807\u8bb0\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001Geopandas\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Geopandas\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Geopandas\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Python\u5e93\uff0c\u7528\u4e8e\u5904\u7406\u548c\u5206\u6790\u5730\u7406\u7a7a\u95f4\u6570\u636e\u3002\u5b83\u57fa\u4e8ePandas\u548cShapely\u5e93\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5730\u7406\u6570\u636e\u5904\u7406\u548c\u53ef\u89c6\u5316\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Geopandas\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Geopandas\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install geopandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u52a0\u8f7d\u548c\u5904\u7406\u5730\u7406\u6570\u636e<\/h3>\n<\/p>\n<p><p>Geopandas\u5e93\u53ef\u4ee5\u8f7b\u677e\u52a0\u8f7d\u548c\u5904\u7406\u5404\u79cd\u5730\u7406\u6570\u636e\u683c\u5f0f\uff0c\u4f8b\u5982Shapefile\u3001GeoJSON\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u52a0\u8f7d\u548c\u5904\u7406\u5730\u7406\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import geopandas as gpd<\/p>\n<h2><strong>\u52a0\u8f7dShapefile\u6570\u636e<\/strong><\/h2>\n<p>gdf = gpd.read_file(&#39;path_to_shapefile.shp&#39;)<\/p>\n<h2><strong>\u663e\u793a\u524d\u51e0\u884c\u6570\u636e<\/strong><\/h2>\n<p>print(gdf.head())<\/p>\n<h2><strong>\u7ed8\u5236\u5730\u7406\u6570\u636e<\/strong><\/h2>\n<p>gdf.plot()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>read_file<\/code>\u65b9\u6cd5\u7528\u4e8e\u52a0\u8f7dShapefile\u6570\u636e\uff0c<code>plot<\/code>\u65b9\u6cd5\u7528\u4e8e\u7ed8\u5236\u5730\u7406\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u7a7a\u95f4\u64cd\u4f5c\u548c\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>Geopandas\u5e93\u63d0\u4f9b\u4e86\u8bb8\u591a\u7a7a\u95f4\u64cd\u4f5c\u548c\u53ef\u89c6\u5316\u529f\u80fd\uff0c\u4f8b\u5982\u7f13\u51b2\u533a\u5206\u6790\u3001\u53e0\u52a0\u5206\u6790\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u8fdb\u884c\u7a7a\u95f4\u64cd\u4f5c\u548c\u53ef\u89c6\u5316\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import geopandas as gpd<\/p>\n<h2><strong>\u52a0\u8f7dShapefile\u6570\u636e<\/strong><\/h2>\n<p>gdf = gpd.read_file(&#39;path_to_shapefile.shp&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u7f13\u51b2\u533a<\/strong><\/h2>\n<p>gdf_buffer = gdf.buffer(0.1)<\/p>\n<h2><strong>\u53e0\u52a0\u5206\u6790<\/strong><\/h2>\n<p>gdf_overlay = gpd.overlay(gdf, gdf_buffer, how=&#39;intersection&#39;)<\/p>\n<h2><strong>\u7ed8\u5236\u5730\u7406\u6570\u636e<\/strong><\/h2>\n<p>gdf.plot()<\/p>\n<p>gdf_buffer.plot()<\/p>\n<p>gdf_overlay.plot()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>buffer<\/code>\u65b9\u6cd5\u7528\u4e8e\u521b\u5efa\u7f13\u51b2\u533a\uff0c<code>overlay<\/code>\u65b9\u6cd5\u7528\u4e8e\u8fdb\u884c\u53e0\u52a0\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528Cartopy\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Cartopy\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Cartopy\u662f\u4e00\u4e2a\u7528\u4e8e\u5730\u7406\u7a7a\u95f4\u6570\u636e\u5904\u7406\u548c\u7ed8\u56fe\u7684Python\u5e93\uff0c\u65e8\u5728\u53d6\u4ee3Basemap\u3002\u5b83\u63d0\u4f9b\u4e86\u66f4\u73b0\u4ee3\u548c\u7075\u6d3b\u7684\u5730\u56fe\u7ed8\u5236\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Cartopy\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Cartopy\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install cartopy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u4f7f\u7528Cartopy\u7ed8\u5236\u5730\u56fe<\/h3>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Cartopy\u7ed8\u5236\u57fa\u672c\u7684\u5730\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cartopy.crs as ccrs<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efa\u5730\u56fe\u6295\u5f71<\/strong><\/h2>\n<p>ax = plt.axes(projection=ccrs.PlateCarree())<\/p>\n<h2><strong>\u7ed8\u5236\u6d77\u5cb8\u7ebf<\/strong><\/h2>\n<p>ax.coastlines()<\/p>\n<h2><strong>\u663e\u793a\u5730\u56fe<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>ccrs.PlateCarree()<\/code>\u7528\u4e8e\u521b\u5efa\u5730\u56fe\u6295\u5f71\uff0c<code>coastlines()<\/code>\u65b9\u6cd5\u7528\u4e8e\u7ed8\u5236\u6d77\u5cb8\u7ebf\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u7ed8\u5236\u66f4\u591a\u5730\u7406\u7279\u5f81<\/h3>\n<\/p>\n<p><p>Cartopy\u5e93\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5176\u4ed6\u529f\u80fd\uff0c\u4f8b\u5982\u7ed8\u5236\u6cb3\u6d41\u3001\u6e56\u6cca\u3001\u56fd\u5bb6\u8fb9\u754c\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u7ed8\u5236\u66f4\u591a\u5730\u7406\u7279\u5f81\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cartopy.crs as ccrs<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>import cartopy.feature as cfeature<\/p>\n<h2><strong>\u521b\u5efa\u5730\u56fe\u6295\u5f71<\/strong><\/h2>\n<p>ax = plt.axes(projection=ccrs.PlateCarree())<\/p>\n<h2><strong>\u7ed8\u5236\u6d77\u5cb8\u7ebf\u548c\u56fd\u5bb6\u8fb9\u754c<\/strong><\/h2>\n<p>ax.coastlines()<\/p>\n<p>ax.add_feature(cfeature.BORDERS)<\/p>\n<h2><strong>\u7ed8\u5236\u6cb3\u6d41\u548c\u6e56\u6cca<\/strong><\/h2>\n<p>ax.add_feature(cfeature.RIVERS)<\/p>\n<p>ax.add_feature(cfeature.LAKES)<\/p>\n<h2><strong>\u663e\u793a\u5730\u56fe<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>cfeature.BORDERS<\/code>\u7528\u4e8e\u7ed8\u5236\u56fd\u5bb6\u8fb9\u754c\uff0c<code>cfeature.RIVERS<\/code>\u548c<code>cfeature.LAKES<\/code>\u7528\u4e8e\u7ed8\u5236\u6cb3\u6d41\u548c\u6e56\u6cca\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u4f7f\u7528Shapely\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Shapely\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Shapely\u662f\u4e00\u4e2a\u7528\u4e8e\u64cd\u4f5c\u548c\u5206\u6790\u51e0\u4f55\u5bf9\u8c61\u7684Python\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u51e0\u4f55\u64cd\u4f5c\u548c\u5206\u6790\u529f\u80fd\uff0c\u4f8b\u5982\u7f13\u51b2\u533a\u5206\u6790\u3001\u53e0\u52a0\u5206\u6790\u3001\u8ddd\u79bb\u8ba1\u7b97\u7b49\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Shapely\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Shapely\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install shapely<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u521b\u5efa\u548c\u64cd\u4f5c\u51e0\u4f55\u5bf9\u8c61<\/h3>\n<\/p>\n<p><p>Shapely\u5e93\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u548c\u64cd\u4f5c\u51e0\u4f55\u5bf9\u8c61\uff0c\u4f8b\u5982\u70b9\u3001\u7ebf\u3001\u591a\u8fb9\u5f62\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u521b\u5efa\u548c\u64cd\u4f5c\u51e0\u4f55\u5bf9\u8c61\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from shapely.geometry import Point, LineString, Polygon<\/p>\n<h2><strong>\u521b\u5efa\u70b9<\/strong><\/h2>\n<p>point = Point(0, 0)<\/p>\n<h2><strong>\u521b\u5efa\u7ebf<\/strong><\/h2>\n<p>line = LineString([(0, 0), (1, 1), (2, 2)])<\/p>\n<h2><strong>\u521b\u5efa\u591a\u8fb9\u5f62<\/strong><\/h2>\n<p>polygon = Polygon([(0, 0), (1, 1), (1, 0)])<\/p>\n<h2><strong>\u8ba1\u7b97\u9762\u79ef\u548c\u5468\u957f<\/strong><\/h2>\n<p>print(polygon.area)<\/p>\n<p>print(polygon.length)<\/p>\n<h2><strong>\u521b\u5efa\u7f13\u51b2\u533a<\/strong><\/h2>\n<p>buffer = point.buffer(1.0)<\/p>\n<h2><strong>\u53e0\u52a0\u5206\u6790<\/strong><\/h2>\n<p>intersection = polygon.intersection(buffer)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>Point<\/code>\u3001<code>LineString<\/code>\u548c<code>Polygon<\/code>\u7c7b\u7528\u4e8e\u521b\u5efa\u51e0\u4f55\u5bf9\u8c61\uff0c<code>area<\/code>\u548c<code>length<\/code>\u5c5e\u6027\u7528\u4e8e\u8ba1\u7b97\u591a\u8fb9\u5f62\u7684\u9762\u79ef\u548c\u5468\u957f\uff0c<code>buffer<\/code>\u65b9\u6cd5\u7528\u4e8e\u521b\u5efa\u7f13\u51b2\u533a\uff0c<code>intersection<\/code>\u65b9\u6cd5\u7528\u4e8e\u8fdb\u884c\u53e0\u52a0\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u51e0\u4f55\u64cd\u4f5c\u548c\u5206\u6790<\/h3>\n<\/p>\n<p><p>Shapely\u5e93\u63d0\u4f9b\u4e86\u8bb8\u591a\u51e0\u4f55\u64cd\u4f5c\u548c\u5206\u6790\u529f\u80fd\uff0c\u4f8b\u5982\u5408\u5e76\u3001\u5dee\u5f02\u3001\u5bf9\u79f0\u5dee\u5f02\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u8fdb\u884c\u51e0\u4f55\u64cd\u4f5c\u548c\u5206\u6790\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from shapely.geometry import Point, Polygon<\/p>\n<h2><strong>\u521b\u5efa\u70b9\u548c\u591a\u8fb9\u5f62<\/strong><\/h2>\n<p>point = Point(0, 0)<\/p>\n<p>polygon = Polygon([(0, 0), (1, 1), (1, 0)])<\/p>\n<h2><strong>\u5408\u5e76<\/strong><\/h2>\n<p>union = point.union(polygon)<\/p>\n<h2><strong>\u5dee\u5f02<\/strong><\/h2>\n<p>difference = polygon.difference(point)<\/p>\n<h2><strong>\u5bf9\u79f0\u5dee\u5f02<\/strong><\/h2>\n<p>symmetric_difference = polygon.symmetric_difference(point)<\/p>\n<h2><strong>\u663e\u793a\u7ed3\u679c<\/strong><\/h2>\n<p>print(union)<\/p>\n<p>print(difference)<\/p>\n<p>print(symmetric_difference)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>union<\/code>\u65b9\u6cd5\u7528\u4e8e\u5408\u5e76\u51e0\u4f55\u5bf9\u8c61\uff0c<code>difference<\/code>\u65b9\u6cd5\u7528\u4e8e\u8ba1\u7b97\u5dee\u5f02\uff0c<code>symmetric_difference<\/code>\u65b9\u6cd5\u7528\u4e8e\u8ba1\u7b97\u5bf9\u79f0\u5dee\u5f02\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u4f7f\u7528Pyproj\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Pyproj\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Pyproj\u662f\u4e00\u4e2a\u7528\u4e8e\u5750\u6807\u8f6c\u6362\u548c\u5730\u56fe\u6295\u5f71\u7684Python\u5e93\u3002\u5b83\u57fa\u4e8eProj\u5e93\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5750\u6807\u8f6c\u6362\u548c\u5730\u56fe\u6295\u5f71\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Pyproj\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Pyproj\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pyproj<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u5750\u6807\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>Pyproj\u5e93\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u5750\u6807\u8f6c\u6362\uff0c\u4f8b\u5982\u4ece\u5730\u7406\u5750\u6807\uff08\u7ecf\u7eac\u5ea6\uff09\u8f6c\u6362\u4e3a\u6295\u5f71\u5750\u6807\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u8fdb\u884c\u5750\u6807\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Proj, transform<\/p>\n<h2><strong>\u5b9a\u4e49\u5730\u7406\u5750\u6807\u7cfb\u548c\u6295\u5f71\u5750\u6807\u7cfb<\/strong><\/h2>\n<p>geographic = Proj(init=&#39;epsg:4326&#39;)<\/p>\n<p>projected = Proj(init=&#39;epsg:3857&#39;)<\/p>\n<h2><strong>\u8fdb\u884c\u5750\u6807\u8f6c\u6362<\/strong><\/h2>\n<p>x, y = transform(geographic, projected, 0, 0)<\/p>\n<h2><strong>\u663e\u793a\u7ed3\u679c<\/strong><\/h2>\n<p>print(x, y)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>Proj<\/code>\u7c7b\u7528\u4e8e\u5b9a\u4e49\u5750\u6807\u7cfb\uff0c<code>transform<\/code>\u51fd\u6570\u7528\u4e8e\u8fdb\u884c\u5750\u6807\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u66f4\u591a\u6295\u5f71\u548c\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>Pyproj\u5e93\u652f\u6301\u8bb8\u591a\u5e38\u89c1\u7684\u5730\u56fe\u6295\u5f71\u548c\u5750\u6807\u7cfb\uff0c\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u5404\u79cd\u6295\u5f71\u548c\u8f6c\u6362\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u8fdb\u884c\u66f4\u591a\u6295\u5f71\u548c\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Proj, transform<\/p>\n<h2><strong>\u5b9a\u4e49\u591a\u4e2a\u5750\u6807\u7cfb<\/strong><\/h2>\n<p>geographic = Proj(init=&#39;epsg:4326&#39;)<\/p>\n<p>utm = Proj(init=&#39;epsg:32633&#39;)<\/p>\n<p>mercator = Proj(init=&#39;epsg:3857&#39;)<\/p>\n<h2><strong>\u8fdb\u884c\u5750\u6807\u8f6c\u6362<\/strong><\/h2>\n<p>x1, y1 = transform(geographic, utm, 0, 0)<\/p>\n<p>x2, y2 = transform(geographic, mercator, 0, 0)<\/p>\n<h2><strong>\u663e\u793a\u7ed3\u679c<\/strong><\/h2>\n<p>print(x1, y1)<\/p>\n<p>print(x2, y2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u5730\u7406\u5750\u6807\u7cfb\u3001UTM\u5750\u6807\u7cfb\u548c\u58a8\u5361\u6258\u6295\u5f71\uff0c\u5e76\u8fdb\u884c\u4e86\u76f8\u5e94\u7684\u5750\u6807\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h2>\u4e03\u3001\u4f7f\u7528Osmnx\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Osmnx\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Osmnx\u662f\u4e00\u4e2a\u7528\u4e8e\u4e0b\u8f7d\u3001\u5904\u7406\u548c\u53ef\u89c6\u5316OpenStreetMap\u6570\u636e\u7684Python\u5e93\u3002\u5b83\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u548c\u5206\u6790\u57ce\u5e02\u8857\u9053\u7f51\u7edc\u3001\u5efa\u7b51\u7269\u8f6e\u5ed3\u7b49\u5730\u7406\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Osmnx\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Osmnx\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install osmnx<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u4e0b\u8f7d\u548c\u53ef\u89c6\u5316\u8857\u9053\u7f51\u7edc<\/h3>\n<\/p>\n<p><p>Osmnx\u5e93\u53ef\u4ee5\u8f7b\u677e\u4e0b\u8f7d\u548c\u53ef\u89c6\u5316\u57ce\u5e02\u8857\u9053\u7f51\u7edc\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4e0b\u8f7d\u548c\u53ef\u89c6\u5316\u8857\u9053\u7f51\u7edc\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import osmnx as ox<\/p>\n<h2><strong>\u4e0b\u8f7d\u8857\u9053\u7f51\u7edc<\/strong><\/h2>\n<p>G = ox.graph_from_place(&#39;Piedmont, California, USA&#39;, network_type=&#39;drive&#39;)<\/p>\n<h2><strong>\u53ef\u89c6\u5316\u8857\u9053\u7f51\u7edc<\/strong><\/h2>\n<p>fig, ax = ox.plot_graph(G)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>graph_from_place<\/code>\u51fd\u6570\u7528\u4e8e\u4e0b\u8f7d\u6307\u5b9a\u5730\u70b9\u7684\u8857\u9053\u7f51\u7edc\uff0c<code>plot_graph<\/code>\u51fd\u6570\u7528\u4e8e\u53ef\u89c6\u5316\u8857\u9053\u7f51\u7edc\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u5206\u6790\u8857\u9053\u7f51\u7edc<\/h3>\n<\/p>\n<p><p>Osmnx\u5e93\u63d0\u4f9b\u4e86\u8bb8\u591a\u529f\u80fd\uff0c\u53ef\u4ee5\u5bf9\u8857\u9053\u7f51\u7edc\u8fdb\u884c\u5206\u6790\uff0c\u4f8b\u5982\u8ba1\u7b97\u6700\u77ed\u8def\u5f84\u3001\u8282\u70b9\u95f4\u8ddd\u79bb\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5206\u6790\u8857\u9053\u7f51\u7edc\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import osmnx as ox<\/p>\n<p>import networkx as nx<\/p>\n<h2><strong>\u4e0b\u8f7d\u8857\u9053\u7f51\u7edc<\/strong><\/h2>\n<p>G = ox.graph_from_place(&#39;Piedmont, California, USA&#39;, network_type=&#39;drive&#39;)<\/p>\n<h2><strong>\u67e5\u627e\u6700\u8fd1\u7684\u8282\u70b9<\/strong><\/h2>\n<p>orig = ox.distance.nearest_nodes(G, -122.247847, 37.812303)<\/p>\n<p>dest = ox.distance.nearest_nodes(G, -122.255847, 37.822303)<\/p>\n<h2><strong>\u8ba1\u7b97\u6700\u77ed\u8def\u5f84<\/strong><\/h2>\n<p>shortest_path = nx.shortest_path(G, orig, dest, weight=&#39;length&#39;)<\/p>\n<h2><strong>\u53ef\u89c6\u5316\u6700\u77ed\u8def\u5f84<\/strong><\/h2>\n<p>fig, ax = ox.plot_graph_route(G, shortest_path)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>nearest_nodes<\/code>\u51fd\u6570\u7528\u4e8e\u67e5\u627e\u6700\u8fd1\u7684\u8282\u70b9\uff0c<code>shortest_path<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u6700\u77ed\u8def\u5f84\uff0c<code>plot_graph_route<\/code>\u51fd\u6570\u7528\u4e8e\u53ef\u89c6\u5316\u6700\u77ed\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h2>\u516b\u3001\u4f7f\u7528Geopy\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Geopy\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Geopy\u662f\u4e00\u4e2a\u7528\u4e8e\u5730\u7406\u7f16\u7801\u548c\u53cd\u5411\u5730\u7406\u7f16\u7801\u7684Python\u5e93\u3002\u5b83\u652f\u6301\u591a\u79cd\u5730\u7406\u7f16\u7801\u670d\u52a1\uff0c\u4f8b\u5982Nominatim\u3001GoogleV3\u3001OpenCage\u7b49\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5Geopy\u5e93<\/h3>\n<\/p>\n<p><p>\u8981\u5b89\u88c5Geopy\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install geopy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u5730\u7406\u7f16\u7801\u548c\u53cd\u5411\u5730\u7406\u7f16\u7801<\/h3>\n<\/p>\n<p><p>Geopy\u5e93\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u5730\u7406\u7f16\u7801\uff08\u5c06\u5730\u5740\u8f6c\u6362\u4e3a\u7ecf\u7eac\u5ea6\uff09\u548c\u53cd\u5411\u5730\u7406\u7f16\u7801\uff08\u5c06\u7ecf\u7eac\u5ea6\u8f6c\u6362\u4e3a\u5730\u5740\uff09\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u8fdb\u884c\u5730\u7406\u7f16\u7801\u548c\u53cd\u5411\u5730\u7406\u7f16\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from geopy.geocoders import Nominatim<\/p>\n<h2><strong>\u521b\u5efa\u5730\u7406\u7f16\u7801\u5668<\/strong><\/h2>\n<p>geolocator = Nominatim(user_agent=&quot;geoapiExercises&quot;)<\/p>\n<h2><strong>\u5730\u7406\u7f16\u7801<\/strong><\/h2>\n<p>location = geolocator.geocode(&quot;1600 Amphitheatre Parkway, Mount<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n View, CA&quot;)<\/p>\n<p>print((location.latitude, location.longitude))<\/p>\n<h2><strong>\u53cd\u5411\u5730\u7406\u7f16\u7801<\/strong><\/h2>\n<p>location = geolocator.reverse(&quot;37.4219999, -122.0840575&quot;)<\/p>\n<p>print(location.address)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>geocode<\/code>\u65b9\u6cd5\u7528\u4e8e\u5730\u7406\u7f16\u7801\uff0c<code>reverse<\/code>\u65b9\u6cd5\u7528\u4e8e\u53cd\u5411\u5730\u7406\u7f16\u7801\u3002<\/p>\n<\/p>\n<p><h3>4\u3001\u4f7f\u7528\u5176\u4ed6\u5730\u7406\u7f16\u7801\u670d\u52a1<\/h3>\n<\/p>\n<p><p>Geopy\u5e93\u652f\u6301\u591a\u79cd\u5730\u7406\u7f16\u7801\u670d\u52a1\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u4e0d\u540c\u7684\u670d\u52a1\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528GoogleV3\u5730\u7406\u7f16\u7801\u670d\u52a1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from geopy.geocoders import GoogleV3<\/p>\n<h2><strong>\u521b\u5efa\u5730\u7406\u7f16\u7801\u5668<\/strong><\/h2>\n<p>geolocator = GoogleV3(api_key=&#39;your_api_key&#39;)<\/p>\n<h2><strong>\u5730\u7406\u7f16\u7801<\/strong><\/h2>\n<p>location = geolocator.geocode(&quot;1600 Amphitheatre Parkway, Mountain View, CA&quot;)<\/p>\n<p>print((location.latitude, location.longitude))<\/p>\n<h2><strong>\u53cd\u5411\u5730\u7406\u7f16\u7801<\/strong><\/h2>\n<p>location = geolocator.reverse(&quot;37.4219999, -122.0840575&quot;)<\/p>\n<p>print(location.address)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528GoogleV3\u5730\u7406\u7f16\u7801\u670d\u52a1\uff0c\u9700\u8981\u63d0\u4f9bAPI\u5bc6\u94a5\u3002<\/p>\n<\/p>\n<p><h2>\u4e5d\u3001\u4f7f\u7528Rasterio\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001Rasterio\u5e93\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>Rasterio\u662f<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u627e\u5230\u9002\u5408\u7684\u5730\u56fe\u5e93\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u591a\u4e2a\u6d41\u884c\u7684\u5730\u56fe\u5e93\u53ef\u4f9b\u9009\u62e9\uff0c\u5305\u62ecFolium\u3001Geopandas\u548cBasemap\u7b49\u3002\u9009\u62e9\u5408\u9002\u7684\u5730\u56fe\u5e93\u53d6\u51b3\u4e8e\u60a8\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0cFolium\u9002\u5408\u521b\u5efa\u4ea4\u4e92\u5f0f\u5730\u56fe\uff0c\u800cGeopandas\u5219\u9002\u5408\u5904\u7406\u5730\u7406\u6570\u636e\u5e76\u8fdb\u884c\u7a7a\u95f4\u5206\u6790\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u67e5\u9605\u5404\u4e2a\u5e93\u7684\u6587\u6863\u548c\u793a\u4f8b\u6765\u5e2e\u52a9\u786e\u5b9a\u6700\u9002\u5408\u60a8\u7684\u9879\u76ee\u7684\u5e93\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u52a0\u8f7d\u5730\u56fe\u5e93\u7684\u6b65\u9aa4\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u52a0\u8f7d\u5730\u56fe\u5e93\u901a\u5e38\u5305\u62ec\u5b89\u88c5\u76f8\u5173\u5e93\u548c\u5bfc\u5165\u6a21\u5757\u3002\u4ee5Folium\u4e3a\u4f8b\uff0c\u60a8\u9700\u8981\u4f7f\u7528pip\u5b89\u88c5\u8be5\u5e93\uff1a<code>pip install folium<\/code>\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7<code>import folium<\/code>\u5c06\u5176\u5bfc\u5165\u5230\u60a8\u7684Python\u811a\u672c\u4e2d\u3002\u6bcf\u4e2a\u5730\u56fe\u5e93\u7684\u52a0\u8f7d\u6b65\u9aa4\u53ef\u80fd\u7565\u6709\u4e0d\u540c\uff0c\u56e0\u6b64\u67e5\u770b\u5b98\u65b9\u6587\u6863\u603b\u662f\u4e00\u4e2a\u597d\u4e3b\u610f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u5730\u56fe\u5e93\u4e2d\u6dfb\u52a0\u81ea\u5b9a\u4e49\u6570\u636e\uff1f<\/strong><br \/>\u8bb8\u591a\u5730\u56fe\u5e93\u5141\u8bb8\u60a8\u5bfc\u5165\u81ea\u5b9a\u4e49\u5730\u7406\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5728\u4f7f\u7528Geopandas\u65f6\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bfb\u53d6Shapefile\u6216GeoJSON\u6587\u4ef6\u6765\u52a0\u8f7d\u81ea\u5b9a\u4e49\u6570\u636e\u3002\u53ef\u4ee5\u4f7f\u7528<code>gpd.read_file(&#39;your_file.shp&#39;)<\/code>\u6765\u8bfb\u53d6\u6587\u4ef6\u3002\u5bf9\u4e8eFolium\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>folium.Marker()<\/code>\u548c\u5176\u4ed6\u56fe\u5c42\u529f\u80fd\u6765\u6dfb\u52a0\u81ea\u5b9a\u4e49\u6807\u8bb0\u548c\u4fe1\u606f\u3002\u5177\u4f53\u7684\u5b9e\u73b0\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003\u5404\u4e2a\u5e93\u7684\u6587\u6863\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u683c\u5f0f\u7684\u6b63\u786e\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u52a0\u8f7d\u5730\u56fe\u5e93\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c\u5e38\u89c1\u7684\u5730\u56fe\u5e93\u5305\u62ecBasemap\u3001Folium\u548cGeopanda [&hellip;]","protected":false},"author":3,"featured_media":1181076,"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\/1181071"}],"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=1181071"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1181071\/revisions"}],"predecessor-version":[{"id":1181079,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1181071\/revisions\/1181079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1181076"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1181071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1181071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1181071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}