def main(args): ''' Main function, invoked from either command line or qc_wrap ''' pargs = parser.parse_args(args[1:]) lasname = pargs.las_file kmname = constants.get_tilename(lasname) msg = "Running %s on block: %s, %s" print(msg % (os.path.basename(args[0]), kmname, time.asctime())) if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportSpikes(pargs.use_local) if pargs.zlim < 0: print("zlim must be positive!") usage() if pargs.slope < 0 or pargs.slope >= 90: print("Specify a slope angle in the range 0->90 degrees.") usage() cut_class = pargs.cut_class print("Cutting to class (terrain) {0:d}".format(cut_class)) pc = pointcloud.fromAny(lasname).cut_to_class(cut_class) if pc.get_size() < 10: print("Too few points in pointcloud.") return print("Sorting spatially...") pc.sort_spatially(FILTER_RAD) slope_arg = np.tan(np.radians(pargs.slope))**2 msg = "Using steepnes parameters: angle: {0:.2f} degrees, delta-z: {1:.2f}" print(msg.format(pargs.slope, pargs.zlim)) print("Filtering, radius: {0:.2f}".format(FILTER_RAD)) dz = pc.spike_filter(FILTER_RAD, slope_arg, pargs.zlim) mask = (dz != 0) dz = dz[mask] pc = pc.cut(mask) print("Spikes: {0:d}".format(mask.sum())) for i in xrange(pc.size): x, y = pc.xy[i] z = pc.z[i] mdz = dz[i] c = pc.c[i] pid = pc.pid[i] print("spike: x: {0:.2f} y: {1:.2f} mean-dz: {2:.2f}".format(x, y, mdz)) wkt_geom = "POINT({0:.2f} {1:.2f})".format(x, y) reporter.report(kmname, FILTER_RAD, mdz, x, y, z, c, pid, wkt_geom=wkt_geom)
def zcheck_base(lasname, vectorname, angle_tolerance, xy_tolerance, z_tolerance, cut_class, reporter, buffer_dist=None, layername=None, layersql=None): is_roads = buffer_dist is not None #'hacky' signal that its roads we're checking print("Starting zcheck_base run at %s" % time.asctime()) tstart = time.clock() kmname = constants.get_tilename(lasname) pc = pointcloud.fromAny(lasname) t2 = time.clock() tread = t2 - tstart print("Reading data took %.3f ms" % (tread * 1e3)) try: extent = np.asarray(constants.tilename_to_extent(kmname)) except Exception, e: print("Could not get extent from tilename.") extent = None
''' try: pargs = parser.parse_args(args[1:]) except TypeError, error_msg: print(str(error_msg)) return 1 lasname = pargs.las_file outdir = pargs.output_dir kmname = constants.get_tilename(pargs.las_file) print("Running %s on block: %s, %s" % (PROGNAME, kmname, time.asctime())) try: xll, yll, xlr, yul = constants.tilename_to_extent(kmname) except (ValueError, AttributeError), error_msg: print("Exception: %s" % error_msg) print("Bad 1km formatting of las file: %s" % lasname) return 1 o_name_grid = kmname + "_class" pts = pointcloud.fromAny(lasname) #terrain subset of surf so read filtered... print("Gridding classes...") cell_size = pargs.cs class_grid = pts.get_grid(x1=xll, x2=xlr, y1=yll, y2=yul, cx=cell_size, cy=cell_size, method="class") save_path = os.path.join(outdir, o_name_grid + '.tif') class_grid.save(save_path, dco=["TILED=YES", "COMPRESS=LZW"], srs=constants.srs) return 0 if __name__ == "__main__": sys.exit(main(sys.argv))
def main(args): try: pargs = parser.parse_args(args[1:]) except Exception, e: print(str(e)) return 1 kmname = constants.get_tilename(pargs.las_file) print("Running %s on block: %s, %s" % (progname, kmname, time.asctime())) lasname = pargs.las_file polyname = pargs.poly_data use_local = pargs.use_local if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportBuildingAbsposCheck(use_local) ################################## pc = pointcloud.fromAny(lasname).cut_to_class(cut_to_classes) try: extent = np.asarray(constants.tilename_to_extent(kmname)) except Exception, e: print("Could not get extent from tilename.") extent = None polys = vector_io.get_geometries(polyname, pargs.layername, pargs.layersql, extent) fn = 0 sl = "-" * 65 for poly in polys: n_corners_found = 0 fn += 1 print("%s\nChecking feature %d\n%s\n" % (sl, fn, sl)) a_poly = array_geometry.ogrgeom2array(poly) pcp = pc.cut_to_polygon(a_poly)
def main(args): pargs = parser.parse_args(args[1:]) lasname = pargs.las_file polyname = pargs.build_polys kmname = constants.get_tilename(lasname) print("Running %s on block: %s, %s" % (os.path.basename(args[0]), kmname, time.asctime())) use_local = pargs.use_local if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportRoofridgeCheck(use_local) cut_class = pargs.cut_class print("Using class(es): %s" % (cut_class)) # default step values for search... steps1 = 32 steps2 = 14 search_factor = pargs.search_factor if search_factor != 1: # can turn search steps up or down steps1 = int(search_factor * steps1) steps2 = int(search_factor * steps2) print("Incresing search factor by: %.2f" % search_factor) print( "Running time will increase exponentionally with search factor...") pc = pointcloud.fromAny(lasname).cut_to_class(cut_class).cut_to_z_interval( Z_MIN, Z_MAX) try: extent = np.asarray(constants.tilename_to_extent(kmname)) except Exception: print("Could not get extent from tilename.") extent = None polys = vector_io.get_geometries(polyname, pargs.layername, pargs.layersql, extent) fn = 0 sl = "+" * 60 is_sloppy = pargs.sloppy use_all = pargs.use_all for poly in polys: print(sl) fn += 1 print("Checking feature number %d" % fn) a_poly = array_geometry.ogrgeom2array(poly) # secret argument to use all buildings... if (len(a_poly) > 1 or a_poly[0].shape[0] != 5) and (not use_all) and (not is_sloppy): print("Only houses with 4 corners accepted... continuing...") continue pcp = pc.cut_to_polygon(a_poly) # hmmm, these consts should perhaps be made more visible... if (pcp.get_size() < 500 and (not is_sloppy)) or (pcp.get_size() < 10): print("Few points in polygon...") continue # Go to a more numerically stable coord system - from now on only consider outer ring... a_poly = a_poly[0] xy_t = a_poly.mean(axis=0) a_poly -= xy_t pcp.xy -= xy_t pcp.triangulate() geom = pcp.get_triangle_geometry() m = geom[:, 1].mean() sd = geom[:, 1].std() if (m > 1.5 or 0.5 * sd > m) and (not is_sloppy): print("Feature %d, bad geometry...." % fn) print(m, sd) continue planes = cluster(pcp, steps1, steps2) if len(planes) < 2: print("Feature %d, didn't find enough planes..." % fn) pair, equation = find_planar_pairs(planes) if pair is not None: p1 = planes[pair[0]] p2 = planes[pair[1]] z1 = p1[0] * pcp.xy[:, 0] + p1[1] * pcp.xy[:, 1] + p1[2] z2 = p2[0] * pcp.xy[:, 0] + p2[1] * pcp.xy[:, 1] + p2[2] print("%s" % ("*" * 60)) print("Statistics for feature %d" % fn) if DEBUG: plot3d(pcp.xy, pcp.z, z1, z2) intersections, distances, rotations = get_intersections( a_poly, equation) if intersections.shape[0] == 2: line_x = intersections[:, 0] line_y = intersections[:, 1] z_vals = p1[0] * intersections[:, 0] + p1[ 1] * intersections[:, 1] + p1[2] if abs(z_vals[0] - z_vals[1]) > 0.01: print("Numeric instabilty for z-calculation...") z_val = float(np.mean(z_vals)) print("Z for intersection is %.2f m" % z_val) if abs(equation[1]) > 1e-3: a = -equation[0] / equation[1] b = equation[2] / equation[1] line_y = a * line_x + b elif abs(equation[0]) > 1e-3: a = -equation[1] / equation[0] b = equation[2] / equation[0] line_x = a * line_y + b if DEBUG: plot_intersections(a_poly, intersections, line_x, line_y) # transform back to real coords line_x += xy_t[0] line_y += xy_t[1] wkt = "LINESTRING(%.3f %.3f %.3f, %.3f %.3f %.3f)" % ( line_x[0], line_y[0], z_val, line_x[1], line_y[1], z_val) print("WKT: %s" % wkt) reporter.report(kmname, rotations[0], distances[0], distances[1], wkt_geom=wkt) else: print( "Hmmm - something wrong, didn't get exactly two intersections..." )
ncols = int(ncols_f) nrows = ncols #tiles are square (for now) if ncols != ncols_f: print("TILE_SIZE: %d must be divisible by cell size..." % (TILE_SIZE)) usage() return 1 georef = [extent[0], cs, 0, extent[3], 0, -cs] print("Using cell size: %.2f" % cs) outdir = pargs.outdir if not os.path.exists(outdir): os.mkdir(outdir) outname_base = "dist_{0:.0f}_".format(cs) + os.path.splitext( os.path.basename(lasname))[0] + ".tif" outname = os.path.join(outdir, outname_base) print("Reading %s, writing %s" % (lasname, outname)) pc = pointcloud.fromAny(lasname) if not pargs.nocut: pc = pc.cut_to_class(CUT_TO) print("Sorting...") pc.sort_spatially(pargs.srad) print("Filtering...") xy = pointcloud.mesh_as_points((nrows, ncols), georef) d = pc.distance_filter(pargs.srad, xy=xy, nd_val=9999).reshape( (nrows, ncols)) g = grid.Grid(d, georef, 9999) g.save(outname, dco=["TILED=YES", "COMPRESS=LZW"], srs=SRS_WKT) return 0 if __name__ == "__main__": main(sys.argv)
def main(args): pargs = parser.parse_args(args[1:]) lasname = pargs.las_file polyname = pargs.build_polys kmname = constants.get_tilename(lasname) print("Running %s on block: %s, %s" % (os.path.basename(args[0]), kmname, time.asctime())) if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportRoofridgeStripCheck(pargs.use_local) cut_class = pargs.cut_class # default step values for search... steps1 = 30 steps2 = 13 search_factor = pargs.search_factor if search_factor != 1: # can turn search steps up or down steps1 = int(search_factor * steps1) steps2 = int(search_factor * steps2) print("Incresing search factor by: %.2f" % search_factor) print("Running time will increase exponentionally with search factor...") pc = pointcloud.fromAny(lasname).cut_to_class(cut_class).cut_to_z_interval(Z_MIN, Z_MAX) try: extent = np.asarray(constants.tilename_to_extent(kmname)) except Exception: print("Could not get extent from tilename.") extent = None polys = vector_io.get_geometries(polyname, pargs.layername, pargs.layersql, extent) fn = 0 sl = "+" * 60 is_sloppy = pargs.sloppy use_all = pargs.use_all for poly in polys: print(sl) fn += 1 print("Checking feature number %d" % fn) a_poly = array_geometry.ogrgeom2array(poly) # secret argument to use all buildings... if (len(a_poly) > 1 or a_poly[0].shape[0] != 5) and (not use_all) and (not is_sloppy): print("Only houses with 4 corners accepted... continuing...") continue pcp = pc.cut_to_polygon(a_poly) strips = pcp.get_pids() if len(strips) != 2: print("Not exactly two overlapping strips... continuing...") continue # Go to a more numerically stable coord system - from now on only consider outer ring... a_poly = a_poly[0] xy_t = a_poly.mean(axis=0) # center of mass system a_poly -= xy_t lines = [] # for storing the two found lines... for sid in strips: print("-*-" * 15) print("Looking at strip %d" % sid) pcp_ = pcp.cut_to_strip(sid) # hmmm, these consts should perhaps be made more visible... if (pcp_.get_size() < 500 and (not is_sloppy)) or (pcp_.get_size() < 10): print("Few points in polygon... %d" % pcp_.get_size()) continue pcp_.xy -= xy_t pcp_.triangulate() geom = pcp_.get_triangle_geometry() m = geom[:, 1].mean() sd = geom[:, 1].std() if (m > 1.5 or 0.5 * sd > m) and (not is_sloppy): print("Feature %d, strip %d, bad geometry...." % (fn, sid)) break planes = cluster(pcp_, steps1, steps2) if len(planes) < 2: print("Feature %d, strip %d, didn't find enough planes..." % (fn, sid)) pair, equation = find_planar_pairs(planes) if pair is not None: p1 = planes[pair[0]] print("%s" % ("*" * 60)) print("Statistics for feature %d" % fn) # Now we need to find some points on the line near the house... (0,0) is # the center of mass norm_normal = equation[0]**2 + equation[1]**2 if norm_normal < 1e-10: print("Numeric instablity, small normal") break # this should be on the line cm_line = np.asarray(equation[:2]) * (equation[2] / norm_normal) line_dir = np.asarray((-equation[1], equation[0])) / (sqrt(norm_normal)) end1 = cm_line + line_dir * LINE_RAD end2 = cm_line - line_dir * LINE_RAD intersections = np.vstack((end1, end2)) line_x = intersections[:, 0] line_y = intersections[:, 1] z_vals = p1[0] * intersections[:, 0] + p1[1] * intersections[:, 1] + p1[2] if abs(z_vals[0] - z_vals[1]) > 0.01: print("Numeric instabilty for z-calculation...") z_val = float(np.mean(z_vals)) print("Z for intersection is %.2f m" % z_val) # transform back to real coords line_x += xy_t[0] line_y += xy_t[1] wkt = "LINESTRING(%.3f %.3f %.3f, %.3f %.3f %.3f)" % ( line_x[0], line_y[0], z_val, line_x[1], line_y[1], z_val) print("WKT: %s" % wkt) lines.append([sid, wkt, z_val, cm_line, line_dir]) if len(lines) == 2: # check for parallelity id1 = lines[0][0] id2 = lines[1][0] z1 = lines[0][2] z2 = lines[1][2] if abs(z1 - z2) > 0.5: print("Large difference in z-values for the two lines!") else: ids = "{0:d}_{1:d}".format(id1, id2) inner_prod = (lines[0][4] * lines[1][4]).sum() inner_prod = max(-1, inner_prod) inner_prod = min(1, inner_prod) if DEBUG: print("Inner product: %.4f" % inner_prod) ang = abs(degrees(acos(inner_prod))) if ang > 175: ang = abs(180 - ang) if ang < 15: v = (lines[0][3] - lines[1][3]) d = np.sqrt((v**2).sum()) if d < 5: for line in lines: reporter.report(kmname, id1, id2, ids, d, ang, line[2], wkt_geom=line[1]) else: print("Large distance between centers %s, %s, %.2f" % (lines[0][3], lines[1][3], d)) else: print("Pair found - but not very well aligned - angle: %.2f" % ang) else: print("Pair not found...")
return ds, lyr def main(args): try: pargs = parser.parse_args(args[1:]) except Exception, e: print(str(e)) return 1 lasname = pargs.las_file kmname = constants.get_tilename(lasname) print("Running %s on block: %s, %s" % (progname, kmname, time.asctime())) if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportWobbly(pargs.use_local) pc = pointcloud.fromAny(lasname).cut_to_class(pargs.cut_to) print("%d points of class %d in this tile..." % (pc.get_size(), pargs.cut_to)) if pc.get_size() < 3: print("Few points of class %d in this tile..." % pargs.cut_to) return 0 print("Using z-limit %.2f m" % pargs.zmin) pc.sort_spatially(pargs.frad) meanz = pc.mean_filter(pargs.frad) diff = pc.z - meanz M = (np.fabs(diff) > pargs.zmin) n = M.sum() print("Found %d wobbly points" % n) if n > 0: pc = pc.cut(M) diff = diff[M]
else: reporter = report.ReportAutoBuilding(use_local) CS = 1 CELL_COUNT_LIM = 2 kmname = constants.get_tilename(lasname) print("Running %s on block: %s, %s" % (os.path.basename(args[0]), kmname, time.asctime())) try: xul, yll, xlr, yul = constants.tilename_to_extent(kmname) except Exception, e: print("Exception: %s" % str(e)) print("Bad 1km formatting of las file name: %s" % lasname) return 1 if pargs.height is not None: print("Cutting to z above %.2f m" % (pargs.height)) pc = pointcloud.fromAny(lasname).cut_to_z_interval( pargs.height, default_max_z) else: print("Cutting to class %d" % pargs.cut_to) pc = pointcloud.fromAny(lasname).cut_to_class(pargs.cut_to) if pc.get_size() == 0: print("No points after restriction...") return 0 cs = CS ncols = TILE_SIZE / cs nrows = ncols georef = [xul, cs, 0, yul, 0, -cs] arr_coords = ((pc.xy - (georef[0], georef[3])) / (georef[1], georef[5])).astype(np.int32) M = np.logical_and(arr_coords[:, 0] >= 0, arr_coords[:, 0] < ncols)
def main(args): try: pargs=parser.parse_args(args[1:]) except Exception,e: print(str(e)) return 1 kmname=constants.get_tilename(pargs.las_file) print("Running %s on block: %s, %s" %(progname,kmname,time.asctime())) lasname=pargs.las_file polyname=pargs.poly_data use_local=pargs.use_local if pargs.schema is not None: report.set_schema(pargs.schema) reporter=report.ReportBuildingRelposCheck(use_local) ################################## pc=pointcloud.fromAny(lasname).cut_to_z_interval(-10,200).cut_to_class(cut_to_classes) try: extent=np.asarray(constants.tilename_to_extent(kmname)) except Exception,e: print("Could not get extent from tilename.") extent=None polys=vector_io.get_geometries(polyname) fn=0 sl="-"*65 pcs=dict() for id in pc.get_pids(): print("%s\n" %("+"*70)) print("Strip id: %d" %id) pc_=pc.cut_to_strip(id) if pc_.get_size()>500: pcs[id]=pc_
else: fargs = json.loads(pargs.json_params) for name in NAMES: # test for defined names assert name in fargs if pargs.schema is not None: report.set_schema(pargs.schema) reporter_polys = report.ReportHoles(pargs.use_local) reporter_points = report.ReportHolePoints(pargs.use_local) if not os.path.exists(pargs.outdir): os.mkdir(pargs.outdir) # should be as a terrain grid - but problems with high veg on fields!!! pc = pointcloud.fromAny(pargs.las_file).cut_to_class(cut_to) pc_ref = pointcloud.fromAny(pargs.ref_data).cut_to_class(5) print("points in input-cloud: %d" % pc.get_size()) print("points in ref-cloud: %d" % pc_ref.get_size()) if pc.get_size() < 10 or pc_ref.get_size() < 100: print("Too few points.") return 1 print("Sorting...") pc.sort_spatially(FRAD) print("Filtering..") # so 1 of two criteria should be fullfilled: low, low, density or high pointdistance... d_in = pc.density_filter(FRAD, pc_ref.xy) pd_in = pc.distance_filter(FRAD, pc_ref.xy) M = np.logical_or(d_in < DEN_LIM, pd_in > PDIST_LIM) pc_pot = pc_ref.cut(M) if pc_pot.get_size() == 0:
Main script functionality. Can be invoked from either the command line or via qc_wrap.py ''' try: pargs = parser.parse_args(args[1:]) except Exception, error_msg: print(str(error_msg)) return 1 kmname = get_tilename(pargs.las_file) print("Running %s on block: %s, %s" % (PROGNAME, kmname, time.asctime())) if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportClassCount(pargs.use_local) pc = pointcloud.fromAny(pargs.las_file) n_points_total = pc.get_size() if n_points_total == 0: print( "Something is terribly terribly wrong here! Simon - vi skal melde en fjel" ) pc_temp = pc.cut_to_class(constants.created_unused) n_created_unused = pc_temp.get_size() pc_temp = pc.cut_to_class(constants.surface) n_surface = pc_temp.get_size() pc_temp = pc.cut_to_class(constants.terrain) n_terrain = pc_temp.get_size()
def main(args): ''' Run road delta check. Invoked from either command line or qc_wrap.py ''' pargs = parser.parse_args(args[1:]) lasname = pargs.las_file linename = pargs.lines kmname = constants.get_tilename(lasname) print("Running %s on block: %s, %s" % (os.path.basename(args[0]), kmname, time.asctime())) if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportDeltaRoads(pargs.use_local) cut_class = pargs.cut_class pc = pointcloud.fromAny(lasname).cut_to_class(cut_class) if pc.get_size() < 5: print("Too few points to bother..") return 1 pc.triangulate() geom = pc.get_triangle_geometry() print("Using z-steepnes limit {0:.2f} m".format(pargs.zlim)) mask = np.logical_and(geom[:, 1] < XY_MAX, geom[:, 2] > pargs.zlim) geom = geom[mask] # save for reporting if not mask.any(): print("No steep triangles found...") return 0 # only the centers of the interesting triangles centers = pc.triangulation.get_triangle_centers()[mask] print("{0:d} steep triangles in tile.".format(centers.shape[0])) try: extent = np.asarray(constants.tilename_to_extent(kmname)) except Exception: print("Could not get extent from tilename.") extent = None lines = vector_io.get_geometries(linename, pargs.layername, pargs.layersql, extent) feature_count = 0 for line in lines: xy = array_geometry.ogrline2array(line, flatten=True) if xy.shape[0] == 0: print("Seemingly an unsupported geometry...") continue # select the triangle centers which lie within line_buffer of the road segment mask = array_geometry.points_in_buffer(centers, xy, LINE_BUFFER) critical = centers[mask] print("*" * 50) print("{0:d} steep centers along line {1:d}".format(critical.shape[0], feature_count)) feature_count += 1 if critical.shape[0] > 0: z_box = geom[mask][:, 2] z1 = z_box.max() z2 = z_box.min() wkt = "MULTIPOINT(" for point in critical: wkt += "{0:.2f} {1:.2f},".format(point[0], point[1]) wkt = wkt[:-1] + ")" reporter.report(kmname, z1, z2, wkt_geom=wkt)
os.mkdir(outdir) cut_to=pargs.cut_to cs=pargs.cs ncols_f=TILE_SIZE/cs ncols=int(ncols_f) nrows=ncols #tiles are square (for now) if ncols!=ncols_f: print("TILE_SIZE: %d must be divisible by cell size...(cs=%.2f)\n" %(TILE_SIZE,cs)) return 1 print("Using cell size: %.2f" %cs) outname_base="diff_{0:.0f}_".format(cs)+os.path.splitext(os.path.basename(lasname))[0]+".tif" outname=os.path.join(outdir,outname_base) if os.path.exists(outname) and not pargs.overwrite: print("Output file already exists - doing nothing (use -overwrite)") return 0 pc=pointcloud.fromAny(lasname).cut_to_class(CUT_CLASS) #what to cut to here...?? if pc.get_size()<MIN_POINT_LIMIT_BASE: print("Few points, %d, in input pointcloud , won't bother..." %pc.get_size()) return 0 pc_ref=pointcloud.fromAny(pointname).cut_to_class(cut_to) print("%d points in reference pointcloud." %pc_ref.get_size()) if pc_ref.get_size()<MIN_POINT_LIMIT: print("Too few, %d, reference points - sorry..." %pc_ref.get_size()) return 0 if pargs.toE: geoid=grid.fromGDAL(GEOID_GRID,upcast=True) print("Using geoid from %s to warp to ellipsoidal heights." %GEOID_GRID) pc_ref.toE(geoid) t0=time.clock() pc.sort_spatially(pargs.srad) z_new=pc.idw_filter(pargs.srad,xy=pc_ref.xy,nd_val=ND_VAL)
geoid_h = geoid.interpolate(lake_centroid_pts)[0] print("Geoid h is: %.2f" % geoid_h) else: geoid_h = 0 lake_buf = lake_geom.Buffer(0.4) lake_in_tile = lake_geom.Intersection(tg) intersection_area = lake_in_tile.GetArea() #if intersection_area/lake_area<0.15: # print("Not enough area covered by tile. Dont wanna make any judgements based on that!") # continue lake_buffer_in_tile = lake_buf.Intersection(tg) if pargs.verbose: print(lake_buffer_in_tile.GetGeometryName()) print(lake_buffer_in_tile.GetGeometryCount()) if pc is None: pc = pointcloud.fromAny(pargs.las_file).cut_to_class(cut_to) lake_extent = lake_geom.GetEnvelope() extent_here = [ max(lake_extent[0], extent[0]), max(lake_extent[2], extent[1]), min(lake_extent[1], extent[2]), min(lake_extent[3], extent[3]) ] print extent_here cs = CS geo_ref = [extent_here[0], cs, 0, extent_here[3], 0, -cs] ncols = int((extent_here[2] - extent_here[0]) / cs) nrows = int((extent_here[3] - extent_here[1]) / cs) xy_mesh = pointcloud.mesh_as_points((nrows, ncols), geo_ref) z_mesh = np.zeros((xy_mesh.shape[0], ), dtype=np.float64) pc_mesh = pointcloud.Pointcloud(xy_mesh, z_mesh)
use_local=pargs.use_local if pargs.schema is not None: report.set_schema(pargs.schema) reporter=report.ReportLineOutliers(use_local) try: extent=np.asarray(constants.tilename_to_extent(kmname)) except Exception,e: print("Could not get extent from tilename.") raise e lines=vector_io.get_features(linename,pargs.layername,pargs.layersql,extent) print("Found %d features in %s" %(len(lines),linename)) if len(lines)==0: return 2 cut_input_to=pargs.cut_to print("Reading "+lasname+"....") pc=pointcloud.fromAny(lasname).cut_to_class(cut_input_to) #what to cut to here...?? if pargs.debug: print("Cutting input pointcloud to class %d" %cut_input_to) if pc.get_size()<5: print("Few points in pointcloud!!") return 3 if pargs.toH: geoid=grid.fromGDAL(GEOID_GRID,upcast=True) print("Using geoid from %s to warp to orthometric heights." %GEOID_GRID) pc.toH(geoid) print("Sorting...") pc.sort_spatially(pargs.srad) print("Starting loop..") n_found=0 for line in lines: if pargs.id_attr is not None:
parser.print_help() def main(args): try: pargs = parser.parse_args(args[1:]) except Exception, e: print(str(e)) return 1 lasname = pargs.las_file kmname = constants.get_tilename(lasname) print("Running %s on block: %s, %s" % (progname, kmname, time.asctime())) if pargs.schema is not None: report.set_schema(pargs.schema) reporter = report.ReportSteepTriangles(pargs.use_local) pc = pointcloud.fromAny(lasname, cls=[pargs.cut_to]) print("%d points of class %d in this tile..." % (pc.get_size(), pargs.cut_to)) if pc.get_size() < 3: print("Few points of class %d in this tile..." % pargs.cut_to) return 0 print("Using slope limit %.2f deg" % pargs.slope) pc.triangulate() tv2 = tan(radians(pargs.slope)) geom = pc.get_triangle_geometry() M = np.logical_and(geom[:, 1] < xy_max, geom[:, 2] > pargs.zmin) M &= (geom[:, 0]) > tv2 geom = geom[M] #save for reporting n = M.sum() print("Found %d steep triangles... reporting centers..." % n)