简体   繁体   English

裁剪分析仅裁剪某些多边形的一部分

[英]Clip Analysis clipping only parts of some polygons

I'm working with NLCD raster data to make a canopy layer across the US.我正在使用 NLCD 栅格数据在美国制作树冠层。 I have a loop set up to where I will clip a section of my massive woodland layer to one degree blocks.我设置了一个循环,将我的巨大林地层的一部分剪辑到一个度块。

Sometimes only parts of an area are getting clipped, leaving giant gaps in the data.有时,只有部分区域被裁剪,从而在数据中留下巨大的空白。

I patched this together by hand in an earlier stage but turns out my dissolve tool doesn't want to work at such a large scale so I'm cutting my stuff up again to run through a Dissolve loop.我在较早的阶段手动将它拼凑在一起,但结果我的溶解工具不想在如此大的范围内工作,所以我再次切割我的东西以通过溶解循环运行。

I would loathe making an even smaller grid set, but that's on my table to try.我讨厌制作更小的网格集,但那是在我的桌子上尝试的。 But I just can't figure out why Clip isn't working properly.但我就是想不通为什么 Clip 不能正常工作。

import arcpy, os, sys, shutil, time
import arcpy.cartography as CA

arcpy.env.overwriteOutput = 1
start = time.time()

#********DATA AND PATHS********
curr_dir = os.getcwd()
print(curr_dir)


#INPUT Directories
input = os.path.join(curr_dir, 'Input.gdb')
woodland_data = os.path.join(input, 'dissolve_me')#These are the projected input
grids = os.path.join(curr_dir, 'Grids.gdb')#These are the exploded grid files

#PROCESSING Directories
scratch = os.path.join(curr_dir, 'scratch.gdb')#clipped woodland features here
scratch_fc = os.path.join(scratch, 'clipped_')#clipped fc name

#OUTPUT Directories
woodland = os.path.join(curr_dir, 'Final.gdb')#Smoothed output goes here
dissolve_fc = os.path.join(woodland, 'dissolved_')#smoothed fc name
fail_gdb = os.path.join(curr_dir, 'Failed.gdb')#Tile to re-run gets dumped in here
failed_tiles = os.path.join(fail_gdb, 'failed_')

arcpy.env.workspace = (grids)
fcs = arcpy.ListFeatureClasses()


def clip_polygon():

    for tile in fcs:
        print(tile)

        try:
            arcpy.Clip_analysis(woodland_data, tile, (scratch_fc + tile), "")
            print(tile + ' Woodland clipped')
        except:
           # arcpy.FeatureClassToFeatureClass_conversion(tile, failed_tiles, (tile + 'failed'))
           # arcpy.CopyFeatures_management(tile, failed_tiles)
            print(tile + ' FAILED')
        else:
            print('moving on to next tile.....')
            continue


if __name__ == '__main__':

   clip_polygon()

end = time.time()
print(end - start)

What size are the tiles you're trying to clip to?您要剪切的瓷砖尺寸是多少? Does this error or just not function?这个错误还是不是 function? (I've had issues with memory errors specifically with dissolving large data and feature classes) Look at this post https://gis.stackexchange.com/questions/239390/dissolve-multiple-shapefiles-so-that-touching-polygons-become-one-gdal-ogr (我遇到了 memory 错误的问题,特别是在分解大数据和要素类时)看看这篇文章https://gis.stackexchange.com/questions/239390/dissolve-multiple-shapefiles-so-that-touching-polygons-成为一个gdal-ogr
I would try the option 5 using Eliminate tool.我会使用消除工具尝试选项 5。 You may need to iterate over a few times to reduce the number of polygons.您可能需要迭代几次以减少多边形的数量。 I would try geopandas - WAY better than ESRI in my opinion.我会尝试 geopandas - 在我看来比 ESRI 更好。 Look at the solution on this post.看看这篇文章的解决方案。 Dissolve Overlapping Polygons (with GDAL/OGR) while keeping non-connected results distinct 溶解重叠多边形(使用 GDAL/OGR),同时保持非连接结果不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM