alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

[992] Remove holes within polygons in a shapefile

To remove holes within polygons in a shapefile, you can use the geopandas library in Python. Here's how you can do it:

import geopandas as gpd
# Read the shapefile
gdf = gpd.read_file('path_to_shapefile.shp')
# Remove holes within polygons
gdf['geometry'] = gdf['geometry'].apply(lambda x: x.exterior)
# Save the modified GeoDataFrame to a new shapefile
gdf.to_file('path_to_output_shapefile.shp')

In this code:

  • Replace 'path_to_shapefile.shp' with the path to your input shapefile.
  • The gdf['geometry'].apply(lambda x: x.exterior) line removes the interior rings (holes) from each polygon in the GeoDataFrame. It keeps only the exterior boundary of each polygon.
  • The modified GeoDataFrame is then saved to a new shapefile using to_file() function.

Make sure to replace 'path_to_output_shapefile.shp' with the desired path for the output shapefile. This process will remove the holes within the polygons of your shapefile and save the modified shapefile with the holes removed.


In ArcGIS Pro, you can remove holes within polygons using the "Eliminate Polygon Part" tool. Here's how you can do it:

  1. Open ArcGIS Pro and add your shapefile to the map.

  2. In the Catalog pane, navigate to the toolboxes and find the "Data Management Tools" toolbox.

  3. Expand the "Features" toolbox and then double-click on "Eliminate Polygon Part" tool to open it.

  4. In the "Eliminate Polygon Part" tool dialog, select your input shapefile as the "Input Features".

  5. Specify an output location and name for the modified shapefile in the "Output Feature Class" field.

  6. Choose the appropriate elimination method. For removing holes within polygons, select the "DELETE_PART" method.

  7. Optionally, you can set additional parameters such as the selection criteria and XY tolerance.

  8. Click on the "Run" button to execute the tool.

  9. Once the tool finishes running, you will see a new shapefile created with the holes removed.

By following these steps, you can easily remove holes within polygons in ArcGIS Pro using the "Eliminate Polygon Part" tool.


In QGIS, you can remove holes within polygons using the "Delete Holes" tool. Here's how you can do it:

  1. Open QGIS and load your shapefile into the project.

  2. In the QGIS toolbar, go to Vector > Geometry Tools > Delete Holes.

  3. In the "Delete Holes" dialog box, select your input shapefile as the "Input layer".

  4. Specify an output location and name for the modified shapefile in the "Output shapefile" field.

  5. Click on the "Run" button to execute the tool.

  6. Once the tool finishes running, you will see a new shapefile created with the holes removed.

By following these steps, you can easily remove holes within polygons in QGIS using the "Delete Holes" tool.

posted on   McDelfino  阅读(53)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示