From efec913a10011fd5b5ba76781b7f2a7f0711dd38 Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Mon, 12 Nov 2018 15:41:19 +1100 Subject: [PATCH] Provide ids when reading shapefiles May come in handy later --- src/data/profile_features.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/data/profile_features.py b/src/data/profile_features.py index 0860b68..5ed2018 100644 --- a/src/data/profile_features.py +++ b/src/data/profile_features.py @@ -18,9 +18,11 @@ def shapes_from_shp(shp_file): :return: """ shapes = [] - for feat in fiona.open(shp_file): + ids = [] + for feat in fiona.open(shp_file,'r'): shapes.append(shape(feat['geometry'])) - return shapes + ids.append(feat['id']) + return shapes, ids def convert_coord_systems(g1, in_coord_system='EPSG:4326', out_coord_system='EPSG:28356'): @@ -126,12 +128,18 @@ def distance_to_intersection(lat, lon, orientation, line_strings): # todo def get_sites_dune_crest_toe(): + """ + Reads dune crest and toe files and creates a pandas dataframe with crest/toe locations at each site_ + :return: + """ + + # Get site information data_folder = './data/interim' df_sites = pd.read_csv(os.path.join(data_folder, 'sites.csv'), index_col=[0]) - # Import + # Import our dune crest and toes for f in ['./data/raw/profile_features/dune_crests.shp']: - shapes = shapes_from_shp(f) + shapes, _ = shapes_from_shp(f) shapes = [convert_coord_systems(x) for x in shapes] # Iterate through each site