Esempio n. 1
0
    def render_aspect(self, ax1, ax2, ax3, mean):
        ax1.set_title('Aspect distribution', **PlotBase.title_opts())
        ax1.set_ylabel('Count', **PlotBase.label_opts())
        Histogram.show_mean(ax1, self.lidar.aspect.mean())

        ax2.set_title('Aspect distribution', **PlotBase.title_opts())
        ax2.set_ylabel('Count', **PlotBase.label_opts())
        Histogram.show_mean(ax2, self.sfm.aspect.mean())

        ax3.set_title('Differences per aspect angle in 10 degree intervals',
                      **PlotBase.title_opts())
        ax3.set_ylabel('Percent', **PlotBase.label_opts())
        ax3.set_xlabel('Degree', **PlotBase.label_opts())
        PlotBase.add_to_legend(ax3, self.BOX_TEXT.format(mean.round(2)))
Esempio n. 2
0
    def render_elevation(self, ax1, ax2, ax3, mean):
        ax1.set_title('Elevation distribution', **PlotBase.title_opts())
        ax1.set_ylabel('Count', **PlotBase.label_opts())
        Histogram.show_mean(ax1, self.lidar.elevation.mean())

        ax2.set_title('Elevation distribution', **PlotBase.title_opts())
        ax2.set_ylabel('Count', **PlotBase.label_opts())
        Histogram.show_mean(ax2, self.sfm.elevation.mean())

        ax3.set_title('Differences per elevation in 10 m intervals',
                      **PlotBase.title_opts())
        ax3.set_ylabel('Percent', **PlotBase.label_opts())
        ax3.set_xlabel('Elevation', **PlotBase.label_opts())
        PlotBase.add_to_legend(ax3, self.BOX_TEXT.format(mean.round(4)))
Esempio n. 3
0
    def plot(self, raster_attr):
        self.print_status(str(raster_attr))

        figure, (ax1, ax2) = plt.subplots(ncols=2)
        figure.set_size_inches(10, 5)

        axes = (ax1, ax2)
        ax1.get_shared_x_axes().join(ax1, ax2)
        ax1.get_shared_y_axes().join(ax1, ax2)

        for n, ax in enumerate(axes):
            ax.set_facecolor('0.9')

        hillshade_opts = dict(cmap='gray', clim=(1, 255))
        ax1.imshow(
            self.lidar.hill_shade, extent=self.lidar.extent, **hillshade_opts
        )
        self.sfm.join_masks('hill_shade', getattr(self.lidar, raster_attr))
        ax2.imshow(
            self.sfm.hill_shade, extent=self.sfm.extent, **hillshade_opts
        )

        im_opts = dict(
            cmap=cm.get_cmap('jet'),
            alpha=0.3,
            vmin=self.min_for_attr(raster_attr),
            vmax=self.max_for_attr(raster_attr),
        )

        ax1.imshow(
            getattr(self.lidar, raster_attr),
            extent=self.lidar.extent,
            **im_opts
        )
        ax1.set_title(PlotBase.LIDAR_LABEL, **PlotBase.title_opts())

        self.sfm.join_masks(raster_attr, getattr(self.lidar, raster_attr))
        image = ax2.imshow(
            getattr(self.sfm, raster_attr), extent=self.sfm.extent, **im_opts
        )
        ax2.set_yticklabels([])
        ax2.set_title(PlotBase.SFM_LABEL, **PlotBase.title_opts())

        self.insert_colorbar(plt, ax2, image, self.SCALE_BAR_LABEL[raster_attr])

        plt.tight_layout()
        plt.savefig(
            self.OUTPUT_FILE.format(self.output_path, raster_attr),
        )
Esempio n. 4
0
    def plot(self, raster_attr):
        self.print_status(str(raster_attr))

        fig = plt.figure(constrained_layout=False)
        fig.set_size_inches(14, 12)
        heights = [2, 1]
        grid_opts = dict(figure=fig, height_ratios=heights)

        difference = getattr(self.raster_difference, raster_attr)

        if raster_attr is 'elevation':
            grid_spec = GridSpec(nrows=2,
                                 ncols=3,
                                 width_ratios=[3, 2, 3],
                                 **grid_opts)
            bins = np.arange(difference.min(),
                             difference.max() + self.HIST_BIN_WIDTH,
                             self.HIST_BIN_WIDTH)
            bounds = dict(norm=colors.BoundaryNorm(boundaries=bins,
                                                   ncolors=self.COLORMAP.N))
        else:
            grid_spec = GridSpec(nrows=2,
                                 ncols=2,
                                 width_ratios=[3, 2],
                                 **grid_opts)
            bounds = dict()
            bins = 'auto'

        ax1 = fig.add_subplot(grid_spec[0, :])
        diff_plot = ax1.imshow(difference,
                               cmap=self.COLORMAP,
                               alpha=0.8,
                               extent=self.sfm.extent,
                               **bounds)
        ax1.set_title(self.TITLE.format(raster_attr.capitalize()),
                      **PlotBase.title_opts())
        self.insert_colorbar(plt, ax1, diff_plot,
                             self.SCALE_BAR_LABEL[raster_attr])

        ax2 = fig.add_subplot(grid_spec[1, 0])
        ax2.hist(difference.compressed(), bins=bins, label='Count')
        ax2.set_xlabel(self.SCALE_BAR_LABEL[raster_attr],
                       **PlotBase.label_opts())
        ax2.set_ylabel('Count', **PlotBase.label_opts())
        if raster_attr is 'elevation':
            self.add_hist_stats(ax2)

        ax3 = fig.add_subplot(grid_spec[1, 1])
        box = ax3.boxplot(difference.compressed(),
                          sym='k+',
                          whis=self.BOX_PLOT_WHISKERS,
                          positions=[0.1])
        ax3.set_xlim([0, .35])
        ax3.tick_params(axis='x',
                        which='both',
                        bottom=False,
                        top=False,
                        labelbottom=False)
        ax3.set_ylabel(self.SCALE_BAR_LABEL[raster_attr],
                       **PlotBase.label_opts())
        self.add_box_plot_stats(ax3, box)

        if raster_attr is 'elevation':
            ax4 = fig.add_subplot(grid_spec[1, 2])
            probplot = sm.ProbPlot(
                self.raster_difference.elevation.compressed())
            probplot.qqplot(ax=ax4, line='s')
            ax4.get_lines()[0].set(markersize=1)
            ax4.get_lines()[1].set(color='black', dashes=[4, 1])
            ax4.set_title('Normal Q-Q Plot', **self.title_opts())

        plt.tight_layout()
        plt.savefig(self.OUTPUT_FILE.format(self.output_path, raster_attr),
                    dpi=PlotBase.DEFAULT_DPI)