2024-10-08 19:29:26 发布
网友
我正在处理一个使用多边形形状文件输入的GIS问题。在
考虑一个不规则多边形。我想在多边形的范围内以相等的间距画垂直线。在
我打算如何继续:
确定边界框(使用PyShp完成)
以相等间距绘制与边界框左边缘平行的垂直线(如何?)
将线裁剪到多边形的范围内(如何,不使用ArcPy?)
注:它们只要求是垂直的,不是一个分划。另外,我不打算使用ArcPy,而是打算用Python(2.7)来完成编码,因为这段代码需要进入PyQt生成的工具中。在
终于找到了我问题的密码!!所以回答它。。。感谢您的意见。。在
Ipath = raw_input("Enter the input file :- ") Opath = raw_input("Enter the output directory :- ") Ipath = Ipath.replace("\\", "/") # Python requirement for paths Opath = Opath.replace("\\", "/") copyfile(str(Ipath) + ".prj", str(Opath) + "/" + "Out_Lines" + ".prj") # Copying projection file sf = shapefile.Reader(str('Input Path')) shapes = sf.shapes() Box = shapes[0].bbox Spc = input("Enter the grid spacing :- ") # Grid Spacing read x_min = Box[0] # Save the coordinates of the right-bottom, left-top bounding box y_min = Box[1] x_max = Box[2] y_max = Box[3] A_bbox = [x_min, y_min] # First assignment of coordinates B_bbox = [x_max, y_max] C_bbox = [x_min, y_max] D_bbox = [x_max, y_min] w = shapefile.Writer(shapefile.POLYLINE) # Shapefile writer w.line(parts = [[A_bbox, C_bbox]]) w.field('Path number', 'C', '50') w.record(str(1)) # Writes the first line, that is the left 'side' of the bounding box # Increasing the X coordinate to generate a line at a specified spacing i = 2 while (A_bbox[0] <= x_max): A_bbox = [A_bbox[0] + Spc, A_bbox[1]] C_bbox = [C_bbox[0] + Spc, C_bbox[1]] w.line(parts = [[A_bbox, C_bbox]]) w.record(str(i)) i = i+1 w.save(str(Opath) + "/" + "Out_Lines")
这将结果保存在shapefile中。在
作为上述问题的延续,问题的解决方案可在Clipping Line shapefiles within extent of Polygon shape获得。我认为这组问题现在可以被视为已回答并结束。在
谢谢大家的帮助。在
终于找到了我问题的密码!!所以回答它。。。感谢您的意见。。在
这将结果保存在shapefile中。在
作为上述问题的延续,问题的解决方案可在Clipping Line shapefiles within extent of Polygon shape获得。我认为这组问题现在可以被视为已回答并结束。在
谢谢大家的帮助。在
相关问题 更多 >
编程相关推荐