+[docs]
+defcombine_features():
+"""
+ Entry point for combining features from a file
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="feature file with features to be combined",
+ metavar="FILE",
+ required=True)
+ 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("-o","--output",dest="output_file_name",
+ help="Output file, e.g., features.geojson.",
+ metavar="PATH",default="features.geojson")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ fc=fc.combine(args.new_feature_name)
+ fc.to_geojson(args.output_file_name)
+
+
+
+
+[docs]
+defdifference_features():
+"""
+ Entry point for differencing features from a file
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="Feature file to be clipped",metavar="FILE1",
+ required=True)
+ parser.add_argument("-m","--mask_file",dest="mask_file",
+ 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("-o","--output",dest="output_file_name",
+ help="Output file, e.g., features.geojson.",
+ metavar="PATH",default="features.geojson")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ maskingFC=read_feature_collection(args.mask_file)
+ fc=fc.difference(maskingFC)
+ fc.to_geojson(args.output_file_name)
+
+
+
+
+[docs]
+deffix_features_at_antimeridian():
+"""
+ Entry point for splitting features that cross +/- 180 degrees
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="Feature file to be clipped",metavar="FILE1",
+ required=True)
+ parser.add_argument("-o","--output",dest="output_file_name",
+ help="Output file, e.g., features.geojson.",
+ metavar="PATH",default="features.geojson")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ fc=fc.fix_antimeridian()
+ fc.to_geojson(args.output_file_name)
+
+
+
+
+[docs]
+defmerge_features():
+"""
+ Entry point for merging features from the geometric_data cache
+ """
+ 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 "
+ "output_file_name",
+ metavar="FILE")
+ parser.add_argument("-c","--component",dest="component",
+ help="The component (ocean, landice, etc.) from which "
+ "to retrieve the geometric features",
+ metavar="COMP")
+ parser.add_argument("-b","--object_type",dest="object_type",
+ help="The type of geometry to load, a point (0D), "
+ "transect (1D) or region (2D)",
+ metavar="TYPE")
+ parser.add_argument("-n","--feature_names",dest="feature_names",
+ help="Semicolon separated list of features",
+ metavar='"FE1;FE2;FE3"')
+ parser.add_argument("-t","--tags",dest="tags",
+ help="Semicolon separated list of tags to match "
+ "features against.",metavar='"TAG1;TAG2;TAG3"')
+ parser.add_argument("-o","--output",dest="output_file_name",
+ help="Output file, e.g., features.geojson.",
+ metavar="PATH",default="features.geojson")
+ parser.add_argument("--cache",dest="cache_location",
+ help="Location of local geometric_data cache.",
+ metavar="PATH")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+
+ args=parser.parse_args()
+
+ fc=FeatureCollection()
+ ifos.path.exists(args.output_file_name):
+ fc=read_feature_collection(args.output_file_name)
+ ifargs.feature_file:
+ fc.merge(read_feature_collection(args.feature_file))
+
+ ifargs.componentandargs.object_type:
+ gf=GeometricFeatures(args.cache_location)
+ ifargs.feature_names:
+ featureNames=args.feature_names.split(';')
+ else:
+ featureNames=None
+ ifargs.tags:
+ tags=args.tags.split(';')
+ else:
+ tags=None
+ fc.merge(gf.read(args.component,args.object_type,featureNames,tags))
+
+ fc.to_geojson(args.output_file_name)
+
+
+
+
+[docs]
+defplot_features():
+"""
+ Entry point for plotting features from a file
+ """
+
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="Feature file to be clipped",metavar="FILE1",
+ required=True)
+ parser.add_argument("-m","--map_type",dest="map_type",
+ help="The map type on which to project",
+ metavar="FILE")
+ parser.add_argument("--max_length",dest="max_length",type=float,
+ default=4.0,
+ help="Maximum allowed segment length after subdivision"
+ " (0.0 indicates skip subdivision)")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ ifnotargs.map_type:
+ mapTypes=['cyl','merc','mill','mill2',
+ 'moll','moll2','robin','robin2','ortho','northpole',
+ 'southpole','atlantic','pacific','americas','asia']
+ else:
+ mapTypes=args.map_type.split(',')
+
+ formapTypeinmapTypes:
+ print('plot type: {}'.format(mapType))
+ ifmapTypein['cyl','merc','mill','mill2','moll','moll2',
+ 'robin','robin2']:
+ figsize=(12,6)
+ else:
+ figsize=(12,9)
+ fig=fc.plot(mapType,args.max_length,figsize)
+
+ plotFileName='{}_{}.png'.format(
+ os.path.splitext(args.feature_file)[0],mapType)
+
+ fig.savefig(plotFileName)
+
+
+
+
+[docs]
+defset_group_name():
+"""
+ Set the group name of the feature collection
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ required=True,
+ help="Input and output feature file where group name "
+ "is to be set",metavar="FILE")
+ parser.add_argument("-g","--group",dest="groupName",
+ help="Feature group name",metavar="GROUPNAME",
+ required=True)
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ fc.set_group_name(args.groupName)
+ fc.to_geojson(args.feature_file)
+
+
+
+
+[docs]
+defsimplify_features():
+"""
+ Features in the collection are simplified using ``shapely``
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="Feature file to be simplified",metavar="FILE",
+ required=True)
+ parser.add_argument("-t","--tolerance",dest="tolerance",type=float,
+ default=0.0,
+ help="A distance in deg lon/lat by which each point "
+ "in a feature can be moved during simplification",
+ metavar="TOLERANCE")
+ parser.add_argument("-o","--output",dest="output_file_name",
+ help="Output file, e.g., features.geojson.",
+ metavar="PATH",default="features.geojson")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ fc=fc.simplify(args.tolerance)
+ fc.to_geojson(args.output_file_name)
+
+
+
+
+[docs]
+defsplit_features():
+"""
+ Features in the collection are split into individual files in the
+ geometric_data cache
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="File containing features to split up",
+ metavar="FILE",required=True)
+ parser.add_argument("-o","--output_dir",dest="output_dir_name",
+ help="Output directory, default is determined by the "
+ "component property",
+ metavar="PATH",default="./geometric_data")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ gf=GeometricFeatures()
+ gf.split(fc,args.output_dir_name)
+
+
+
+
+[docs]
+deftag_features():
+"""
+ Features in the collection are tagged with the given tag(s)
+ """
+ parser=argparse.ArgumentParser(
+ description=__doc__,formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument("-f","--feature_file",dest="feature_file",
+ help="Features collection file to be tagged",
+ metavar="FILE",required=True)
+ parser.add_argument("-t","--tag",dest="tag",
+ help="Tag to add to all features",
+ metavar="TAG",required=True)
+ parser.add_argument("-r","--remove",dest="remove",action='store_true',
+ help="Use this flag to signal removing a tag instead "
+ "of adding")
+ parser.add_argument("-o","--output",dest="output_file_name",
+ help="Output file, e.g., features.geojson.",
+ metavar="PATH",default="features.geojson")
+ parser.add_argument('-v','--version',
+ action='version',
+ version='geometric_features {}'.format(
+ geometric_features.__version__),
+ help="Show version number and exit")
+ args=parser.parse_args()
+
+ fc=read_feature_collection(args.feature_file)
+ fc.tag(args.tag.split(';'),args.remove)
+ fc.to_geojson(args.output_file_name)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/geometric_features/aggregation.html b/main/_modules/geometric_features/aggregation.html
new file mode 100644
index 00000000..0944f513
--- /dev/null
+++ b/main/_modules/geometric_features/aggregation.html
@@ -0,0 +1,196 @@
+
+
+
+
+
+
+
+ geometric_features.aggregation — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[docs]
+defget_aggregator_by_name(region_group):
+"""
+ Get a geojson mask file and the appropriate file suffix for the given
+ region group.
+
+ Parameters
+ ----------
+ region_group : str
+ The name of a region group to get mask features for, one of
+ 'Antarctic Regions', 'Arctic Ocean Regions', 'Arctic Sea Ice Regions',
+ 'Ocean Basins', 'Ice Shelves', 'Ocean Subbasins', 'ISMIP6 Regions',
+ 'MOC Basins', 'Transport Transects', or 'Arctic Transport Transects'
+
+ Returns
+ -------
+ function : callable
+ An aggregation functions for collecting the features, which takes a
+ :py:class:`geometric_features.GeometricFeatures` object as its argument
+
+ prefix : str
+ A prefix (or suffix) for use in file names that corresponds to the
+ region group
+
+ date : str
+ A date stamp when the regions in ``fc`` were last modified. This date
+ can be used to cache masks based on these regions as long as the date
+ remains the same.
+ """
+
+ regions={'Antarctic Regions':{'prefix':'antarcticRegions',
+ 'date':'20230403',
+ 'function':antarctic},
+ 'Arctic Ocean Regions':{'prefix':'arcticOceanRegions',
+ 'date':'20201130',
+ 'function':arctic_ocean},
+ 'Arctic Sea Ice Regions':{'prefix':'arcticSeaIceRegions',
+ 'date':'20201130',
+ 'function':arctic_seaice},
+ 'Ocean Basins':{'prefix':'oceanBasins',
+ 'date':'20200621',
+ 'function':basins},
+ 'Ice Shelves':{'prefix':'iceShelves',
+ 'date':'20200621',
+ 'function':ice_shelves},
+ 'Ocean Subbasins':{'prefix':'oceanSubbasins',
+ 'date':'20201123',
+ 'function':subbasins},
+ 'Greenland Regions':{'prefix':'greenlandRegions',
+ 'date':'20240510',
+ 'function':greenland},
+ 'ISMIP6 Regions':{'prefix':'ismip6Regions',
+ 'date':'20210201',
+ 'function':ismip6},
+ 'MOC Basins':{'prefix':'mocBasins',
+ 'date':'20210623',
+ 'function':moc},
+ 'Transport Transects':{'prefix':'transportTransects',
+ 'date':'20210323',
+ 'function':transport},
+ 'Arctic Transport Transects':{'prefix':'arcticTransportTransects',
+ 'date':'20220926',
+ 'function':arctic_transport}}
+
+ ifregion_groupnotinregions:
+ raiseValueError(f'Unknown region group {region_group}')
+
+ region=regions[region_group]
+
+ prefix=region['prefix']
+ date=region['date']
+
+ function=region['function']
+
+ returnfunction,prefix,date
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/geometric_features/aggregation/ocean/antarctic_regions.html b/main/_modules/geometric_features/aggregation/ocean/antarctic_regions.html
new file mode 100644
index 00000000..c5161af0
--- /dev/null
+++ b/main/_modules/geometric_features/aggregation/ocean/antarctic_regions.html
@@ -0,0 +1,149 @@
+
+
+
+
+
+
+
+ geometric_features.aggregation.ocean.antarctic_regions — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Source code for geometric_features.aggregation.ocean.greenland_regions
+
+[docs]
+defgreenland(gf):
+"""
+ Aggregate Greenland continental shelf regions similar to ISMIP6
+
+ Parameters
+ ----------
+ gf : geometric_features.GeometricFeatures
+ An object that knows how to download and read geometric features
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ The new feature collection with antarctic regions
+ """
+ # Authors
+ # -------
+ # Carolyn Begeman
+
+ regions=['ISMIP6 Greenland Central East Shelf',
+ 'ISMIP6 Greenland Central West Shelf',
+ 'ISMIP6 Greenland North East Shelf',
+ 'ISMIP6 Greenland North Shelf',
+ 'ISMIP6 Greenland North West Shelf',
+ 'ISMIP6 Greenland South East Shelf',
+ 'ISMIP6 Greenland South West Shelf']
+
+ fc=gf.read(componentName='ocean',objectType='region',
+ featureNames=regions)
+
+ returnfc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/geometric_features/aggregation/ocean/ice_shelf_regions.html b/main/_modules/geometric_features/aggregation/ocean/ice_shelf_regions.html
new file mode 100644
index 00000000..77f38491
--- /dev/null
+++ b/main/_modules/geometric_features/aggregation/ocean/ice_shelf_regions.html
@@ -0,0 +1,288 @@
+
+
+
+
+
+
+
+ geometric_features.aggregation.ocean.ice_shelf_regions — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[docs]
+defmoc(gf):
+"""
+ Aggregate features defining the ocean basins used in computing the
+ meridional overturning circulation (MOC)
+
+ Parameters
+ ----------
+ gf : ``GeometricFeatures``
+ An object that knows how to download and read geometric features
+
+ Returns
+ -------
+ fc : ``FeatureCollection``
+ The new feature collection
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ MOCSubBasins={'Atlantic':['Atlantic'],
+ 'AtlanticMed':['Atlantic','Mediterranean'],
+ 'IndoPacific':['Pacific','Indian'],
+ 'Pacific':['Pacific'],
+ 'Indian':['Indian']}
+
+ MOCSouthernBoundary={'Atlantic':'34S',
+ 'AtlanticMed':'34S',
+ 'IndoPacific':'34S',
+ 'Pacific':'6S',
+ 'Indian':'6S'}
+
+ fc=FeatureCollection()
+ fc.set_group_name(groupName='MOCBasinRegionsGroup')
+
+ # build MOC basins from regions with the appropriate tags
+ forbasinNameinMOCSubBasins:
+ tags=['{}_Basin'.format(basin)forbasinin
+ MOCSubBasins[basinName]]
+
+ fcBasin=gf.read(componentName='ocean',objectType='region',
+ tags=tags,allTags=False)
+
+ fcBasin=fcBasin.combine(featureName='{}_MOC'.format(basinName))
+
+ maskName='MOC mask {}'.format(MOCSouthernBoundary[basinName])
+ fcMask=gf.read(componentName='ocean',objectType='region',
+ featureNames=[maskName])
+ # mask out the region covered by the mask
+ fcBasin=fcBasin.difference(fcMask)
+
+ # remove various small polygons that are not part of the main MOC
+ # basin shapes. Most are tiny but one below Australia is about 20
+ # deg^2, so make the threshold 100 deg^2 to be on the safe side.
+ fcBasin=_remove_small_polygons(fcBasin,minArea=100.)
+
+ # add this basin to the full feature collection
+ fc.merge(fcBasin)
+
+ returnfc
+
+
+
+def_remove_small_polygons(fc,minArea):
+"""
+ A helper function to remove small polygons from a feature collection
+
+ Parameters
+ ----------
+ fc : ``FeatureCollection``
+ The feature collection to remove polygons from
+
+ minArea : float
+ The minimum area (in square degrees) below which polygons should be
+ removed
+
+ Returns
+ -------
+ fcOut : ``FeatureCollection``
+ The new feature collection with small polygons removed
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ fcOut=FeatureCollection()
+
+ removedCount=0
+ forfeatureinfc.features:
+ geom=feature['geometry']
+ add=False
+ ifgeom['type']notin['Polygon','MultiPolygon']:
+ # no area to check, so just add it
+ fcOut.add_feature(copy.deepcopy(feature))
+ else:
+ featureShape=shapely.geometry.shape(geom)
+ iffeatureShape.geom_type=='Polygon':
+ iffeatureShape.area>minArea:
+ add=True
+ else:
+ removedCount+=1
+ else:
+ # a MultiPolygon
+ outPolygons=[]
+ forpolygoninfeatureShape.geoms:
+ ifpolygon.area>minArea:
+ outPolygons.append(polygon)
+ else:
+ removedCount+=1
+ iflen(outPolygons)>0:
+ outShape=shapely.ops.unary_union(outPolygons)
+ feature['geometry']=shapely.geometry.mapping(outShape)
+ add=True
+ ifadd:
+ fcOut.add_feature(copy.deepcopy(feature))
+
+ returnfcOut
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/geometric_features/aggregation/ocean/ocean_basins.html b/main/_modules/geometric_features/aggregation/ocean/ocean_basins.html
new file mode 100644
index 00000000..5fb2b6c5
--- /dev/null
+++ b/main/_modules/geometric_features/aggregation/ocean/ocean_basins.html
@@ -0,0 +1,166 @@
+
+
+
+
+
+
+
+ geometric_features.aggregation.ocean.ocean_basins — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[docs]
+defread_feature_collection(fileName):
+"""
+ Read a feature collection from a geojson file.
+
+ Parameters
+ ----------
+ fileName : str
+ The path to the geojson file
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ The feature collection read in
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+ fc=FeatureCollection()
+ withopen(fileName)asf:
+ featuresDict=json.load(f)
+ forfeatureinfeaturesDict['features']:
+ fc.add_feature(feature)
+ forkeyinsorted(list(featuresDict.keys())):
+ ifkeynotin['features','type']:
+ fc.otherProperties[key]=featuresDict[key]
+ returnfc
+
+
+
+
+[docs]
+classFeatureCollection(object):
+"""
+ An object for representing and manipulating a collection of geoscientific
+ geometric features.
+
+ Attributes
+ ----------
+ features : list of dict
+ A list of python dictionaries describing each feature, following the
+ geojson convention
+
+ otherProperties : dict
+ Other properties of the feature collection such as ``type`` and
+ ``groupName``
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+
+[docs]
+ def__init__(self,features=None,otherProperties=None):
+"""
+ Construct a new feature collection
+
+ Parameters
+ ----------
+ features : list of dict, optional
+ A list of python dictionaries describing each feature, following
+ the geojson convention
+
+ otherProperties : dict, optional
+ Other properties of the feature collection such as ``type`` and
+ ``groupName``
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+ iffeaturesisNone:
+ self.features=[]
+ else:
+ self.features=features
+ self.otherProperties=dict()
+ self.otherProperties['type']='FeatureCollection'
+ self.otherProperties['groupName']='enterGroupName'
+ ifotherPropertiesisnotNone:
+ self.otherProperties.update(otherProperties)
+
+
+
+[docs]
+ defadd_feature(self,feature):
+"""
+ Add a feature to the feature collection if it isn't already present
+
+ Parameters
+ ----------
+ feature : dict
+ The feature to add
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ feature=_validate_feature(feature)
+ ifnotself.feature_in_collection(feature):
+ self.features.append(feature)
+
+
+
+[docs]
+ defmerge(self,other):
+"""
+ Merge another feature collection into this one
+
+ Parameters
+ ----------
+ other : geometric_features.FeatureCollection
+ The other feature collection
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ forfeatureinother.features:
+ self.add_feature(feature)
+
+ forkeyinsorted(list(other.otherProperties.keys())):
+ ifkeynotin['features','type']andkeynotin \
+ self.otherProperties:
+ self.otherProperties[key]=other.otherProperties[key]
+
+
+
+[docs]
+ deftag(self,tags,remove=False):
+"""
+ Add tags to all features in the collection
+
+ Parameters
+ ----------
+ tags : list of str
+ Tags to be added
+
+ remove : bool, optional
+ Whether to remove the tag rather than adding it
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ forfeatureinself.features:
+ featureTags=feature['properties']['tags'].split(';')
+ fortagintags:
+ ifremoveandtaginfeatureTags:
+ featureTags.remove(tag)
+ elifnotremoveandtagnotinfeatureTags:
+ featureTags.append(tag)
+ feature['properties']['tags']=';'.join(featureTags)
+
+
+
+[docs]
+ defset_group_name(self,groupName):
+"""
+ Set the group name of a feature collection
+
+ Parameters
+ ----------
+ groupName : str
+ The group name
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ self.otherProperties['groupName']=groupName
+
+
+
+[docs]
+ defcombine(self,featureName):
+"""
+ Combines the geometry of the feature collection into a single feature
+
+ Parameters
+ ----------
+ featureName : str
+ The name of the new, combined feature
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ A new feature collection with a single feature with the combined
+ geometry
+
+ Raises
+ ------
+ ValueError
+ If the combined geometry is of an unsupported type (typically
+ ``GeometryCollection``)
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ featureShapes=[]
+ authors=[]
+ featureNames=[]
+ forfeatureinself.features:
+ featureShapes.append(shapely.geometry.shape(feature['geometry']))
+ authors.append(feature['properties']['author'])
+ featureNames.append(feature['properties']['name'])
+
+ combinedShape=shapely.ops.unary_union(featureShapes)
+
+ geometry=shapely.geometry.mapping(combinedShape)
+
+ try:
+ objectType=_get_geom_object_type(geometry['type'])
+ exceptKeyError:
+ raiseValueError('combined geometry is of unsupported type '
+ '{}. Most likely cause is that '
+ 'multiple feature types (regions, points and '
+ 'transects) are being combined.'.format(
+ geometry['type']))
+
+ feature={}
+ feature['type']='Feature'
+ feature['properties']={}
+ feature['properties']['name']=featureName
+ feature['properties']['component']= \
+ self.features[0]['properties']['component']
+ feature['properties']['object']=objectType
+ feature['properties']['tags']=''
+ feature['properties']['author']='; '.join(list(set(authors)))
+ feature['properties']['constituents']= \
+ '; '.join(list(set(featureNames)))
+ feature['geometry']=geometry
+
+ fc=FeatureCollection([feature])
+ returnfc
+
+
+
+[docs]
+ defdifference(self,maskingFC,show_progress=False):
+"""
+ Use features from a masking collection to mask out (remove part of
+ the geometry from) this collection.
+
+ Parameters
+ ----------
+ maskingFC : geometric_features.FeatureCollection
+ Another collection of one or more features to use as masks
+
+ show_progress : bool
+ Show a progress bar
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ A new feature collection with a single feature with the geometry
+ masked
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ featureCount=len(self.features)
+ maskCount=len(maskingFC.features)
+
+ totalCount=featureCount*maskCount
+
+ ifshow_progress:
+ print('Masking features...')
+ widgets=['',progressbar.Percentage(),' ',progressbar.Bar(),
+ ' ',progressbar.ETA()]
+ bar=progressbar.ProgressBar(widgets=widgets,
+ maxval=totalCount).start()
+ else:
+ widgets=None
+ bar=None
+
+ maskedFeatures=[]
+ maskedCount=0
+ droppedCount=0
+ forfeatureIndex,featureinenumerate(self.features):
+ name=feature['properties']['name']
+ ifshow_progress:
+ widgets[0]='{}: '.format(name)
+ featureShape=shapely.geometry.shape(feature['geometry'])
+ add=True
+ masked=False
+ formaskIndex,maskFeatureinenumerate(maskingFC.features):
+ ifshow_progress:
+ bar.update(maskIndex+featureIndex*maskCount)
+ maskShape=shapely.geometry.shape(maskFeature['geometry'])
+ iffeatureShape.intersects(maskShape):
+ masked=True
+ featureShape=featureShape.difference(maskShape)
+ iffeatureShape.is_empty:
+ add=False
+ break
+
+ ifadd:
+ newFeature=copy.deepcopy(feature)
+ ifmasked:
+ maskedCount+=1
+ newFeature['geometry']= \
+ shapely.geometry.mapping(featureShape)
+ maskedFeatures.append(newFeature)
+ else:
+ droppedCount+=1
+
+ ifshow_progress:
+ bar.finish()
+
+ print(' {} features unchanged, {} masked and {} dropped.'.format(
+ featureCount-maskedCount-droppedCount,maskedCount,
+ droppedCount))
+
+ fc=FeatureCollection(maskedFeatures,self.otherProperties)
+ returnfc
+
+
+
+[docs]
+ deffix_antimeridian(self):
+"""
+ Split features at +/-180 degrees (the antimeridian) to make them valid
+ geojson geometries
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ A new feature collection with the antimeridian handled correctly
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ fc=FeatureCollection(features=None,
+ otherProperties=self.otherProperties)
+ forfeatureinself.features:
+ geometry=_split_geometry_crossing_antimeridian(
+ feature['geometry'])
+ ifgeometryisNone:
+ # no change
+ newFeature=dict(feature)
+ else:
+ newFeature=dict()
+ newFeature['properties']=dict(feature['properties'])
+ newFeature['geometry']=geometry
+ fc.add_feature(newFeature)
+
+ returnfc
+
+
+
+[docs]
+ defsimplify(self,tolerance=0.0):
+"""
+ Features in the collection are simplified using ``shapely``
+
+ Parameters
+ ----------
+ tolerance : float, optional
+ The tolerance in degrees lon/lat allowed when simplifying shapes
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ A new feature collection with simplified geometries
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ newFeatures=[]
+ forfeatureinself.features:
+ featureShape=shapely.geometry.shape(feature['geometry'])
+ simplifiedFeature=featureShape.simplify(tolerance)
+ newFeature=copy.deepcopy(feature)
+ newFeature['geometry']= \
+ shapely.geometry.mapping(simplifiedFeature)
+ newFeatures.append(newFeature)
+
+ fc=FeatureCollection(newFeatures,self.otherProperties)
+ returnfc
+
+
+
+[docs]
+ deffeature_in_collection(self,feature):
+"""
+ Is this feature already in the collection?
+
+ Parameters
+ ----------
+ feature : dict
+ The feature to check
+
+ Returns
+ -------
+ inCollection : bool
+ Whether the feature is in the collection
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ featureNames=[f['properties']['name']forfinself.features]
+ returnfeature['properties']['name']infeatureNames
+
+
+
+[docs]
+ defto_geojson(self,fileName,stripHistory=False,indent=4):
+"""
+ Write the feature collection to a geojson file
+
+ Parameters
+ ----------
+ fileName : str
+ A geojson file to write to
+
+ stripHistory : bool, optional
+ Whether to remove the history attribute (e.g. when splitting
+ features for inclusion in the ``geometric_features`` repo)
+
+ indent : int, optional
+ The number of spaces to use for indentation when formatting the
+ geojson file
+ """
+ # Authors
+ # -------
+ # Douglas Jacobsen, Xylar Asay-Davis, Phillip J. Wolfram
+
+ outFeatures=dict(self.otherProperties)
+ # features go last for readability
+ outFeatures['features']=copy.deepcopy(self.features)
+
+ ifstripHistory:
+ # remove provenance from the output
+ forfeatureinoutFeatures['features']:
+ # pop (with default so no exception is raised if no history)
+ feature['properties'].pop('history',None)
+ else:
+ # provenance the output
+ command=provenance_command()
+ forfeatureinoutFeatures['features']:
+ if'history'infeature['properties']:
+ history=feature['properties']['history']+' '+command
+ feature['properties']['history']=history
+ else:
+ feature['properties']['history']=command
+
+ outFile=open(fileName,'w')
+
+ forfeatureinoutFeatures['features']:
+ feature['geometry']['coordinates']= \
+ _round_coords(feature['geometry']['coordinates'])
+
+ json.dump(outFeatures,outFile,indent=indent)
+
+
+
+[docs]
+ defplot(self,projection,maxLength=4.0,figsize=None,colors=None,
+ dpi=200):
+"""
+ Plot the features on a map using cartopy.
+
+ Parameters
+ ----------
+ projection : str or ``cartopy.crs.Projection``
+ A cartopy projection object or one of the internally defined
+ map names:
+
+ 'cyl', 'merc', 'mill', 'mill2', 'moll', 'moll2', 'robin',
+ 'robin2', 'ortho', 'northpole', 'southpole', 'atlantic',
+ 'pacific', 'americas', 'asia'
+
+ maxLength : float, optional
+ Maximum allowed segment length after subdivision for smoother
+ plotting (0.0 indicates skip subdivision)
+
+ figsize : tuple of float
+ Size of the figure in inches
+
+ colors : list of str
+ Colors to cycle through for the shapes
+
+ dpi : int
+ Dots per inch for the figure
+
+ Returns
+ -------
+ fig : ``matplotlib.figure.Figure``
+ The figure
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis, `Phillip J. Wolfram
+
+ projectionName='custom'
+
+ ifisinstance(projection,str):
+ projections=build_projections()
+ projectionName=projection
+ projection=projections[projectionName]
+
+ iffigsizeisNone:
+ ifprojectionNamein['cyl','merc','mill','mill2','moll',
+ 'moll2','robin','robin2']:
+ figsize=(12,6)
+ else:
+ figsize=(12,9)
+
+ fig=plt.figure(figsize=figsize,dpi=dpi)
+ (ax,projection)=plot_base(projectionName,projection)
+
+ ifcolorsisNone:
+ # use colorbrewer qualitative 7 data class colors,
+ # "7-class Accent": http://colorbrewer2.org/
+ colors=['#7fc97f','#beaed4','#fdc086','#ffff99','#386cb0',
+ '#f0027f','#bf5b17']
+
+ bounds=None
+
+ forfeatureIndex,featureinenumerate(self.features):
+ geomType=feature['geometry']['type']
+ shape=shapely.geometry.shape(feature['geometry'])
+ ifmaxLength>0.0:
+ shape=subdivide_geom(shape,geomType,maxLength)
+
+ refProjection=cartopy.crs.PlateCarree()
+
+ color=colors[featureIndex%len(colors)]
+
+ ifgeomTypein['Polygon','MultiPolygon']:
+ props={'linewidth':2.0,'edgecolor':color,'alpha':0.4,
+ 'facecolor':color}
+ elifgeomTypein['LineString','MultiLineString']:
+ props={'linewidth':4.0,'edgecolor':color,'alpha':1.,
+ 'facecolor':'none'}
+
+ ifboundsisNone:
+ bounds=list(shape.bounds)
+ else:
+ # expand the bounding box
+ bounds[:2]=np.minimum(bounds[:2],shape.bounds[:2])
+ bounds[2:]=np.maximum(bounds[2:],shape.bounds[2:])
+
+ ifgeomType=='Point':
+ ax.scatter(shape.coords[0][0],shape.coords[0][1],s=9,
+ transform=cartopy.crs.PlateCarree(),marker='o',
+ color='blue',edgecolor='blue')
+ else:
+ ax.add_geometries((shape,),crs=refProjection,**props)
+
+ box=shapely.geometry.box(*bounds)
+ ifmaxLength>0.0:
+ box=subdivide_geom(box,'Polygon',maxLength)
+
+ boxProjected=projection.project_geometry(box,src_crs=refProjection)
+ try:
+ x1,y1,x2,y2=boxProjected.bounds
+ ax.set_xlim([x1,x2])
+ ax.set_ylim([y1,y2])
+ exceptValueError:
+ print("Warning: bounding box could not be projected into "
+ "projection {}".format(projectionName))
+ print("Defaulting to global bounds.")
+ ax.set_global()
+
+ fig.canvas.draw()
+ plt.tight_layout(pad=4.)
+
+ returnfig
+
+
+
+
+def_get_geom_object_type(geomType):
+"""
+ Get the object type for a given geometry type
+ """
+ geomObjectTypes={'Polygon':'region',
+ 'MultiPolygon':'region',
+ 'LineString':'transect',
+ 'MultiLineString':'transect',
+ 'Point':'point',
+ 'MultiPoint':'point'}
+ returngeomObjectTypes[geomType]
+
+
+def_validate_feature(feature):
+"""
+ Validate the geometric feature to ensure that it has all required keys:
+ - properties
+ - name
+ - tags
+ - object
+ - component
+ - author
+ - geometry
+ - type
+ - coordinates
+
+ Parameters
+ ----------
+ feature : dict
+ The feature to check
+
+ Raises
+ ------
+ KeyError
+ If the feature is missing required keys
+
+ ValueError
+ If the geometry type doesn't match the object type
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis, Phillip J. Wolfram
+
+ required={
+ 'properties':['name','object','component'],
+ 'geometry':['type','coordinates']}
+
+ try:
+ name=feature['properties']['name']
+ exceptKeyError:
+ name='unknown'
+ forouterKeyinrequired:
+ ifouterKeynotinfeature:
+ raiseKeyError('Feature {} missing [{}] key'.format(
+ name,outerKey))
+ forinnerKeyinrequired[outerKey]:
+ ifinnerKeynotinfeature[outerKey]:
+ raiseKeyError('Feature {} missing [{}][{}] key'.format(
+ name,outerKey,innerKey))
+
+ geomType=feature['geometry']['type']
+ objectType=feature['properties']['object']
+ if_get_geom_object_type(geomType)!=objectType:
+ raiseValueError('Object type {} and geometry type {} '
+ 'are incompatible'.format(objectType,geomType))
+
+ if'author'infeature['properties']:
+ author=feature['properties']['author']
+ else:
+ author=''
+
+ if'tags'infeature['properties']:
+ tags=feature['properties']['tags']
+ else:
+ tags=''
+
+ # Make the properties an ordered dictionary so they can be sorted
+ outProperties={'name':feature['properties']['name'],
+ 'tags':tags,
+ 'object':feature['properties']['object'],
+ 'component':feature['properties']['component'],
+ 'author':author}
+ forkeyinsorted(feature['properties']):
+ ifkeynotinoutProperties.keys():
+ outProperties[key]=feature['properties'][key]
+
+ # Make the geometry an ordered dictionary so they can keep it in the
+ # desired order
+ outGeometry={'type':feature['geometry']['type'],
+ 'coordinates':feature['geometry']['coordinates']}
+ forkeyinsorted(feature['geometry']):
+ ifkeynotinoutGeometry.keys():
+ outGeometry[key]=feature['geometry'][key]
+
+ # Make the feature an ordered dictionary so properties come before geometry
+ # (easier to read)
+ outFeature={'type':'Feature',
+ 'properties':outProperties}
+ # Add the rest
+ forkeyinsorted(feature):
+ ifkeynotin['geometry','type','properties']:
+ outFeature[key]=feature[key]
+
+ # geometry goes last for readability
+ outFeature['geometry']=outGeometry
+
+ returnoutFeature
+
+
+def_split_geometry_crossing_antimeridian(geometry):
+ def_to_polar(lon,lat):
+ phi=np.pi/180.*(np.mod(lon+180.,360.)-180.)
+ radius=np.pi/180.*(90.-sign*lat)
+
+ # nudge points at +/- 180 out of the way so they don't intersect the
+ # testing wedge
+ phi=np.sign(phi)* \
+ np.where(np.abs(phi)>np.pi-1.5*epsilon,
+ np.pi-1.5*epsilon,np.abs(phi))
+ # radius = np.where(radius < 1.5*epsilon, 1.5*epsilon, radius)
+
+ x=radius*np.sin(phi)
+ y=radius*np.cos(phi)
+ ifisinstance(lon,list):
+ x=x.tolist()
+ y=y.tolist()
+ elifisinstance(lon,tuple):
+ x=tuple(x)
+ y=tuple(y)
+
+ returnx,y
+
+ def_from_polar(x,y):
+ radius=np.sqrt(np.array(x)**2+np.array(y)**2)
+ phi=np.arctan2(x,y)
+
+ # close up the tiny gap
+ radius=np.where(radius<2*epsilon,0.,radius)
+ phi=np.sign(phi)* \
+ np.where(np.abs(phi)>np.pi-2*epsilon,
+ np.pi,np.abs(phi))
+
+ lon=180./np.pi*phi
+ lat=sign*(90.-180./np.pi*radius)
+
+ ifisinstance(x,list):
+ lon=lon.tolist()
+ lat=lat.tolist()
+ elifisinstance(x,tuple):
+ lon=tuple(lon)
+ lat=tuple(lat)
+ returnlon,lat
+
+ epsilon=1e-14
+ antimeridianWedge=shapely.geometry.Polygon([(epsilon,-np.pi),
+ (epsilon**2,-epsilon),
+ (0,epsilon),
+ (-epsilon**2,-epsilon),
+ (-epsilon,-np.pi),
+ (epsilon,-np.pi)])
+
+ featureShape=shapely.geometry.shape(geometry)
+ sign=(2.*(0.5*(featureShape.bounds[1]+featureShape.bounds[3])>=0.)-
+ 1.)
+ polarShape=shapely.ops.transform(_to_polar,featureShape)
+
+ ifnotpolarShape.intersects(antimeridianWedge):
+ # this feature doesn't cross the antimeridian
+ return
+
+ difference=polarShape.difference(antimeridianWedge)
+
+ outShape=shapely.ops.transform(_from_polar,difference)
+
+ returnshapely.geometry.mapping(outShape)
+
+
+def_round_coords(coordinates,digits=6):
+"""
+ Round the coordinates of geojson geometry data before writing to a file
+ """
+ ifisinstance(coordinates,float):
+ returnround(coordinates,digits)
+ ifisinstance(coordinates,int):
+ returnfloat(coordinates)
+ elifisinstance(coordinates,list):
+ return[_round_coords(c,digits)forcincoordinates]
+ elifisinstance(coordinates,tuple):
+ returntuple([_round_coords(c,digits)forcincoordinates])
+ else:
+ raiseTypeError('Unexpected type for coordinates {}'.format(
+ coordinates))
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/geometric_features/geometric_features.html b/main/_modules/geometric_features/geometric_features.html
new file mode 100644
index 00000000..b68cbff9
--- /dev/null
+++ b/main/_modules/geometric_features/geometric_features.html
@@ -0,0 +1,452 @@
+
+
+
+
+
+
+
+ geometric_features.geometric_features — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[docs]
+classGeometricFeatures(object):
+"""
+ An object for keeping track of where geometric features are cached and
+ downloading missing features as needed.
+
+ Attributes
+ ----------
+ allFeaturesAndTags : dict of dict
+ A cache of all the feature names and tags in the ``geometric_features``
+ repo used to determine which features need to be downloaded into the
+ local cache
+
+ remoteBranch : str, optional
+ The branch or tag from the ``geometric_features`` repo to download
+ from if files are missing from the local cache
+
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+
+[docs]
+ def__init__(self,cacheLocation=None,remoteBranchOrTag=None):
+"""
+ The constructor for the GeometricFeatures object
+
+ Parameters
+ ----------
+ cacheLocation : str, optional
+ The location of the local geometric features cache. If not
+ specified, the environment variable ``$GEOMETRIC_DATA_DIR`` is
+ used if it is set and ``./geometric_data`` is used otherwise.
+
+ remoteBranchOrTag : str, optional
+ The branch or tag from the ``geometric_features`` repo to download
+ from if files are missing from the local cache, with default to
+ a tag the same as this version of ``geometric_features``
+ """
+
+ ifcacheLocationisNone:
+ if'GEOMETRIC_DATA_DIR'inos.environ:
+ self.cacheLocation=os.environ['GEOMETRIC_DATA_DIR']
+ else:
+ self.cacheLocation='./geometric_data'
+ else:
+ self.cacheLocation=cacheLocation
+ ifremoteBranchOrTagisNone:
+ self.remoteBranch=geometric_features.__version__
+ else:
+ self.remoteBranch=remoteBranchOrTag
+
+ features_file=(imp_res_files('geometric_features')/
+ 'features_and_tags.json')
+ withfeatures_file.open('r')asfile:
+ self.allFeaturesAndTags=json.load(file)
+
+
+
+[docs]
+ defread(self,componentName,objectType,featureNames=None,tags=None,
+ allTags=True):
+"""
+ Read one or more features from the cached collection of geometric
+ features. If any of the requested features have not been cached, they
+ are downloaded from the ``geometric_features`` GitHub repository. If
+ neither ``featureNames`` nor ``tags`` are specified, all features of
+ the component and object type are read in.
+
+ Parameters
+ ----------
+ componentName : {'bedmachine', 'bedmap2', 'iceshelves', 'landice', 'natural_earth', 'ocean'}
+ The component from which to retrieve the geometric features
+
+ objectType : {'point', 'transect', 'region'}
+ The type of geometry to load, a point (0D), transect (1D) or region
+ (2D)
+
+ featureNames : list of str, optional
+ The names of geometric features to read
+
+ tags : list of str, optional
+ A list of tags to check for. When ``allTags=True``, a feature is
+ only read in if it has all tags. Otherwise, features with any of
+ the tags are read.
+
+ allTags : bool, optional
+ Whether a feature must have all tags (instead of any of the tags)
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ The feature collection read in
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ featureNames=self._get_feature_names(componentName,objectType,
+ featureNames,tags,allTags)
+ fileList=self._download_geometric_features(componentName,objectType,
+ featureNames)
+
+ fc=FeatureCollection()
+ forfileNameinfileList:
+ fc.merge(read_feature_collection(fileName))
+
+ returnfc
+
+
+
+[docs]
+ defsplit(self,fc,destinationDir=None):
+"""
+ Split a feature collection into individual files for each feature. This
+ is how new geometry should be added to the ``geometric_features`` repo.
+
+ Parameters
+ ----------
+ fc : geometric_features.FeatureCollection
+ The feature collection to split
+
+ destinationDir : str, optional
+ The root path where the split geometry will be stored,
+ ``cacheLocation`` by default
+
+ Returns
+ -------
+ fc : geometric_features.FeatureCollection
+ The feature collection read in
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ ifdestinationDirisNone:
+ destinationDir=self.cacheLocation
+
+ forfeatureinfc.features:
+ featureName=feature['properties']['name']
+ componentName=feature['properties']['component']
+ objectType=feature['properties']['object']
+
+ relativePath=_get_file_name(componentName,objectType,
+ featureName)
+ fullPath=os.path.join(destinationDir,relativePath)
+
+ path,file=os.path.split(fullPath)
+
+ try:
+ os.makedirs(path)
+ exceptOSError:
+ pass
+
+ singleFC=FeatureCollection([feature])
+ singleFC.otherProperties.pop('groupName',None)
+
+ singleFC.to_geojson(fullPath,stripHistory=True)
+
+
+ def_download_geometric_features(self,componentName,objectType,
+ featureNames):
+"""
+ Determine a list of requested files and download the any that are
+ missing from the repo
+
+ Parameters
+ ----------
+ componentName : {'bedmachine', 'bedmap2', 'iceshelves', 'landice', 'natural_earth', 'ocean'}
+ The component from which to retrieve the geometric features
+
+ objectType : {'point', 'transect', 'region'}
+ The type of geometry to load, a point (0D), transect (1D) or region
+ (2D)
+
+ featureNames : list of str
+ The names of geometric features to read
+
+ Returns
+ -------
+ fileList : list of str
+ File names of the features
+
+
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+ try:
+ os.makedirs(self.cacheLocation)
+ exceptOSError:
+ pass
+
+ fileList=[]
+ filesToDownload=[]
+ forfeatureNameinfeatureNames:
+ relativePath=_get_file_name(componentName,objectType,
+ featureName)
+ fullPath=os.path.join(self.cacheLocation,relativePath)
+ fileList.append(fullPath)
+ ifnotos.path.exists(fullPath):
+ filesToDownload.append(relativePath)
+
+ iflen(filesToDownload)>0:
+ baseURL='https://raw.githubusercontent.com/MPAS-Dev/' \
+ 'geometric_features/{}/geometric_data'.format(
+ self.remoteBranch)
+ download_files(filesToDownload,baseURL,self.cacheLocation)
+
+ returnfileList
+
+ def_get_feature_names(self,componentName,objectType,featureNames,
+ tags,allTags):
+"""
+ Find features by name or tags, reporting errors in the process
+
+ Parameters
+ ----------
+ componentName : {'bedmachine', 'bedmap2', 'iceshelves', 'landice', 'natural_earth', 'ocean'}
+ The component from which to retrieve the geometric features
+
+ objectType : {'point', 'transect', 'region'}
+ The type of geometry to load, a point (0D), transect (1D) or region
+ (2D)
+
+ featureNames : list of str
+ The names of geometric features to read
+
+ tags : list of str
+ A list of tags to check for. A feature is only read in if it has
+ all tags.
+
+ allTags : bool, optional
+ Whether a feature must have all tags (instead of any of the tags)
+
+ Returns
+ -------
+ featureNames : list of str
+ The names of features found either explicitly by name or by tags
+
+ Raises
+ ------
+ KeyError
+ If the component is not in the geometric features repo, if the
+ object type is not in the component, or if one or more feature
+ names are not found
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+
+ ifcomponentNamenotinself.allFeaturesAndTags:
+ raiseKeyError('invalid component {}'.format(componentName))
+
+ component=self.allFeaturesAndTags[componentName]
+
+ ifobjectTypenotincomponent:
+ raiseKeyError('invalid object {} in component {}'.format(
+ objectType,componentName))
+
+ availableFeaturesAndTags=component[objectType]
+
+ iffeatureNamesisNoneandtagsisNone:
+ outFeatureNames=list(availableFeaturesAndTags.keys())
+
+ else:
+ outFeatureNames=[]
+ iffeatureNamesisnotNone:
+ forfeatureNameinfeatureNames:
+ iffeatureNamenotinavailableFeaturesAndTags:
+ raiseKeyError('invalid feature {}'.format(
+ featureName))
+ outFeatureNames.append(featureName)
+
+ iftagsisnotNone:
+ ifallTags:
+ op=all
+ else:
+ op=any
+ forfeatureNameinavailableFeaturesAndTags:
+ featureTags=availableFeaturesAndTags[featureName]
+ ifop([taginfeatureTagsfortagintags]):
+ outFeatureNames.append(featureName)
+ returnoutFeatureNames
+
+
+
+def_get_file_name(componentName,objectType,featureName):
+"""
+ Get the relative path of a cached geometric feature from its component,
+ object type and feature name.
+
+ Parameters
+ ----------
+ componentName : {'bedmachine', 'bedmap2', 'iceshelves', 'landice', 'natural_earth', 'ocean'}
+ The component from which to retrieve the geometric features
+
+ objectType : {'point', 'transect', 'region'}
+ The type of geometry to load, a point (0D), transect (1D) or region
+ (2D)
+
+ featureName : str
+ The names of a geometric feature
+
+ Returns
+ -------
+ fileName : str
+ The relative path to that feature
+ """
+ # Authors
+ # -------
+ # Douglas Jacobsen, Xylar Asay-Davis
+
+ badCharacters='<>:"/\\|?*\',;'
+ featureDir=featureName.strip().replace(' ','_').strip('.')
+ forcharinbadCharacters:
+ featureDir=featureDir.replace(char,'')
+ fileName=os.path.join(componentName,objectType,featureDir,
+ '{}.geojson'.format(objectType))
+
+ returnfileName
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/geometric_features/utils.html b/main/_modules/geometric_features/utils.html
new file mode 100644
index 00000000..5488930c
--- /dev/null
+++ b/main/_modules/geometric_features/utils.html
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+
+ geometric_features.utils — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[docs]
+defwrite_feature_names_and_tags(cacheLocation='./geometry_data'):
+"""
+ Make a json file with all the available features and tags by component
+ and object type, used to update the file when new geometric features are
+ added to the repo
+
+ Parameters
+ ----------
+ cacheLocation : str, optional
+ The location of the geometric features cache
+ """
+ # Authors
+ # -------
+ # Xylar Asay-Davis
+ outFileName='features_and_tags.json'
+ fileNames=sorted(glob.glob('{}/*/*/*/*.geojson'.format(cacheLocation)))
+
+ allFeaturesAndTags=OrderedDict()
+ forfileNameinfileNames:
+ print(fileName)
+ withopen(fileName)asf:
+ features=json.load(f)['features']
+ feature=features[0]
+ featureName=feature['properties']['name']
+ componentName=feature['properties']['component']
+ objectType=feature['properties']['object']
+ tags=feature['properties']['tags'].split(';')
+ ifcomponentNamenotinallFeaturesAndTags:
+ allFeaturesAndTags[componentName]=OrderedDict()
+ ifobjectTypenotinallFeaturesAndTags[componentName]:
+ allFeaturesAndTags[componentName][objectType]=OrderedDict()
+ allFeaturesAndTags[componentName][objectType][featureName]= \
+ tags
+
+ outFile=open(outFileName,'w')
+
+ json.dump(allFeaturesAndTags,outFile,indent=2)
+
+
+
+defprovenance_command():
+"""
+ Get a string to use for provenance in each feature
+ """
+ # Authors
+ # -------
+ # Phillip J. Wolfram, Xylar Asay-Davis
+
+ cwd=os.getcwd()
+ user=os.getenv('USER')
+ curtime=datetime.datetime.now().strftime('%m/%d/%y %H:%M')
+ call=' '.join(sys.argv)
+ host=socket.gethostname()
+ sep=' : '
+ provstr=sep.join([curtime,host,user,cwd,call])+';'
+ returnprovstr
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/_modules/index.html b/main/_modules/index.html
new file mode 100644
index 00000000..03b2e621
--- /dev/null
+++ b/main/_modules/index.html
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+ Overview: module code — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
split the feature collection into its individual features
+
update the manifest of all features and tags
+
commit the changes and make a pull request
+
+
+
importos
+fromgeometric_featuresimportGeometricFeatures,read_feature_collection
+fromgeometric_features.utilsimportwrite_feature_names_and_tags
+
+# A new feature colleciton has been constructed and tagged using the
+# naming convetions of geometric_features
+fc=read_feature_collection('my_new_features.geojson')
+
+# make a geometric features object that points to geometry in the local
+# cache in ./geometric_data
+gf=GeometricFeatures(cacheLocation='./geometric_data')
+
+# split the feature collection into individual features within
+# ./geometric_data
+gf.split(fc)
+
+# write a file features_and_tags.json with features and tags from the cache
+write_feature_names_and_tags(gf.cacheLocation)
+
+# move features_and_tags.json into geometric_features to replace the old
+# manifest
+os.rename('features_and_tags.json',
+ 'geometric_features/features_and_tags.json')
+
+
+
After this, you can gitadd and gitcommit the changes, and make a
+pull request to have them added to the repository.
+
It is not recommended that you modified features directly in
+geometric_data, but if you have already done so, you can update the
+manifest of all features and tags based on your changes first, then merge your
+features into a feature collection and then split it back out into individual
+features to ensure consistent formatting.
+
importos
+fromgeometric_featuresimportGeometricFeatures
+fromgeometric_features.utilsimportwrite_feature_names_and_tags
+
+
+# Write a file features_and_tags.json with features and tags from the cache.
+# This updates the file names, feature names and tags that geometric_features
+# knows about.
+write_feature_names_and_tags('./geometric_data')
+
+# move features_and_tags.json into geometric_features to replace the old
+# manifest
+os.rename('features_and_tags.json',
+ 'geometric_features/features_and_tags.json')
+
+# Make a geometric features object that gets data from a local cache in
+# ./geometric_data. (The remote branch won't matter.)
+gf=GeometricFeatures(cacheLocation='./geometric_data')
+
+# Make a feature colleciton with the standrd transport sections
+fc=gf.read(componentName='ocean',objectType='transect',
+ tags=['standard_transport_sections'])
+
+# split the feature collection back into individual features within
+# ./geometric_data to clean things up
+gf.split(fc)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/aggregation.html b/main/aggregation.html
new file mode 100644
index 00000000..e38b7fb4
--- /dev/null
+++ b/main/aggregation.html
@@ -0,0 +1,242 @@
+
+
+
+
+
+
+
+
+ Aggregate Existing Features — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The geometric_features.aggregation module contains functions used to
+aggregate existing features to make new, larger ones. An example usage of these
+aggregation functions is to create masks for regional averaging.
This function returns the function that will aggregate the requested group,
+a prefix for the group (a modified version of the group name) and a date stamp
+that is updated each time the features in the group are changed. This way,
+mask files can be created from these features with filenames that include the
+date stamp. As long as the date stamp has not changed, these cached mask files
+can be reused.
The function geometric_features.aggregation.ocean.subbasins()
+aggregates oceanic regions to make the following ocean subbasins: North and
+South Atlantic, North and South Pacific, Indian Basin, Arctic Basin, and
+Southern Ocean Basin.
The function geometric_features.aggregation.ocean.basins() aggregates
+oceanic regions to make the following ocean basins: Atlantic, Pacific, Indian,
+Arctic, Southern Ocean, Mediterranean, Global Ocean, Global Ocean 65N to 65S,
+Global Ocean 15S to 15N.
The function geometric_features.aggregation.ocean.arctic() aggregates
+regions of the Arcic (and subArctic): Baffin Bay, Baltic Sea, Barents Sea,
+Beaufort Gyre, Beaufort Gyre Shelf, Canada Basin, Canadian Archipelago,
+Central Arctic, Chukchi Sea, East Siberian Sea, Greenland Sea, Hudson Bay,
+Irminger Sea, Kara Sea, Labrador Sea, Laptev Sea, North Sea, Norwegian Sea, and
+Arctic Ocean - no Barents, Kara Seas.
The function geometric_features.aggregation.ocean.greenland()
+aggregates regions of the continental shelves around Greenland based on the
+ISMIP6 regions: ISMIP6 Greenland Central East Shelf,
+ISMIP6 Greenland Central West Shelf, ISMIP6 Greenland North East Shelf,
+ISMIP6 Greenland North Shelf, ISMIP6 Greenland North West Shelf,
+ISMIP6 Greenland South East Shelf, ISMIP6 Greenland South West Shelf.
The function geometric_features.aggregation.ocean.ice_shelves()
+aggregates ice shelves and ice-shelf regions. There are 106 regions, so they
+won’t all be listed. See the resulting feature collection or the code itself
+for the full list.
The function geometric_features.aggregation.seaice.arctic() aggregates
+regions of the Arctic as defined by the
+National Snow and Ice Data Center (NSIDC) that are
+relevant for sea ice: Baffin Bay NSIDC, Barents Sea, Beaufort Sea NSIDC,
+Canadian Archipelago NSIDC, Central Arctic NSIDC, Chukchi Sea NSIDC,
+East Siberian Sea NSIDC, Hudson Bay NSIDC, Kara Sea, Laptev Sea NSIDC.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/api.html b/main/api.html
new file mode 100644
index 00000000..fb9ba374
--- /dev/null
+++ b/main/api.html
@@ -0,0 +1,358 @@
+
+
+
+
+
+
+
+
+ API reference — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This page provides an auto-generated summary of the geometric features API. For
+more details and examples, refer to the relevant chapters in the main part of
+the documentation.
Make a json file with all the available features and tags by component and object type, used to update the file when new geometric features are added to the repo
Aggregates ocean regions into the following larger sub-basins: * Arctic Ocean Basin * North Atlantic Basin * South Atlantic Basin * North Pacific Basin * South Pacific Basin * Indian Ocean Basin * Southern Ocean Basin
If you add a new capability to geometric_features, it should also be
+documented under the docs directory. After making changes, it is useful to
+do a local build of the docs.
+
First, set up the development environment as described in Quick Start.
+Then, run:
+
cddocs
+makeclean
+makehtml
+
+
+
You can find the test build in _build/html/index.html.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/feature_collection.html b/main/feature_collection.html
new file mode 100644
index 00000000..3ed534e7
--- /dev/null
+++ b/main/feature_collection.html
@@ -0,0 +1,262 @@
+
+
+
+
+
+
+
+
+ FeatureCollection — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
FeatureCollection objects can be used to manipulate features in several
+ways. Typically, you would use member functions such as fc.merge(),
+fc.combine() and fc.plot() to perform these manipulations.
These features can later be split into the :ref: GemoetricData
+direcory (see Adding New Features) and uploaded to the GitHub repository.
+Tags make it easier to combine many features into a feature collection (e.g.
+individual ocean regions into ocean basins).
Group names can be used later to identify the features in a collection, e.g.
+in order to create a mask for that cells in a mesh that belong to the features
+in that group. The MPAS-Ocean model uses these features to create masks for
+land and for ocean regions such as ocean basins and Antarctic ice-shelf
+cavities.
Sometimes, features are made up of segments or polygons with tiny edges that
+add little relevant detail to the features but make the files describing them
+needlessly large. In such cases, the features can be simplified by calling
+geometric_features.FeatureCollection.simplify() with
+and appropriate length scale (in degrees latitude/longitude) over which the
+feature may be modified to make it simpler. If a length scale of zero is
+used, the feature will be simplified without any modification tot he shape
+being described (so that only edges or polygons that are truly reduntant will
+be removed).
Valid geojson shapes should not cross the “antimeridian”, the location
+where 180 degrees longitude meets -180 degrees. Often, it isn’t practical to
+contstruct a feature’s geometry from the start in this way, so this function
+provides a bit of a hack for removing a tiny sliver of the feature around the
+antimeridian so that the resulting shape remians between -180 and 180 degrees
+longitude.
An object for keeping track of where geometric features are cached and
+downloading missing features as needed.
+
+
Variables:
+
+
allFeaturesAndTags (dict of dict) – A cache of all the feature names and tags in the geometric_features
+repo used to determine which features need to be downloaded into the
+local cache
+
remoteBranch (str, optional) – The branch or tag from the geometric_features repo to download
+from if files are missing from the local cache
cacheLocation (str, optional) – The location of the local geometric features cache. If not
+specified, the environment variable $GEOMETRIC_DATA_DIR is
+used if it is set and ./geometric_data is used otherwise.
+
remoteBranchOrTag (str, optional) – The branch or tag from the geometric_features repo to download
+from if files are missing from the local cache, with default to
+a tag the same as this version of geometric_features
Read one or more features from the cached collection of geometric
+features. If any of the requested features have not been cached, they
+are downloaded from the geometric_features GitHub repository. If
+neither featureNames nor tags are specified, all features of
+the component and object type are read in.
+
+
Parameters:
+
+
componentName ({'bedmachine', 'bedmap2', 'iceshelves', 'landice', 'natural_earth', 'ocean'}) – The component from which to retrieve the geometric features
+
objectType ({'point', 'transect', 'region'}) – The type of geometry to load, a point (0D), transect (1D) or region
+(2D)
+
featureNames (list of str, optional) – The names of geometric features to read
+
tags (list of str, optional) – A list of tags to check for. When allTags=True, a feature is
+only read in if it has all tags. Otherwise, features with any of
+the tags are read.
+
allTags (bool, optional) – Whether a feature must have all tags (instead of any of the tags)
+
+
+
Returns:
+
fc (geometric_features.FeatureCollection) – The feature collection read in
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/generated/geometric_features.GeometricFeatures.split.html b/main/generated/geometric_features.GeometricFeatures.split.html
new file mode 100644
index 00000000..2ee3d9f1
--- /dev/null
+++ b/main/generated/geometric_features.GeometricFeatures.split.html
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+ geometric_features.GeometricFeatures.split — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Get a geojson mask file and the appropriate file suffix for the given
+region group.
+
+
Parameters:
+
region_group (str) – The name of a region group to get mask features for, one of
+‘Antarctic Regions’, ‘Arctic Ocean Regions’, ‘Arctic Sea Ice Regions’,
+‘Ocean Basins’, ‘Ice Shelves’, ‘Ocean Subbasins’, ‘ISMIP6 Regions’,
+‘MOC Basins’, ‘Transport Transects’, or ‘Arctic Transport Transects’
+
+
Returns:
+
+
function (callable) – An aggregation functions for collecting the features, which takes a
+geometric_features.GeometricFeatures object as its argument
+
prefix (str) – A prefix (or suffix) for use in file names that corresponds to the
+region group
+
date (str) – A date stamp when the regions in fc were last modified. This date
+can be used to cache masks based on these regions as long as the date
+remains the same.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/generated/geometric_features.aggregation.html b/main/generated/geometric_features.aggregation.html
new file mode 100644
index 00000000..4d936329
--- /dev/null
+++ b/main/generated/geometric_features.aggregation.html
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+ geometric_features.aggregation — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Aggregates ocean regions into the following larger sub-basins:
+* Arctic Ocean Basin
+* North Atlantic Basin
+* South Atlantic Basin
+* North Pacific Basin
+* South Pacific Basin
+* Indian Ocean Basin
+* Southern Ocean Basin
Make a json file with all the available features and tags by component
+and object type, used to update the file when new geometric features are
+added to the repo
+
+
Parameters:
+
cacheLocation (str, optional) – The location of the geometric features cache
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/genindex.html b/main/genindex.html
new file mode 100644
index 00000000..1199ac2b
--- /dev/null
+++ b/main/genindex.html
@@ -0,0 +1,349 @@
+
+
+
+
+
+
+
+ Index — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index
+
+
+
+
+
+
+
+
+
+
Index
+
+
+ _
+ | A
+ | B
+ | C
+ | D
+ | F
+ | G
+ | I
+ | M
+ | P
+ | R
+ | S
+ | T
+ | W
+
+
The the overarching purpose of geometric_features is to facilitate access
+to and manipulation of the geometric data in the repository. This data is
+currently divided across 6 components, bedmachine, bedmap2,
+iceshelves, landice, natural_earth, and ocean.
These components each define two “coastlines” between the Antarctic continent
+and the ocean. One excludes the cavity under ice shelves while the other
+includes them. The bedmachine component uses the BedMachine Antarctica
+dataset
+(Morlighem et al. 2020)
+to define the coastlines, while the bedmap2 dataset is based on Bedmap2
+(Fretwell et al. 2016).
This component defines regions that extend the bounds of present-day Antarctic
+ice shelves both out to the edge of the continental shelf and into regions of
+grounded ice. These maps are used to partition maps of Antarctic melt into
+total and average melt fluxes over these ice shelves in ocean models that
+simulate this melting. The ice-shelf features have been divided across the
+IMBIE1 Basins so that melt rates can also be aggregated per basin.
This component contains regions, transects and points of significance for the
+global ocean. The regions mostly define individual seas from the
+International Hydrographic Organisation, but some are masking regions used
+to delineate larger basins such as those used for computing the Meridional
+Overturning Circulation. The transects include passages through which ocean
+transport is commonly measured; locations of so-called “critical passages”,
+though which ocean flow must be allowed at lower model resolution; and
+“critical land blockages” such as the Antarctic Peninsula, though which ocean
+should not be allowed to flow. The points in the database are mostly used
+as seed points for flood-filling ocean meshes to exclude inland seas that are
+not connected to the ocean. These points are also sometimes used to sample
+ocean properties to debug model runs.
geometric_features supports three object types: regions, transects and
+points. Regions are by far the most common, defining areas on the globe.
+Transects define a connected series of line setments on the globe (typically
+with the implication that they will also include a depth component from the
+ocean model, though the features are defined only on the surface of the
+sphere). These could represent such features as ship tracks, passages,
+radar lines, or float trajectories. Points specify a single location on the
+globe.
An individual feature is defined by nested datastructure of python
+dictionaries. The outermost dictionary contains at least 3 keys:
+'type', 'properties' and 'geometry'.
The properties of a feature are stored in another python dictionary, nested in
+the outer dictionary. Properties include: 'name' - the name of the
+feature; 'tags' - a list of tags describing the feature, separated by
+semicolons; 'object' - the object type of the feature (region, transect or
+point); 'component' - the component of the feature; and 'author' -
+a comma- or semicolon-separated list of authors (or URLs). Optionally, a
+feature can include any number of other user-defined properties.
The 'type' of the geometry ('Polygon' or 'MultiPolygon' for a
+region, 'LineString' or 'MultiLineString' for a transect and
+'Point' or 'Multipoint' for a point) and the 'coordinates' defining
+the feature’s geometry. By far, the easiest way to create an manipulate the
+geometry is with the shapely package.
The GeometricFeatures class knows about both a local cache of
+Geometric Data and the GitHub repository where it can be retrieved as
+needed. A GeometricFeatures object is created with an optional path to the
+local cache and/or the name of the remote branch or tag in which to find the
+geometric data. The default local cache is ./geometric_data, and the
+default remote branch is the same as the version number of the
+geometric_features package that is installed (highly recommended!). If
+using a branch other than the package version, the list of all available
+features and tags (which is included in the package) may not include all the
+features in the desired branch. That is, if you install v0.1 of the
+geometric_features conda package, you should expect to work with v0.1
+of the Geometric Data as well.
+
An example workflow for creating a GeometricFeatures object and using it
+to read in a set of geometric features (possibly after downloading the
+geometric data from GitHub) is:
+
fromgeometric_featuresimportGeometricFeatures
+
+# get geometric data from geometric_features v0.1 and store it in
+# the local directory ./geometric_data
+gf=GeometricFeatures(localCache='./geometric_data',
+ remoteBranchOrTag='0.1')
+
+# read in a feature collection defining the coastline
+fc=gf.read(componentName='natural_earth',objectType='region',
+ featureNames=['Land Coverage'])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/index.html b/main/index.html
new file mode 100644
index 00000000..527098e3
--- /dev/null
+++ b/main/index.html
@@ -0,0 +1,176 @@
+
+
+
+
+
+
+
+
+ geometric_features — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This repository houses definitions of geometric features. These features
+can include regions, transects, and points, described in geojson format.
+For example, here are some regions for Antarctica.
The python geometric_features package can be used to help maintain and use
+this repository. Several example scripts that make use of the package can be
+found in the examples directory. Each of the classes and functions that make
+up the package have extensive documentation. More user-level documentation
+will be added shortly.
+
To use geometric features, you can install it in a conda environment:
Merge, combine, tag, mask out or simplify the features, see below.
+
Use the shapely package to edit the geometry in more sophisticated ways
+
+
+
Visualize features:
+
+
fc.plot(projection='cyl')
+
+
+
Split feature collection back into individual features for inclusion in the
+repo:
+
+
gf.split(fc)
+
+
+
+
Available functionality includes:
+
+
fc.merge(other) - Merge two feature collection together.
+
fc.combine() - Combine features into a single feature.
+
fc.difference() - Mask features using shapes in a second feature file.
+
fc.fix_antimeridian() - Split a feature at the antimeridian (+/- 180 longitude). The resulting feature has all points between -180 and 180 lon.
+
fc.set_group_name() - Set the “groupName” property of the FeatureCollection
+
fc.tag() - Add one or more tags to the “tag” property of each feature in a collection. This can be useful for reading back a collection of features with that tag.
+
+
IMPORTANT: Always use the gf.split(fc) script when placing features into
+the geometric_data directory. This will help everyone maintain the
+repository, and allow tools to parse them cleanly.
+
Many of this functionality can also be accessed with a command-line interface:
An example workflow to read in, plot and write out a set of features is
+
#!/usr/bin/env python
+
+fromgeometric_featuresimportGeometricFeatures
+importmatplotlib.pyplotasplt
+
+# create a GeometricFeatures object that points to a local cache of geometric
+# data and knows which branch of geometric_feature to use to download
+# missing data
+gf=GeometricFeatures(cacheLocation='./geometric_data')
+
+# read in a FeatureCollection containing all ocean regions in the Atlantic
+# basin
+fcAtlantic=gf.read(componentName='ocean',objectType='region',
+ tags=['Atlantic_Basin'])
+
+fcAtlantic.plot('cyl')
+plt.title('Atlantic merged')
+
+# combine them all into a single feature
+fcAtlantic=fcAtlantic.combine(featureName='Atlantic_Basin')
+fcAtlantic.plot('cyl')
+plt.title('Atlantic combined')
+
+# make another feature containing the regions in Filchner-Ronne Ice Shelf
+fcFilchnerRonne=gf.read(componentName='iceshelves',objectType='region',
+ featureNames=['Filchner_1','Filchner_2',
+ 'Filchner_3','Ronne_1','Ronne_2'])
+fcFilchnerRonne.plot('southpole')
+plt.title('Filchner-Ronne')
+
+
+# make one more collection of all the IMBIE basins in West Antarctica
+fcWestAntarctica=gf.read(componentName='landice',objectType='region',
+ tags=['WestAntarcticaIMBIE'])
+
+fcWestAntarctica.plot('southpole')
+plt.title('West Antarctica')
+
+fcWestAntarctica.to_geojson('west_antarctica.geojson')
+plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/search.html b/main/search.html
new file mode 100644
index 00000000..9c56ed19
--- /dev/null
+++ b/main/search.html
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+ Search — geometric_features 1.5.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+