Esempio n. 1
0
    def test_fxn(self):

        with utils.WorkSpace(self.workspace), utils.OverwriteState(True):
            floodslyr, wetlandslyr, buildingslyr = tidegates.assess_impact(
                floods_path=self.floods,
                flood_idcol='GeoID',
                wetlands_path=self.wetlands,
                buildings_path=self.buildings,
                buildings_output=os.path.join(self.workspace,
                                              'flooded_buildings.shp'),
                wetlands_output=os.path.join(self.workspace,
                                             'flooded_wetlands.shp'),
                cleanup=False,
                verbose=False,
            )

            nt.assert_true(isinstance(floodslyr, arcpy.mapping.Layer))
            tgtest.assert_shapefiles_are_close(floodslyr.dataSource,
                                               self.known_floods)

            nt.assert_true(isinstance(wetlandslyr, arcpy.mapping.Layer))
            tgtest.assert_shapefiles_are_close(wetlandslyr.dataSource,
                                               self.known_wetlands)

            nt.assert_true(isinstance(buildingslyr, arcpy.mapping.Layer))
            tgtest.assert_shapefiles_are_close(buildingslyr.dataSource,
                                               self.known_buildings)

        with utils.WorkSpace(self.workspace):
            utils.cleanup_temp_results(self.floods, 'flooded_buildings.shp',
                                       'flooded_wetlands.shp',
                                       '_temp_flooded_wetlands.shp')
    def test_fxn(self):

        with utils.WorkSpace(self.workspace), utils.OverwriteState(True):
            floodslyr, wetlandslyr, buildingslyr = tidegates.assess_impact(
                floods_path=self.floods,
                flood_idcol='GeoID',
                wetlands_path=self.wetlands,
                buildings_path=self.buildings,
                buildings_output=os.path.join(self.workspace, 'flooded_buildings.shp'),
                wetlands_output=os.path.join(self.workspace, 'flooded_wetlands.shp'),
                cleanup=False,
                verbose=False,
            )

            nt.assert_true(isinstance(floodslyr, arcpy.mapping.Layer))
            tgtest.assert_shapefiles_are_close(floodslyr.dataSource, self.known_floods)

            nt.assert_true(isinstance(wetlandslyr, arcpy.mapping.Layer))
            tgtest.assert_shapefiles_are_close(wetlandslyr.dataSource, self.known_wetlands)

            nt.assert_true(isinstance(buildingslyr, arcpy.mapping.Layer))
            tgtest.assert_shapefiles_are_close(buildingslyr.dataSource, self.known_buildings)

        with utils.WorkSpace(self.workspace):
            utils.cleanup_temp_results(
                self.floods,
                'flooded_buildings.shp',
                'flooded_wetlands.shp',
                '_temp_flooded_wetlands.shp'
            )
Esempio n. 3
0
    def analyze(self, topo_array, zones_array, template,
                elev=None, surge=None, slr=None, num=0, **params):
        """ Tool-agnostic helper function for :meth:`.main_execute`.

        Parameters
        ----------
        topo_array : numpy array
            Floating point array of the digital elevation model.
        zones_array : numpy array
            Categorical (integer) array of where each non-zero value
            delineates a tidegate's zone of influence.
        template : arcpy.Raster or tidegates.utils.RasterTemplate
            A raster or raster-like object that define the spatial
            extent of the analysis area. Required attributes are:
              - templatemeanCellWidth
              - templatemeanCellHeight
              - templateextent.lowerLeft
        elev : float, optional
            Custom elevation to be analyzed
        slr : float, optional
            Sea level rise associated with the standard scenario.
        surge : str, optional
            The name of the storm surge associated with the scenario
            (e.g., MHHW, 100yr).
        **params : keyword arguments
            Keyword arguments of analysis parameters generated by
            `self._get_parameter_values`

        Returns
        -------
        floods, flooded_wetlands, flooded_buildings : arcpy.mapping.Layers
            Layers (or None) of the floods and flood-impacted wetlands
            and buildings, respectively.

        """

        # prep input
        elev, title, floods_path = self._prep_flooder_input(
            flood_output=params['flood_output'],
            elev=elev,
            surge=surge,
            slr=slr,
            num=num,
        )

        # define the scenario in the message windows
        self._show_header(title)

        # run the scenario and add its info the output attribute table
        flooded_zones = tidegates.flood_area(
            topo_array=topo_array,
            zones_array=zones_array,
            template=template,
            ID_column=params['ID_column'],
            elevation_feet=elev,
            filename=floods_path,
            num=num,
            verbose=True,
            asMessage=True
        )
        self._add_scenario_columns(flooded_zones.dataSource, elev=elev, surge=surge, slr=slr)

        # setup temporary files for impacted wetlands and buildings
        wl_path = utils.create_temp_filename(floods_path, prefix="_wetlands_", filetype='shape', num=num)
        bldg_path = utils.create_temp_filename(floods_path, prefix="_buildings_", filetype='shape', num=num)

        # asses impacts due to flooding
        fldlyr, wtlndlyr, blgdlyr = tidegates.assess_impact(
            floods_path=floods_path,
            flood_idcol=params['ID_column'],
            wetlands_path=params.get('wetlands', None),
            wetlands_output=wl_path,
            buildings_path=params.get('buildings', None),
            buildings_output=bldg_path,
            cleanup=False,
            verbose=True,
            asMessage=True,
        )

        if wtlndlyr is not None:
            self._add_scenario_columns(wtlndlyr.dataSource, elev=elev, surge=surge, slr=slr)

        return fldlyr, wtlndlyr, blgdlyr
