def test_dump_load(some_point, tmpdir): file = tmpdir.join("test.wkt") with open(file, "w") as file_pointer: dump(some_point, file_pointer) with open(file, "r") as file_pointer: restored = load(file_pointer) assert some_point == restored
def get_wkt_bbox(fname): try: from shapely import wkt except ImportError: logger.error("Need shapely installed to load from .wkt file") raise return wkt.load(fname).bounds
def test_dump_load_null_geometry(empty_geometry, tmpdir): file = tmpdir.join("test.wkt") with open(file, "w") as file_pointer: dump(empty_geometry, file_pointer) with open(file, "r") as file_pointer: restored = load(file_pointer) # This is does not work with __eq__(): assert empty_geometry.equals(restored)
IMAGE_SIZE_Y = 1024 # in pixels RESOLUTION = 0.25 # in meters per pixel along x and y axis BBOX_CENTER_OFFSET_X = IMAGE_SIZE_X * RESOLUTION / 2 BBOX_CENTER_OFFSET_Y = IMAGE_SIZE_Y * RESOLUTION / 2 IMAGES_PER_OBJECT = 5 TRAIN_TEST_SPLIT = 1 / 10 DATA_DIR = '../data/windturbines/' RATIO_POS_NEG_SAMPLES = 1 / 10 RD_X_MIN = 646.36 RD_X_MAX = 308975.28 RD_Y_MIN = 276050.82 RD_Y_MAX = 636456.31 # Build Netherlands geometry to check randomly created points to fall within with open('Netherlands.txt') as csv_neth: netherlands = wkt.load(csv_neth) # Get list of objects to get aerial imagery for payload = ''' PREFIX brt: <http://brt.basisregistraties.overheid.nl/def/top10nl#> PREFIX geo: <http://www.opengis.net/ont/geosparql#> prefix pdok: <http://data.pdok.nl/def/pdok#> SELECT * WHERE {{ ?instance a ?class ; geo:hasGeometry/pdok:asWKT-RD ?rd ; geo:hasGeometry/geo:asWKT ?wgs84 . filter( ?class = brt:{} ) }}
def madagascar(scope="module"): """Load a simplified geometry of Madagascar.""" fname = resource_filename(__name__, "data/madagascar.wkt") with open(fname) as f: return wkt.load(f)
def senegal(scope="module"): """Load a simplified geometry of Senegal.""" fname = resource_filename(__name__, "data/senegal.wkt") with open(fname) as f: return wkt.load(f)
def get_wkt_bbox(fname): from shapely import wkt with open(fname) as f: return wkt.load(f).bounds