# Generate InShape class
SHAPE = InShape(shape_path)
# Create shapely polygon from imported shapefile 
UNIQUE_SHAPE = SHAPE.shape_poly()
#print type(UNIQUE_SHAPE)
# Generate InPoly class
INPOLY = InPoly(shape_path)
# Create matplotlib Path object from imported shapefile
#outer_shape = UNIQUE_SHAPE.buffer(1.,resolution=1)
#inner_shape = UNIQUE_SHAPE.buffer(-8,resolution=1)

#outer_poly = INPOLY.poly_from_shape(shape=outer_shape)
#inner_poly = INPOLY.poly_from_shape(shape=inner_shape)

poly = INPOLY.poly_from_shape(shape=UNIQUE_SHAPE)

many_points = INPOLY.rand_poly(poly=poly, N=1e5)

# Scale smaller shape to fit inside larger shape. 
#SMALL_SHAPE = scale(UNIQUE_SHAPE, xfact=0.3, yfact=0.3)
#points_in_small_shape = INPOLY.rand_shape(shape=SMALL_SHAPE, IN=False)
# Generate matplotlib Path object for the small scalled polygon 
#small_poly = INPOLY.node_poly(SHAPE.external_coords(shape=SMALL_SHAPE))
# Remove points that are outside the buffered_poly
#outer_poly_points = INPOLY.points_in(many_points, poly=outer_poly)

# Remove points that are inside the small_poly
poly_points = np.asarray(INPOLY.points_in(many_points, 
                                                poly=poly,
                                                IN=True))
/AGOS/PROGRAMS/ANT/Versions/26.04.2015/shapefiles/aus.shp"

t0 = dt.datetime.now()

# Generate InShape class
SHAPE = InShape(shape_path)
# Create shapely polygon from imported shapefile 
UNIQUE_SHAPE = SHAPE.shape_poly()
print type(UNIQUE_SHAPE)
# Generate InPoly class
INPOLY = InPoly(shape_path)
# Create matplotlib Path object from imported shapefile
outer_shape = UNIQUE_SHAPE.buffer(1.,resolution=1)
inner_shape = UNIQUE_SHAPE.buffer(-8,resolution=1)

outer_poly = INPOLY.poly_from_shape(shape=outer_shape)
inner_poly = INPOLY.poly_from_shape(shape=inner_shape)
many_points = INPOLY.rand_poly(poly=outer_poly, N=1e4)

# Scale smaller shape to fit inside larger shape. 
#SMALL_SHAPE = scale(UNIQUE_SHAPE, xfact=0.3, yfact=0.3)
#points_in_small_shape = INPOLY.rand_shape(shape=SMALL_SHAPE, IN=False)
# Generate matplotlib Path object for the small scalled polygon 
#small_poly = INPOLY.node_poly(SHAPE.external_coords(shape=SMALL_SHAPE))
# Remove points that are outside the buffered_poly
outer_poly_points = INPOLY.points_in(many_points, poly=outer_poly)

# Remove points that are inside the small_poly
inner_poly_points = np.asarray(INPOLY.points_in(outer_poly_points, 
                                                poly=inner_poly,
                                                IN=False))
Exemple #3
0
# Generate InShape class
SHAPE = InShape(shape_path)
# Create shapely polygon from imported shapefile
UNIQUE_SHAPE = SHAPE.shape_poly()
#print type(UNIQUE_SHAPE)
# Generate InPoly class
INPOLY = InPoly(shape_path)
# Create matplotlib Path object from imported shapefile
#outer_shape = UNIQUE_SHAPE.buffer(1.,resolution=1)
#inner_shape = UNIQUE_SHAPE.buffer(-8,resolution=1)

#outer_poly = INPOLY.poly_from_shape(shape=outer_shape)
#inner_poly = INPOLY.poly_from_shape(shape=inner_shape)

poly = INPOLY.poly_from_shape(shape=UNIQUE_SHAPE)

many_points = INPOLY.rand_poly(poly=poly, N=1e5)

# Scale smaller shape to fit inside larger shape.
#SMALL_SHAPE = scale(UNIQUE_SHAPE, xfact=0.3, yfact=0.3)
#points_in_small_shape = INPOLY.rand_shape(shape=SMALL_SHAPE, IN=False)
# Generate matplotlib Path object for the small scalled polygon
#small_poly = INPOLY.node_poly(SHAPE.external_coords(shape=SMALL_SHAPE))
# Remove points that are outside the buffered_poly
#outer_poly_points = INPOLY.points_in(many_points, poly=outer_poly)

# Remove points that are inside the small_poly
poly_points = np.asarray(INPOLY.points_in(many_points, poly=poly, IN=True))

cluster_points = np.asarray(kmeans(poly_points, n_stations)[0])