Esempio n. 4
0
    def analyze(self, topo_array, zones_array, template,
                elev=None, surge=None, slr=None, **params):
        """ Tool-agnostic helper function for :meth:`.main_execute`.

        Parameters
        ----------
        topo_array : numpy array
            Floating point array of the digital elevation model.
        zones_array : numpy array
            Categorical (integer) array of where each non-zero value
            delineates a tidegate's zone of influence.
        template : arcpy.Raster or tidegates.utils.RasterTemplate
            A raster or raster-like object that define the spatial
            extent of the analysis area. Required attributes are:
              - templatemeanCellWidth
              - templatemeanCellHeight
              - templateextent.lowerLeft
        elev : float, optional
            Custom elevation to be analyzed
        slr : float, optional
            Sea level rise associated with the standard scenario.
        surge : str, optional
            The name of the storm surge associated with the scenario
            (e.g., MHHW, 100yr).
        **params : keyword arguments
            Keyword arguments of analysis parameters generated by
            `self._get_parameter_values`

        Returns
        -------
        floods, flooded_wetlands, flooded_buildings : arcpy.mapping.Layers
            Layers (or None) of the floods and flood-impacted wetlands
            and buildings, respectively.

        """

        # prep input
        elev, title, floods_path = self._prep_flooder_input(
            flood_output=params['flood_output'],
            elev=elev,
            surge=surge,
            slr=slr,
        )

        # define the scenario in the message windows
        self._show_header(title)

        # run the scenario and add its info the output attribute table
        flooded_zones = tidegates.flood_area(
            topo_array=topo_array,
            zones_array=zones_array,
            template=template,
            ID_column=params['ID_column'],
            elevation_feet=elev,
            filename=floods_path,
            verbose=True,
            asMessage=True
        )
        self._add_scenario_columns(flooded_zones.dataSource, elev=elev, surge=surge, slr=slr)

        # setup temporary files for impacted wetlands and buildings
        wl_path = utils.create_temp_filename(floods_path, prefix="_wetlands_", filetype='shape')
        bldg_path = utils.create_temp_filename(floods_path, prefix="_buildings_", filetype='shape')

        # asses impacts due to flooding
        fldlyr, wtlndlyr, blgdlyr = tidegates.assess_impact(
            floods_path=floods_path,
            flood_idcol=params['ID_column'],
            wetlands_path=params.get('wetlands', None),
            wetlands_output=wl_path,
            buildings_path=params.get('buildings', None),
            buildings_output=bldg_path,
            cleanup=False,
            verbose=True,
            asMessage=True,
        )

        if wtlndlyr is not None:
            self._add_scenario_columns(wtlndlyr.dataSource, elev=elev, surge=surge, slr=slr)

        return fldlyr, wtlndlyr, blgdlyr
Esempio n. 5
0
    def analyze(self, elev=None, surge=None, slr=None, **params):
        """ Tool-agnostic helper function for :meth:`.main_execute`.

        Parameters
        ----------
        elev : float, optional
            Custom elevation to be analyzed
        slr : float, optional
            Sea level rise associated with the standard scenario.
        surge : str, optional
            The name of the storm surge associated with the scenario
            (e.g., MHHW, 100yr).
        **params : keyword arguments
            Keyword arguments of analysis parameters generated by
            `self._get_parameter_values`

        Returns
        -------
        floods, flooded_wetlands, flooded_buildings : arcpy.mapping.Layers
            Layers (or None) of the floods and flood-impacted wetlands
            and buildings, respectively.

        """

        # prep input
        elev, title, floods_path = self._prep_flooder_input(
            flood_output=params['flood_output'],
            elev=elev,
            surge=surge,
            slr=slr,
        )

        # define the scenario in the message windows
        self._show_header(title)

        # run the scenario and add its info the output attribute table
        flooded_zones = tidegates.flood_area(
            dem=params['dem'],
            zones=params['zones'],
            ID_column=params['ID_column'],
            elevation_feet=elev,
            filename=floods_path,
            verbose=True,
            asMessage=True
        )
        self._add_scenario_columns(flooded_zones.dataSource, elev=elev, surge=surge, slr=slr)

        # setup temporary files for impacted wetlands and buildings
        wl_path = utils.create_temp_filename(floods_path, prefix="_wetlands_", filetype='shape')
        bldg_path = utils.create_temp_filename(floods_path, prefix="_buildings_", filetype='shape')

        # asses impacts due to flooding
        fldlyr, wtlndlyr, blgdlyr = tidegates.assess_impact(
            floods_path=floods_path,
            flood_idcol=params['ID_column'],
            wetlands_path=params.get('wetlands', None),
            wetlands_output=wl_path,
            buildings_path=params.get('buildings', None),
            buildings_output=bldg_path,
            cleanup=False,
            verbose=True,
            asMessage=True,
        )

        if wtlndlyr is not None:
            self._add_scenario_columns(wtlndlyr.dataSource, elev=elev, surge=surge, slr=slr)

        return fldlyr, wtlndlyr, blgdlyr