Esempio n. 1
0
    def onRectangle(self, rectangle_geometry):
        """
        The ``onRectangle()`` method is called after the user has activated the
        tool and selected an area of interest. This is where the main part of
        the tool is executed.

        This method calls the :func:`common.avevel.evaluate` function where the
        average displacement velocity is computed.

        After popping-up a window with the result, the selection is cleared and
        the method returns.

        Args:
            rectangle_geometry (Extent): the extent of the selection.
                This argument is passed directly by the ArcMAP enviromnment
                upon execution of the add-in.
        """
        # Detect if a layer is selected
        try:
            self.sar, md = utils.verifySqueeSAR()
        except "Invalid layer!":
            return

        # Identiy user selected data
        try:
            nfeat, spatref = utils.selectSqueeSARData(rectangle_geometry, self.sar)
        except "No features!":
            return

        # Evaluate average velocity
        ave_vel = avevel.evaluate(self.sar)

        # Pop-up a message box with the informations
        text = "{0} feature(s) selected within:\n".format(nfeat) + \
               "Lat: {0} to {1}\n".format(rectangle_geometry.YMin, rectangle_geometry.YMax) + \
               "Lon: {0} to {1}\n\n".format(rectangle_geometry.XMin, rectangle_geometry.XMax) + \
               "Average velocity: {:.2f} mm/year".format(ave_vel)

        pa.MessageBox(text,
                      "Info",
                      0)

        # Clear selection
        ap.SelectLayerByAttribute_management(self.sar, "CLEAR_SELECTION")
Esempio n. 2
0
    def onRectangle(self, rectangle_geometry):
        """
        The ``onRectangle()`` method is called after the user has activated the
        tool and selected an area of interest. This is where the main part of
        the tool is executed.

        This method calls the :func:`common.avevel.evaluate` function where the
        average displacement velocity is computed.

        After popping-up a window with the result, the selection is cleared and
        the method returns.

        Args:
            rectangle_geometry (Extent): the extent of the selection.
                This argument is passed directly by the ArcMAP enviromnment
                upon execution of the add-in.
        """
        # Detect if a layer is selected
        try:
            self.sar, md = utils.verifySqueeSAR()
        except "Invalid layer!":
            return

        # Identiy user selected data
        try:
            nfeat, spatref = utils.selectSqueeSARData(rectangle_geometry,
                                                      self.sar)
        except "No features!":
            return

        # Evaluate average velocity
        ave_vel = avevel.evaluate(self.sar)

        # Pop-up a message box with the informations
        text = "{0} feature(s) selected within:\n".format(nfeat) + \
               "Lat: {0} to {1}\n".format(rectangle_geometry.YMin, rectangle_geometry.YMax) + \
               "Lon: {0} to {1}\n\n".format(rectangle_geometry.XMin, rectangle_geometry.XMax) + \
               "Average velocity: {:.2f} mm/year".format(ave_vel)

        pa.MessageBox(text, "Info", 0)

        # Clear selection
        ap.SelectLayerByAttribute_management(self.sar, "CLEAR_SELECTION")
