Skip to content

Commit

Permalink
change how attributes are concatenated during shp unpack to avoid slo…
Browse files Browse the repository at this point in the history
…w looping
  • Loading branch information
torimcd committed Oct 25, 2024
1 parent f9627d8 commit 7743188
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
### Removed
### Fixed
- Issue 258 - Granules with very large feature counts cannot be added to hydrocron
- Issue 235 - Track ingest table can be populated with granules that aren't loaded into Hydrocron
- Issue 248 - Track ingest operations need to query UAT for granule files if track ingest is running in SIT or UAT
### Security
Expand Down
11 changes: 8 additions & 3 deletions hydrocron/db/io/swot_shp.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def handle_null_geometries(geodf):
geodf_no_nulls : geopandas.GeoDataFrame
the geodataframe with null geometries handled
"""

logging.info('Starting handle null geometries')
geodf['geometry'].fillna(
value=Polygon(constants.SWOT_PRIOR_LAKE_FILL_GEOMETRY_COORDS),
inplace=True)
Expand All @@ -131,6 +131,8 @@ def convert_polygon_to_centerpoint(geodf_polygon):
geodf_centerpoint : geopandas.GeoDataFrame
the geodataframe with point feature types and calculated centerpoint geometries
"""
logging.info('Starting convert polygon to centerpoint')

geodf_centerpoint = geodf_polygon
geodf_centerpoint['geometry'] = geodf_polygon['geometry'].centroid

Expand All @@ -152,6 +154,7 @@ def parse_metadata_from_shpxml(xml_elem):
metadata_attrs : dict
a dictionary of metadata attributes to add to record
"""
logging.info('Starting parse metadata from shpfile')
# get SWORD version
for globs in xml_elem.findall('global_attributes'):
prior_db_files = globs.find('xref_prior_river_db_files').text
Expand Down Expand Up @@ -191,10 +194,12 @@ def assemble_attributes(geodf, attributes):
attributes : dict
A dictionary of attributes to concatenate
"""
logging.info('Starting assemble attributes')

items = []

geodf.assign(**attributes)
geodf = geodf.astype(str)
geodf = geodf.assign(**attributes)
items = geodf.to_dict('records')

return items
Expand All @@ -215,7 +220,7 @@ def parse_from_filename(filename):
filename_attrs : dict
A dictionary of attributes from the filename
"""

logging.info('Starting parse attributes from filename')
filename_components = filename.split("_")

collection = ""
Expand Down

0 comments on commit 7743188

Please sign in to comment.