Skip to content

Commit

Permalink
point to published BC Boundary layer and fix alias/designation key in…
Browse files Browse the repository at this point in the history
… CLI
  • Loading branch information
smnorris committed Jun 25, 2020
1 parent 9947a9f commit 8d90268
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions designatedlands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def cli():

@cli.command()
@click.argument("config_file", type=click.Path(exists=True), required=False)
@click.option("--alias", "-a", help="The 'alias' key for the source of interest")
@click.option("--designation", "-d", help="The 'designation' key for the source of interest")
@click.option(
"--overwrite",
is_flag=True,
Expand All @@ -48,17 +48,17 @@ def cli():
)
@verbose_opt
@quiet_opt
def download(config_file, alias, overwrite, verbose, quiet):
def download(config_file, designation, overwrite, verbose, quiet):
"""Download data, load to postgres
"""
set_log_level(verbose, quiet)
DL = DesignatedLands(config_file)
DL.download(alias=alias, overwrite=overwrite)
DL.download(designation=designation, overwrite=overwrite)


@cli.command()
@click.argument("config_file", type=click.Path(exists=True), required=False)
@click.option("--alias", "-a", help="The 'alias' key for the source of interest")
@click.option("--designation", "-a", help="The 'designation' key for the source of interest")
@click.option(
"--overwrite",
is_flag=True,
Expand All @@ -67,11 +67,11 @@ def download(config_file, alias, overwrite, verbose, quiet):
)
@verbose_opt
@quiet_opt
def preprocess(config_file, alias, overwrite, verbose, quiet):
def preprocess(config_file, designation, overwrite, verbose, quiet):
"""Create tiles layer and preprocess sources where required"""
set_log_level(verbose, quiet)
DL = DesignatedLands(config_file)
DL.preprocess(alias=alias)
DL.preprocess(designation=designation)
DL.create_bc_boundary()


Expand Down
16 changes: 8 additions & 8 deletions designatedlands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def read_sources(self):
for i, source in enumerate(supporting_list, start=(len(self.sources) + 1)):
source["id"] = i
source["hierarchy"] = "00"
source["src"] = "designatedlands." + source["alias"]
source["src"] = "designatedlands." + source["designation"]
self.sources_supporting = supporting_list

# load source csv to the db
Expand Down Expand Up @@ -279,17 +279,17 @@ def validate_sources(self):
)
)

def download(self, alias=None, overwrite=False):
def download(self, designation=None, overwrite=False):
"""Download source data
"""

sources = self.sources_supporting + self.sources

# if supplied a layer name, only process that layer
if alias:
sources = [s for s in sources if s["alias"] == alias]
if designation:
sources = [s for s in sources if s["designation"] == designation]
if not sources:
raise ValueError("Alias %s does not exist" % alias)
raise ValueError("designation %s does not exist" % designation)

# download and load everything that we can automate
for source in [s for s in sources if s["manual_download"] != "T"]:
Expand Down Expand Up @@ -359,7 +359,7 @@ def download(self, alias=None, overwrite=False):
else:
LOG.info(source["src"] + " already loaded.")

def preprocess(self, alias=None):
def preprocess(self, designation=None):
"""
Preprocess sources as specified
Supported operations:
Expand All @@ -374,8 +374,8 @@ def preprocess(self, alias=None):
preprocess_sources = [
s for s in self.sources if s["preprocess_operation"] != ""
]
if alias:
preprocess_sources = [s for s in preprocess_sources if s["alias"] == alias]
if designation:
preprocess_sources = [s for s in preprocess_sources if s["designation"] == designation]
LOG.info("Preprocessing")
for source in preprocess_sources:
if source["preprocess_operation"] not in ["clip", "union"]:
Expand Down
4 changes: 2 additions & 2 deletions sources_supporting.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
manual_download,name,alias,url,file_in_url,layer_in_file,query,metadata_url,info_url,notes,license
manual_download,name,designation,url,file_in_url,layer_in_file,query,metadata_url,info_url,notes,license
,"BCGS 1:20,000 Grid",tiles_20k,https://catalogue.data.gov.bc.ca/dataset/bcgs-1-20-000-grid,,,,https://catalogue.data.gov.bc.ca/dataset/bcgs-1-20-000-grid,,Used to tile processing,Open Government License - British Columbia
,BC Marine Ecosections,marine_ecosections,https://catalogue.data.gov.bc.ca/dataset/marine-ecosections-coastal-resource-information-management-system-crims,,,,https://catalogue.data.gov.bc.ca/dataset/marine-ecosections-coastal-resource-information-management-system-crims,,"Defines BC Marine Ecounits, used in combination with bc_boundary_abms to define marine areas",Open Government License - British Columbia
,NTS 250k Grid,tiles_250k,https://catalogue.data.gov.bc.ca/dataset/nts-250k-grid-digital-baseline-mapping-at-1-250-000-nts,,,,https://catalogue.data.gov.bc.ca/dataset/nts-250k-grid-digital-baseline-mapping-at-1-250-000-nts,,Used to tile processing in marine areas not covered by 20k tiles,Open Government License - British Columbia
,"BC Boundary, ABMS (includes marine)",bc_abms,https://catalogue.data.gov.bc.ca/dataset/province-of-british-columbia-legally-defined-administrative-areas-of-bc,,,,https://catalogue.data.gov.bc.ca/dataset/province-of-british-columbia-legally-defined-administrative-areas-of-bc,,"Defines BC administrative area, including some marine",Access Only
,Muskwa-Kechika Management Area boundary,mk_boundary,https://catalogue.data.gov.bc.ca/dataset/tantalis-management-areas-spatial,,,,https://catalogue.data.gov.bc.ca/dataset/tantalis-management-areas-spatial,,,Open Government License - British Columbia
T,"BC Boundary, land",bc_boundary_land,,BC_Boundary.gdb,BC_Boundary_Terrestrial_Singlepart,,,,Defines terrestrial area of BC,
,"BC Boundary, land",bc_boundary_land,ftp://ftp.geobc.gov.bc.ca/sections/outgoing/bmgs/BC_Boundary_Terrestrial/BC_Boundary_Terrestrial.gdb.zip,BC_Boundary_Terrestrial.gdb,BC_Boundary_Terrestrial_Singlepart,,,,Defines terrestrial area of BC,

0 comments on commit 8d90268

Please sign in to comment.