Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/*.geojson
/*.png
*.pyc
4 changes: 4 additions & 0 deletions combine_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
parser.add_argument("-n", "--new_feature_name", dest="new_feature_name",
help="The new name of the combined feature",
metavar="NAME", required=True)
parser.add_argument("-g", "--groupName", dest="groupName",
help="Feature group name.",
metavar="GROUPNAME", default="unspecifiedGroupName")
parser.add_argument("-o", "--output", dest="output_file_name",
help="Output file, e.g., features.geojson.",
metavar="PATH", default="features.geojson")
Expand Down Expand Up @@ -97,6 +100,7 @@
feature['properties']['constituents'] = '; '.join(list(set(featureNames)))
feature['geometry'] = shapely.geometry.mapping(combinedShape)
features['features'].append(feature)
features['groupName'] = args.groupName

if feature['geometry']['type'] == 'GeometryCollection':
print "Error: combined geometry from %s is of type GeometryCollection."%(args.feature_file)
Expand Down
5 changes: 5 additions & 0 deletions difference_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
help="Feature file with one or more features whose overlap "
"with features in feature_file should be removed",
metavar="FILE2", required=True)
parser.add_argument("-g", "--groupName", dest="groupName",
help="Feature group name.",
metavar="GROUPNAME", default="unspecifiedGroupName")
parser.add_argument("-o", "--output", dest="output_file_name",
help="Output file, e.g., features.geojson.",
metavar="PATH", default="features.geojson")
Expand Down Expand Up @@ -108,6 +111,8 @@
else:
print "%s has been removed."%name

features['groupName'] = args.groupName

write_all_features(features, out_file_name, indent=4)

# vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python
6 changes: 4 additions & 2 deletions driver_scripts/setup_MOC_basins.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def spcall(args): #{{{

options, args = parser.parse_args()

groupNameMOC = 'MOCBasinRegionsGroup'
groupNameBasins = 'OceanBasinRegionsMOCGroup'

subBasins = {'Atlantic': ['Atlantic', 'Mediterranean'],
'IndoPacific': ['Pacific', 'Indian'],
Expand Down Expand Up @@ -52,11 +54,11 @@ def spcall(args): #{{{
#merge the the features into a single file
print " * combining features into single feature named %s_MOC"%basinName
spcall(['./combine_features.py', '-f', basinFileName, '-n', '%s_MOC'%basinName,
'-o', basinCombinedFileName])
'-g', groupNameBasins, '-o', basinCombinedFileName])

print " * masking out features south of MOC region"
spcall(['./difference_features.py', '-f', basinCombinedFileName,
'-m', MOCMaskFileNames[basinName], '-o', MOCName])
'-m', MOCMaskFileNames[basinName], '-g', groupNameMOC, '-o', MOCName])

if options.plot:
spcall(['./plot_features.py', '-f', MOCName, '-o', imageName, '-m', 'cyl'])
Expand Down
4 changes: 3 additions & 1 deletion driver_scripts/setup_ocean_basins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def spcall(args): #{{{

options, args = parser.parse_args()

groupName = 'OceanBasinRegionsGroup'

for oceanName in 'Atlantic', 'Pacific', 'Indian', 'Arctic', 'Southern_Ocean', 'Mediterranean':

tag = '%s_Basin'%oceanName
Expand All @@ -37,7 +39,7 @@ def spcall(args): #{{{
#merge the the features into a single file
print " * combining features into single feature named %s_Basin"%oceanName
spcall(['./combine_features.py', '-f', basinFileNameName, '-n', '%s_Basin'%oceanName,
'-o', basinCombinedFileName])
'-g', groupName, '-o', basinCombinedFileName])

if(options.plot):
args = ['./plot_features.py', '-f', basinCombinedFileName, '-o', imageName, '-m', 'cyl']
Expand Down
3 changes: 3 additions & 0 deletions merge_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-f", "--feature_file", dest="feature_file", help="Single feature file to append to features.geojson", metavar="FILE")
parser.add_argument("-d", "--features_directory", dest="features_dir", help="Directory containing multiple feature files, each will be appended to features.geojson", metavar="PATH")
parser.add_argument("-g", "--group", dest="groupName", help="Feature group name.", metavar="GROUPNAME", default="unspecifiedGroupName")
parser.add_argument("-t", "--tags", dest="tags", help="Semicolon separated list of tags to match features against.", metavar='"TAG1;TAG2;TAG3"')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see previous comment about changing default.

parser.add_argument("-o", "--output", dest="output_file_name", help="Output file, e.g., features.geojson.", metavar="PATH", default="features.geojson")

Expand Down Expand Up @@ -101,6 +102,8 @@
print "Error parsing geojson file: %s"%(path)
del paths

all_features['groupName'] = args.groupName

write_all_features(all_features, file_to_append, indent=4)

# vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python