gdalwrap::gdal dsm_to_region(const gdalwrap::gdal& dsm) { gdalwrap::gdal region; region.copy_meta(dsm, clara::region::N_RASTER); const auto& dsm_band = dsm.bands[0]; size_t pose, width = dsm.get_width(); for (size_t px_x = 0; px_x < width - 1; px_x++) for (size_t px_y = 0; px_y < dsm.get_height() - 1; px_y++) { // compute :: Z_MEAN{x1 - x2} > 30cm : P_OBSTACLE = 1 pose = px_x + px_y * width; flag_obstacle(dsm_band, region.bands, pose, pose + 1); flag_obstacle(dsm_band, region.bands, pose, pose + width); flag_obstacle(dsm_band, region.bands, pose, pose + width + 1); } region.names = {"NO_3D_CLASS", "FLAT", "OBSTACLE", "ROUGH", "SLOPE"}; return region; }
static bpy::list py_get_band_as_uchar(gdalwrap::gdal& self, const std::string& name) { return std_vector_to_py_list(gdalwrap::raster2bytes(self.get_band(name))); }
static bpy::list py_get_band(gdalwrap::gdal& self, const std::string& name) { return std_vector_to_py_list(self.get_band(name)); }
void save(const std::string& filepath) const { io.save(filepath); }
void save(const std::string& filepath) { dtm.save(filepath); }
const gdalwrap::raster& get_npointsmap() const { return dtm.get_band("N_POINTS"); }
/* getters */ const gdalwrap::raster& get_heightmap() const { return dtm.get_band("Z_MAX"); }
/** Get the index of the point in the raster * * @param p the point * * @returns the index of the point * */ size_t index( const point_xy_t& p ) const { return dtm.index_custom(p[0], p[1]); }
/** load region and robot model * * @param f_region path to a region.tif file * (multi-layers terrains classification probabilities, float32) * * @param f_robot_model path to a robot model * to generate the visibility map (at least its sensor height) * */ void load(const std::string& f_dtm, const std::string& f_robot_model) { dtm.load(f_dtm); rmdl.load(f_robot_model); _load(); }