Esempio n. 3
0
    def onRectangle(self, rectangle_geometry):
        """
        The ``onRectangle()`` method is called after the user has activated the
        tool and selected an area of interest. This is where the main part of
        the tool is executed.

        In order for the evaluation to be carried on, there should be *at least
        3 scatterers* selected.

        This method calls the :func:`common.subres.evaluate` function where the
        subsidence residual map is computed.

        The result of the residual evaluation is stored in a raster file (named
        *subsidence*) within the default geodatabase. The raster is also added
        as a layer (with the same name) and overlayed with transparency over
        the area selected by the user.

        Args:
            rectangle_geometry (Extent): the extent of the selection.
                This argument is passed directly by the ArcMAP enviromnment
                upon execution of the add-in.
        """
        # Detect if a layer is selected
        try:
            self.sar, md = utils.verifySqueeSAR()
        except "Invalid layer!":
            return

        # TODO: At this point the parameters of the Gaussian search space should be known.
        #       We should extend the underlying selection to include 3 sigma extra to allow for full analysis
        #       The variable extent should be modified to include the additional area
        extent = rectangle_geometry

        # Identiy user selected data
        try:
            nfeat, spatref = utils.selectSqueeSARData(extent, self.sar)
        except "No features!":
            return

        # Verify that the number of selected scatterers is larger than three
        if nfeat < 3:
            pa.MessageBox(
                "At least 3 features required within the selection boundaries",
                "Warning", 0)
            return

        # Evaluate residual raster
        res = subres.evaluate(extent, self.sar)

        # Evaluate the size of the raster cell
        (x_len, y_len) = np.shape(res)
        x_cell_size = extent.width / x_len
        y_cell_size = extent.height / y_len

        # Define the spatial coordinate system using the spatial reference
        # obtained from the selected SqueeSAR layer.
        ap.env.outputCoordinateSystem = spatref

        # Convert the returned numpy array into a raster file and store it
        raster = ap.NumPyArrayToRaster(res, extent.lowerLeft, x_cell_size,
                                       y_cell_size)
        raster.save("subsidence")

        # Select the first dataframe and create a raster layer
        df = ap.mapping.ListDataFrames(md)[0]
        add_layer = ap.mapping.Layer("subsidence")

        # If transparency is supported, set to 25%
        if add_layer.supports("TRANSPARENCY"):
            add_layer.transparency = 25

        # Add the raster layer to the top
        ap.mapping.AddLayer(df, add_layer, "TOP")

        # Clear the current selection
        ap.SelectLayerByAttribute_management(self.sar, "CLEAR_SELECTION")
Esempio n. 4
0
    def onRectangle(self, rectangle_geometry):
        """
        The ``onRectangle()`` method is called after the user has activated the
        tool and selected an area of interest. This is where the main part of
        the tool is executed.

        In order for the evaluation to be carried on, there should be *at least
        3 scatterers* selected.

        This method calls the :func:`common.subres.evaluate` function where the
        subsidence residual map is computed.

        The result of the residual evaluation is stored in a raster file (named
        *subsidence*) within the default geodatabase. The raster is also added
        as a layer (with the same name) and overlayed with transparency over
        the area selected by the user.

        Args:
            rectangle_geometry (Extent): the extent of the selection.
                This argument is passed directly by the ArcMAP enviromnment
                upon execution of the add-in.
        """
        # Detect if a layer is selected
        try:
            self.sar, md = utils.verifySqueeSAR()
        except "Invalid layer!":
            return

        # TODO: At this point the parameters of the Gaussian search space should be known.
        #       We should extend the underlying selection to include 3 sigma extra to allow for full analysis
        #       The variable extent should be modified to include the additional area
        extent = rectangle_geometry

        # Identiy user selected data
        try:
            nfeat, spatref = utils.selectSqueeSARData(extent, self.sar)
        except "No features!":
            return

        # Verify that the number of selected scatterers is larger than three
        if nfeat < 3:
            pa.MessageBox("At least 3 features required within the selection boundaries",
                          "Warning",
                          0)
            return

        # Evaluate residual raster
        res = subres.evaluate(extent, self.sar)

        # Evaluate the size of the raster cell
        (x_len, y_len) = np.shape(res)
        x_cell_size = extent.width / x_len
        y_cell_size = extent.height / y_len

        # Define the spatial coordinate system using the spatial reference
        # obtained from the selected SqueeSAR layer.
        ap.env.outputCoordinateSystem = spatref

        # Convert the returned numpy array into a raster file and store it
        raster = ap.NumPyArrayToRaster(res, extent.lowerLeft, x_cell_size, y_cell_size)
        raster.save("subsidence")

        # Select the first dataframe and create a raster layer
        df = ap.mapping.ListDataFrames(md)[0]
        add_layer = ap.mapping.Layer("subsidence")

        # If transparency is supported, set to 25%
        if add_layer.supports("TRANSPARENCY"):
            add_layer.transparency = 25

        # Add the raster layer to the top
        ap.mapping.AddLayer(df, add_layer, "TOP")

        # Clear the current selection
        ap.SelectLayerByAttribute_management(self.sar, "CLEAR_SELECTION")