Skip to content

Commit

Permalink
Brat: metadata values as strings, fix unpacking project nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyMWhitehead committed Sep 8, 2021
1 parent 594d9ef commit 22fb53d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/commons/rscommons/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def create_database(huc: str, db_path: str, metadata: Dict[str, str], epsg: int,
# We need to create a projection for this DB
db_srs = osr.SpatialReference()
db_srs.ImportFromEPSG(int(epsg))
metadata['gdal_srs_proj4'] = db_srs.ExportToProj4()
metadata['gdal_srs_axis_mapping_strategy'] = osr.OAMS_TRADITIONAL_GIS_ORDER
metadata['gdal_srs_proj4'] = str(db_srs.ExportToProj4())
metadata['gdal_srs_axis_mapping_strategy'] = str(osr.OAMS_TRADITIONAL_GIS_ORDER)

if not os.path.isfile(schema_path):
raise Exception('Unable to find database schema file at {}'.format(schema_path))
Expand Down
14 changes: 7 additions & 7 deletions packages/brat/sqlbrat/brat_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def brat_build(huc: int, flowlines: Path, dem: Path, slope: Path, hillshade: Pat
project.add_project_raster(proj_nodes['Inputs'], LayerTypes['HILLSHADE'], hillshade)
project.add_project_raster(proj_nodes['Inputs'], LayerTypes['SLOPE'], slope)
project.add_project_geopackage(proj_nodes['Inputs'], LayerTypes['INPUTS'])
db_node, _db_path = project.add_project_geopackage(proj_nodes['Outputs'], LayerTypes['OUTPUTS'])
db_node, _db_path, *_ = project.add_project_geopackage(proj_nodes['Outputs'], LayerTypes['OUTPUTS'])

inputs_gpkg_path = os.path.join(output_folder, LayerTypes['INPUTS'].rel_path)
intermediates_gpkg_path = os.path.join(output_folder, LayerTypes['INTERMEDIATES'].rel_path)
Expand Down Expand Up @@ -153,12 +153,12 @@ def brat_build(huc: int, flowlines: Path, dem: Path, slope: Path, hillshade: Pat

db_metadata = {
'BRAT_Build_DateTime': datetime.datetime.now().isoformat(),
'Streamside_Buffer': streamside_buffer,
'Riparian_Buffer': riparian_buffer,
'Reach_Codes': reach_codes,
'Canal_Codes': canal_codes,
'Max_Waterbody': max_waterbody,
'Elevation_Buffer': elevation_buffer
'Streamside_Buffer': str(streamside_buffer),
'Riparian_Buffer': str(riparian_buffer),
'Reach_Codes': ','.join(reach_codes),
'Canal_Codes': ','.join(canal_codes),
'Max_Waterbody': str(max_waterbody),
'Elevation_Buffer': str(elevation_buffer)
}

# Execute the SQL to create the lookup tables in the output geopackage
Expand Down

0 comments on commit 22fb53d

Please sign in to comment.