Пример #1
0
    print(py)

    t0 = time.time()

    print("Centroid sampling:")
    cs = CentroidSampler(py)
    cs.perform_sampling()
    cs.print_samples()

    print("Representative point sampling:")
    ls = RepresentativePointSampler(py)
    ls.perform_sampling()
    ls.print_samples()

    print("Regular grid sampling:")
    rs = RegularGridSampler(py, 500, 500)
    rs.perform_sampling()
    rs.print_samples()

    print("Uniform random sampling:")
    us = UniformRandomSampler(py, 25)
    # us.set_sample_count(500)
    us.perform_sampling()
    us.print_samples()

    # us.print_triangles()

    print("Skeleton line sampling:")
    sls = SkeletonLineSampler(py)
    sls.perform_sampling()
    sls.print_samples()
Пример #2
0
    t0 = time.time()

    print "Centroid sampling:"
    cs = CentroidSampler(py)
    cs.perform_sampling()
    for s in cs.samples:
        print "\t", s
    
    print "Label point sampling:"
    ls = LabelPointSampler(py)
    ls.perform_sampling()
    for s in ls.samples:
        print "\t", s
    
    print "Regular grid sampling:"
    rs = RegularGridSampler(py, 500, 500)
    rs.perform_sampling()
    for s in rs.samples:
        print "\t", s
    
    print "Uniform random sampling:"
    us = UniformRandomSampler(py, 25)
    #us.set_sample_count(500)
    us.perform_sampling()
    for s in us.samples:
        print "\t", s
    
    #us.print_triangles()
    
    print "Skeleton line sampling:"
    sls = SkeletonLineSampler(py)
Пример #3
0
    tgt_ly.CreateField(new_field)

    i = 0

    for ft in ly:
        t = ft.GetFieldAsString('type')
        if t != tgt_type:
            continue

        gm = ft.GetGeometryRef()
        py = loads(gm.ExportToWkb())

        #sls = SkeletonLineSampler(py)
        #sls.perform_sampling()

        rgs = RegularGridSampler(py, 20, 20)
        rgs.perform_sampling()

        for s in rgs.samples:
            i += 1
            print "\t", s
            tgt_gm = ogr.Geometry(ogr.wkbPoint)
            tgt_gm.SetPoint_2D(0, s.x, s.y)
            tgt_ft = ogr.Feature(tgt_ly.GetLayerDefn())
            tgt_ft.SetGeometry(tgt_gm)
            tgt_ft.SetField('type', tgt_type)
            tgt_ft.SetField('id', i)
            tgt_ft.SetField('x', s.x)
            tgt_ft.SetField('y', s.y)
            tgt_ly.CreateFeature(tgt_ft)
Пример #4
0
    tgt_ly.CreateField(new_field)
    
    i = 0

    for ft in ly:
        t = ft.GetFieldAsString('type')
        if t != tgt_type:
            continue
        
        gm = ft.GetGeometryRef()
        py = loads(gm.ExportToWkb())
        
        #sls = SkeletonLineSampler(py)
        #sls.perform_sampling()

        rgs = RegularGridSampler(py, 20, 20)
        rgs.perform_sampling()
        
        for s in rgs.samples:
            i += 1
            print "\t", s
            tgt_gm = ogr.Geometry(ogr.wkbPoint)
            tgt_gm.SetPoint_2D(0, s.x, s.y)
            tgt_ft = ogr.Feature(tgt_ly.GetLayerDefn())
            tgt_ft.SetGeometry(tgt_gm)
            tgt_ft.SetField('type', tgt_type)
            tgt_ft.SetField('id', i)
            tgt_ft.SetField('x', s.x)
            tgt_ft.SetField('y', s.y)
            tgt_ly.CreateFeature(tgt_ft)