Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tilequeue.transform import apply_to_all_coords
- from tilequeue.transform import rescale_point
- import shapely.wkt
- def coerce_int((x, y)):
- return int(x), int(y)
- def make_fn(fn):
- def _fn((x, y)):
- x, y = fn((x, y))
- return coerce_int((x, y))
- return _fn
- scale = 4096
- bounds = (0., 0., 4096., 4096.)
- geometry_wkt = 'POLYGON((0 0, 4096 0, 4096 4096, 0 4096, 0 0))'
- shape = shapely.wkt.loads(geometry_wkt)
- rescale_fn = rescale_point(bounds, scale)
- fn = make_fn(rescale_fn)
- transform_fn = apply_to_all_coords(fn)
- transformed_shape = transform_fn(shape)
- print transformed_shape.wkt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement