Ejemplo n.º 1
0
def provision(
    bbox: BBOX,
    run_id: str,
    src_layer_name: str,
    dst_layer_name: str,
) -> List[str]:
    kmz_driver = ogr.GetDriverByName("LIBKML")
    kmz_datasets = [
        kmz_driver.Open(filename) for filename in glob.iglob(
            get_data_path(("avcan-ates-areas-2020-06-23", "**", "*.kmz")),
            recursive=True,
        )
    ]
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory, exist_ok=True)
    path = os.path.join(run_directory, f"{dst_layer_name}.shp")
    ogr_to_shp(
        bbox,
        [ds.GetLayerByName(src_layer_name) for ds in kmz_datasets],
        path,
        dst_layer_name,
        OUTPUT_CRS_CODE,
    )
    kmz_datasets = None
    return [path]
def provision(bbox: BBOX, run_id: str) -> List[str]:
    logging.info(
        "Retrieving BC Freshwater Atlas - this could take a while the first time"
    )
    zip_path = fetch("FWA_BC.zip", "ftp.geobc.gov.bc.ca",
                     "/sections/outgoing/bmgs/FWA_Public")
    fgdb_dir = os.path.dirname(zip_path)
    fgdb = os.path.join(fgdb_dir, "FWA_BC.gdb")
    if not os.path.exists(fgdb):
        with zipfile.ZipFile(zip_path, "r") as zip_ref:
            zip_ref.extractall(get_cache_path((fgdb, )))
    logging.info("Retrieved BC Freshwater Atlas")
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("OpenFileGDB")
    datasource = driver.Open(fgdb)
    path = os.path.join(run_directory, "bc_wetlands.shp")
    ogr_to_shp(
        bbox,
        [datasource.GetLayerByName("FWA_WETLANDS_POLY")],
        path,
        "bc_wetlands",
        OUTPUT_CRS_CODE,
    )
    datasource = None
    return [path]
Ejemplo n.º 3
0
def provision(bbox: BBOX, run_id: str) -> List[str]:
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("GPKG")
    datasource = driver.Open(LOCAL_FEATURES_PATH)
    path = os.path.join(run_directory, "trails.shp")
    ogr_to_shp(
        bbox,
        [datasource.GetLayerByName("trails")],
        path,
        "trails",
        OUTPUT_CRS_CODE,
    )
    datasource = None
    return [path]
Ejemplo n.º 4
0
def provision(bbox: BBOX, run_id: str) -> List[str]:
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("OpenFileGDB")
    datasource = driver.Open(
        get_data_path(("FTEN_ROAD_SEGMENT_LINES_SVW.gdb", )))
    path = os.path.join(run_directory, "bc_resource_roads.shp")
    ogr_to_shp(
        bbox,
        [
            datasource.GetLayerByName(
                "WHSE_FOREST_TENURE_FTEN_ROAD_SEGMENT_LINES_SVW")
        ],
        path,
        "bc_resource_roads",
        OUTPUT_CRS_CODE,
    )
    datasource = None
    return [path]
Ejemplo n.º 5
0
def provision(bbox: BBOX, run_id: str) -> List[str]:
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("OpenFileGDB")
    datasource = driver.Open(get_data_path(("FTEN_RECREATION_POLY_SVW.gdb", )))
    rec_sites_layer = datasource.GetLayerByName(
        "WHSE_FOREST_TENURE_FTEN_RECREATION_POLY_SVW")
    rec_sites_layer.SetAttributeFilter(
        "LIFE_CYCLE_STATUS_CODE IN ('ACTIVE','PENDING')")
    path = os.path.join(run_directory, "bc_rec_sites.shp")
    ogr_to_shp(
        bbox,
        [rec_sites_layer],
        path,
        "bc_rec_sites",
        OUTPUT_CRS_CODE,
    )
    rec_sites_layer = None
    datasource = None
    return [path]
def provision(bbox: BBOX, run_id: str) -> List[str]:
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("OpenFileGDB")
    datasource = driver.Open(
        get_data_path(("pmbc_parcel_fabric_poly_svw.gdb", )))
    parcels_layer = datasource.GetLayerByName("pmbc_parcel_fabric_poly_svw")
    parcels_layer.SetAttributeFilter(
        "OWNER_TYPE IN ('First Nation','Mixed Ownership','Municipal','Private','Unknown')"
    )
    path = os.path.join(run_directory, "bc_parcels.shp")
    ogr_to_shp(
        bbox,
        [parcels_layer],
        path,
        "bc_parcels",
        OUTPUT_CRS_CODE,
    )
    parcels_layer = None
    datasource = None
    return [path]
def provision(bbox: BBOX, run_id: str) -> List[str]:
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("GPKG")
    datasource = driver.Open(get_local_features_path())
    result = ogr_to_shp(
        bbox,
        [datasource.GetLayerByName("trails")],
        os.path.join(run_directory, "trails.shp"),
        "trails",
        OUTPUT_CRS_CODE,
    )
    datasource = None
    return result
Ejemplo n.º 8
0
def provision(bbox: BBOX, run_id: str) -> List[str]:
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("ESRI Shapefile")
    datasource = driver.Open(
        get_data_path(("FTEN_ROAD_SECTION_LINES_SVW", "FTEN_RS_LN_line.shp")))
    result = ogr_to_shp(
        bbox,
        [datasource.GetLayerByIndex(0)],
        os.path.join(run_directory, "bc_resource_roads.shp"),
        "bc_resource_roads",
        OUTPUT_CRS_CODE,
    )
    datasource = None
    return result
Ejemplo n.º 9
0
def provision(bbox: BBOX, run_id: str) -> List[str]:
    logging.info(
        "Retrieving BC Freshwater Atlas - this could take a while the first time"
    )
    fgdb = retrieve_directory("ftp.geobc.gov.bc.ca",
                              "/sections/outgoing/bmgs/FWA_Public/FWA_BC.gdb")
    logging.info("Retrieved BC Freshwater Atlas")
    run_directory = get_run_data_path(run_id, (CACHE_DIR_NAME, ))
    os.makedirs(run_directory)
    driver = ogr.GetDriverByName("OpenFileGDB")
    datasource = driver.Open(fgdb)
    result = ogr_to_shp(
        bbox,
        [datasource.GetLayerByName("FWA_WETLANDS_POLY")],
        os.path.join(run_directory, "bc_wetlands.shp"),
        "bc_wetlands",
        OUTPUT_CRS_CODE,
    )
    datasource = None
    return result