├── .project
├── c
├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── src
│ ├── CMakeLists.txt
│ ├── bcal.c
│ ├── bcal_point.h
│ ├── bcal_types.h
│ ├── filter
│ │ ├── CMakeLists.txt
│ │ ├── bcal_bin.c
│ │ ├── bcal_filter.c
│ │ ├── bcal_filter.h
│ │ └── bcal_partition.c
│ └── sqlite
│ │ ├── CMakeLists.txt
│ │ ├── shell.c
│ │ ├── sqlite3.c
│ │ ├── sqlite3.h
│ │ └── sqlite3ext.h
└── test
│ ├── CMakeLists.txt
│ └── test_partition1.c
└── src
├── bcal_lidar_tools_envi52
├── LidarToolsHelp_BCAL.pro
├── bcal_lidar_tools_envi52.pro
├── bcal_lidar_tools_envi52.sav
├── bcal_lidar_tools_envi52_classic.pro
├── bcal_lidar_tools_envi52_classic.sav
├── lib
│ ├── GetBounds_BCAL.pro
│ ├── GetIndex_BCAL.pro
│ ├── GetUniqLAS_BCAL.pro
│ ├── InitDataLAS_BCAL.pro
│ ├── InitHeaderLAS_BCAL.pro
│ ├── InitRecordLAS_BCAL.pro
│ ├── ReadCommonHeaderLAS_BCAL.pro
│ ├── ReadHeaderLAS_BCAL.pro
│ ├── ReadLAS_BCAL.pro
│ ├── RecordsToProj_BCAL.pro
│ ├── ScalePoly_BCAL.pro
│ ├── WriteLAS_BCAL.pro
│ └── fsc
│ │ ├── normalize_BCAL.pro
│ │ └── xcolors_BCAL.pro
└── procedures
│ ├── AddProjectionLAS_BCAL.pro
│ ├── AsciiToLAS_BCAL.pro
│ ├── AssignColorLAS_BCAL.pro
│ ├── AssignVegHtLAS_BCAL.pro
│ ├── BoundLAS_BCAL.pro
│ ├── BufferLAS_BCAL.pro
│ ├── ChangeZUnitLAS_BCAL.pro
│ ├── DEMLAS_BCAL.pro
│ ├── DataInfoBatchLAS_BCAL.pro
│ ├── DataInfoLAS_BCAL.pro
│ ├── DecimateLAS_BCAL.pro
│ ├── DecimateLASdensity_BCAL.pro
│ ├── DecimateLASper_BCAL.pro
│ ├── ExportLAS_BCAL.pro
│ ├── FileInfoLAS_BCAL.pro
│ ├── FlightlineLAS_BCAL.pro
│ ├── HeightGroupsLAS_BCAL.pro
│ ├── HeightLAS_BCAL.pro
│ ├── IntensityMetrics_BCAL.pro
│ ├── LASToAscii_BCAL.pro
│ ├── LidarMetrics_BCAL.pro
│ ├── LidarRasterLAS_BCAL.pro
│ ├── NormalizeElevLAS_BCAL.pro
│ ├── PrepareLAS_BCAL.pro
│ ├── ReclassifyLAS_BCAL.pro
│ ├── ReprojectLAS_BCAL.pro
│ ├── ReturnsLAS_BCAL.pro
│ ├── SubsetLAS_BCAL.pro
│ ├── TileLAS_BCAL.pro
│ ├── TopoRasterAll_BCAL.pro
│ ├── TopoRasterBare_BCAL.pro
│ ├── TransectLAS_BCAL.pro
│ ├── VegMetrics_BCAL.pro
│ ├── Visualize3D_BCAL.pro
│ └── Wizard
│ ├── Wizard_BCAL.pro
│ ├── Wizard_Data_Input.pro
│ ├── Wizard_Data_Preprocess.pro
│ ├── Wizard_Generate_Data.pro
│ ├── Wizard_Generate_Data_Impl.pro
│ ├── Wizard_Height_Filtering.pro
│ ├── Wizard_Height_Filtering_Impl.pro
│ ├── Wizard_Intro.pro
│ └── Wizard_Utils.pro
├── bcal_lidar_tools_envi53
├── LidarToolsHelp_BCAL.pro
├── bcal_lidar_tools_envi53.pro
├── bcal_lidar_tools_envi53.sav
├── bcal_lidar_tools_envi53_classic.pro
├── bcal_lidar_tools_envi53_classic.sav
├── lib
│ ├── GetBounds_BCAL.pro
│ ├── GetIndex_BCAL.pro
│ ├── GetUniqLAS_BCAL.pro
│ ├── InitDataLAS_BCAL.pro
│ ├── InitHeaderLAS_BCAL.pro
│ ├── InitRecordLAS_BCAL.pro
│ ├── ReadCommonHeaderLAS_BCAL.pro
│ ├── ReadHeaderLAS_BCAL.pro
│ ├── ReadLAS_BCAL.pro
│ ├── RecordsToProj_BCAL.pro
│ ├── ScalePoly_BCAL.pro
│ ├── WriteLAS_BCAL.pro
│ └── fsc
│ │ ├── normalize_BCAL.pro
│ │ └── xcolors_BCAL.pro
└── procedures
│ ├── AddProjectionLAS_BCAL.pro
│ ├── AsciiToLAS_BCAL.pro
│ ├── AssignColorLAS_BCAL.pro
│ ├── AssignVegHtLAS_BCAL.pro
│ ├── BoundLAS_BCAL.pro
│ ├── BufferLAS_BCAL.pro
│ ├── ChangeZUnitLAS_BCAL.pro
│ ├── DEMLAS_BCAL.pro
│ ├── DataInfoBatchLAS_BCAL.pro
│ ├── DataInfoLAS_BCAL.pro
│ ├── DecimateLAS_BCAL.pro
│ ├── DecimateLASdensity_BCAL.pro
│ ├── DecimateLASper_BCAL.pro
│ ├── ExportLAS_BCAL.pro
│ ├── FileInfoLAS_BCAL.pro
│ ├── FlightlineLAS_BCAL.pro
│ ├── HeightGroupsLAS_BCAL.pro
│ ├── HeightLAS_BCAL.pro
│ ├── IntensityMetrics_BCAL.pro
│ ├── LASToAscii_BCAL.pro
│ ├── LidarMetrics_BCAL.pro
│ ├── LidarRasterLAS_BCAL.pro
│ ├── NormalizeElevLAS_BCAL.pro
│ ├── PrepareLAS_BCAL.pro
│ ├── ReclassifyLAS_BCAL.pro
│ ├── ReprojectLAS_BCAL.pro
│ ├── ReturnsLAS_BCAL.pro
│ ├── SubsetLAS_BCAL.pro
│ ├── TileLAS_BCAL.pro
│ ├── TopoRasterAll_BCAL.pro
│ ├── TopoRasterBare_BCAL.pro
│ ├── TransectLAS_BCAL.pro
│ ├── VegMetrics_BCAL.pro
│ ├── Visualize3D_BCAL.pro
│ └── Wizard
│ ├── Wizard_BCAL.pro
│ ├── Wizard_Data_Input.pro
│ ├── Wizard_Data_Preprocess.pro
│ ├── Wizard_Generate_Data.pro
│ ├── Wizard_Generate_Data_Impl.pro
│ ├── Wizard_Height_Filtering.pro
│ ├── Wizard_Height_Filtering_Impl.pro
│ ├── Wizard_Intro.pro
│ └── Wizard_Utils.pro
├── deprecated
├── LidarToolsHelp_BCAL.pro
├── LidarTools_BCAL.pro
├── LidarTools_BCAL_Envi4x.pro
├── LidarTools_BCAL_Envi5x.pro
├── lib
│ ├── GetBounds_BCAL.pro
│ ├── GetIndex_BCAL.pro
│ ├── GetUniqLAS_BCAL.pro
│ ├── InitDataLAS_BCAL.pro
│ ├── InitHeaderLAS_BCAL.pro
│ ├── InitRecordLAS_BCAL.pro
│ ├── ReadHeaderLAS_BCAL.pro
│ ├── ReadLAS_BCAL.pro
│ ├── RecordsToProj_BCAL.pro
│ ├── ScalePoly_BCAL.pro
│ ├── WriteLAS_BCAL.pro
│ └── fsc
│ │ ├── idlgrcolorbar__define.pro
│ │ ├── normalize_BCAL.pro
│ │ ├── trackball__define.pro
│ │ └── xcolors_BCAL.pro
└── procedures
│ ├── AddProjectionLAS_BCAL.pro
│ ├── AsciiToLAS_BCAL.pro
│ ├── AssignColorLAS_BCAL.pro
│ ├── BoundLAS_BCAL.pro
│ ├── BufferLAS_BCAL.pro
│ ├── DEMLAS_BCAL.pro
│ ├── DataInfoBatchLAS_BCAL.pro
│ ├── DataInfoLAS_BCAL.pro
│ ├── DecimateLAS_BCAL.pro
│ ├── DecimateLASdensity_BCAL.pro
│ ├── DecimateLASper_BCAL.pro
│ ├── ExportLAS_BCAL.pro
│ ├── FileInfoLAS_BCAL.pro
│ ├── FlightlineLAS_BCAL.pro
│ ├── HeightGroupsLAS_BCAL.pro
│ ├── HeightLAS_BCAL.pro
│ ├── IntensityMetrics_BCAL.pro
│ ├── LASToAscii_BCAL.pro
│ ├── LidarMetrics_BCAL.pro
│ ├── LidarRasterLAS_BCAL.pro
│ ├── PrepareLAS_BCAL.pro
│ ├── ReclassifyLAS_BCAL.pro
│ ├── ReprojectLAS_BCAL.pro
│ ├── ReturnsLAS_BCAL.pro
│ ├── SubsetLAS_BCAL.pro
│ ├── TileLAS_BCAL.pro
│ ├── TopoRasterAll_BCAL.pro
│ ├── TopoRasterBare_BCAL.pro
│ ├── TransectLAS_BCAL.pro
│ ├── VegMetrics_BCAL.pro
│ ├── Visualize3D_BCAL.pro
│ └── Wizard
│ ├── Wizard_BCAL.pro
│ ├── Wizard_Data_Input.pro
│ ├── Wizard_Data_Preprocess.pro
│ ├── Wizard_Generate_Data.pro
│ ├── Wizard_Generate_Data_Impl.pro
│ ├── Wizard_Height_Filtering.pro
│ ├── Wizard_Height_Filtering_Impl.pro
│ ├── Wizard_Intro.pro
│ └── Wizard_Utils.pro
└── notes.txt
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | LidarTools_BCAL
4 |
5 |
6 |
7 |
8 |
9 | com.rsi.idldt.core.IDLBuilder
10 |
11 |
12 |
13 |
14 |
15 | com.rsi.idldt.core.IDLNature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/c/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 |
--------------------------------------------------------------------------------
/c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Boise State University. All rights reserved.
2 | # Use of this source code is governed by a BSD-style
3 | # license that can be found in the LICENSE file.
4 |
5 | cmake_minimum_required(VERSION 2.8.8)
6 |
7 | project(bcal)
8 |
9 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
10 |
11 | if(NOT MSVC)
12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
13 | else(NOT MSVC)
14 | add_definitions(-D_CRT_SECURE_NO_WARNINGS)
15 | add_definitions(-D_SCL_SECURE_NO_WARNINGS)
16 | endif(NOT MSVC)
17 |
18 | include(FindGDAL)
19 | find_package(GDAL REQUIRED)
20 |
21 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
22 |
23 | add_subdirectory(src)
24 |
25 | include(CTest)
26 | enable_testing()
27 |
28 | if(BUILD_TESTING)
29 | add_subdirectory(test)
30 | endif(BUILD_TESTING)
31 |
32 | # CPack related
33 | include(InstallRequiredSystemLibraries)
34 |
35 | set(BCAL_NAME "bcal")
36 | set(BCAL_VERSION_MAJOR 0)
37 | set(BCAL_VERSION_MINOR 0)
38 | set(BCAL_VERSION_PATCH 0)
39 | set(BCAL_VERSION_NAME "bcal-${BCAL_VERSION_MAJOR}.${BCAL_VERSION_MINOR}.${BCAL_VERSION_PATCH}")
40 | set(BCAL_VERSION "${BCAL_VERSION_MAJOR}.${BCAL_VERSION_MINOR}.${BCAL_VERSION_PATCH}")
41 |
42 | if(CMAKE_BUILD_TYPE)
43 | string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
44 | else()
45 | set(BUILD_TYPE "debug")
46 | endif()
47 |
48 | # *****************************************************************************
49 | # CPack variables
50 | # *****************************************************************************
51 | if(WIN32)
52 | set(CPACK_NSIS_PACKAGE_NAME ${BCAL_VERSION_NAME})
53 | set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
54 | set(CPACK_VERSION_MAJOR ${BCAL_VERSION_MAJOR})
55 | set(CPACK_VERSION_MINOR ${BCAL_VERSION_MINOR})
56 | set(CPACK_VERSION_PATCH ${BCAL_VERSION_PATCH})
57 | set(CPACK_PACKAGE_VERSION ${BCAL_VERSION})
58 |
59 | set(CPACK_NSIS_INSTALL_ROOT "C:")
60 | cmake_policy(PUSH)
61 | cmake_policy(SET CMP0010 OLD)
62 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "${BCAL_NAME}\\\\${BCAL_VERSION_NAME}")
63 | set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${BCAL_NAME}\\\\${BCAL_VERSION_NAME}")
64 | cmake_policy(POP)
65 | set(CPACK_NSIS_DISPLAY_NAME "${BCAL_NAME}\\\\${BCAL_VERSION_NAME}")
66 |
67 | set(CPACK_CREATE_DESKTOP_LINKS ${BCAL_NAME})
68 | set(CPACK_NSIS_MODIFY_PATH ${BCAL_NAME})
69 |
70 | set(CPACK_PACKAGE_EXECUTABLES "bcal" ${BCAL_VERSION_NAME})
71 |
72 | get_filename_component(GDAL_INSTALL_PATH ${GDAL_LIBRARY} DIRECTORY)
73 | get_filename_component(GDAL_INSTALL_PATH ${GDAL_INSTALL_PATH} DIRECTORY)
74 | message(STATUS "Using ${GDAL_INSTALL_PATH} for GDAL_HOME")
75 |
76 | install(FILES ${PROJECT_SOURCE_DIR}/README.md DESTINATION doc)
77 |
78 | install(PROGRAMS "${GDAL_INSTALL_PATH}/bin/gdal200.dll" DESTINATION bin)
79 | install(PROGRAMS "${GDAL_INSTALL_PATH}/bin/gdal_translate.exe" DESTINATION bin)
80 | install(PROGRAMS "${GDAL_INSTALL_PATH}/bin/gdalbuildvrt.exe" DESTINATION bin)
81 | # gdal data
82 | endif(WIN32)
83 |
84 | Include(CPack)
85 |
86 |
--------------------------------------------------------------------------------
/c/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016, Boise State University
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | 3. Neither the name of the copyright holder nor the names of its contributors
15 | may be used to endorse or promote products derived from this software without
16 | specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
30 |
--------------------------------------------------------------------------------
/c/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Boise State University. All rights reserved.
2 | # Use of this source code is governed by a BSD-style
3 | # license that can be found in the LICENSE file.
4 |
5 | cmake_minimum_required(VERSION 2.8.8)
6 |
7 | include_directories(sqlite)
8 | include_directories(filter)
9 |
10 | add_subdirectory(sqlite)
11 | add_subdirectory(filter)
12 |
13 | add_executable(bcal bcal.c
14 | $)
15 |
16 | target_link_libraries(bcal ${GDAL_LIBRARY})
17 |
--------------------------------------------------------------------------------
/c/src/bcal.c:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | /*
6 | ** Main executable for the bcal lidar tools. See the corresponding folders for
7 | ** tool documentation (eg filter/ for the filter tool).
8 | */
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include "bcal_filter.h"
15 |
16 | void Usage()
17 | {
18 | printf(
19 | "bcal [options] arguments\n"
20 | "\n"
21 | " tools: filter\n" );
22 | exit(1);
23 | }
24 |
25 | int main( int argc, char *argv[] )
26 | {
27 | unsigned int i = 1;
28 | if( argc < 2 )
29 | {
30 | Usage();
31 | }
32 |
33 | if( strncmp( argv[i], "filter", strlen( "filter" ) ) == 0 )
34 | {
35 | return bcal_filter_app( argc, argv );
36 | }
37 | else
38 | {
39 | Usage();
40 | }
41 | i++;
42 | return 0;
43 | }
44 |
--------------------------------------------------------------------------------
/c/src/bcal_point.h:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #ifndef BCAL_POINT_H_
6 | #define BCAL_POINT_H_
7 |
8 | #include "bcal_types.h"
9 |
10 | typedef struct bcal_point bcal_point;
11 | struct bcal_point
12 | {
13 | int64 fid;
14 | double x;
15 | double y;
16 | double z;
17 | uint8 c;
18 | uint8 h;
19 |
20 | uint32 bin;
21 | };
22 |
23 | #endif /* BCAL_POINT_H_ */
24 |
25 |
--------------------------------------------------------------------------------
/c/src/bcal_types.h:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 |
6 |
7 | #ifndef BCAL_TYPES_H_
8 | #define BCAL_TYPES_H_
9 |
10 | #include
11 | typedef int8_t int8;
12 | typedef uint8_t uint8;
13 | typedef int16_t int16;
14 | typedef uint16_t uint16;
15 | typedef int32_t int32;
16 | typedef uint32_t uint32;
17 | typedef int64_t int64;
18 | typedef uint64_t uint64;
19 |
20 | #endif /* BCAL_TYPES_H_ */
21 |
22 |
--------------------------------------------------------------------------------
/c/src/filter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Boise State University. All rights reserved.
2 | # Use of this source code is governed by a BSD-style
3 | # license that can be found in the LICENSE file.
4 |
5 | cmake_minimum_required(VERSION 2.8.8)
6 |
7 | include_directories(${PROJECT_SOURCE_DIR}/src
8 | ${GDAL_INCLUDE_DIR})
9 | set(bcal_filter_src bcal_bin.c
10 | bcal_filter.c
11 | bcal_partition.c)
12 |
13 | add_library(filter OBJECT ${bcal_filter_src})
14 |
15 |
--------------------------------------------------------------------------------
/c/src/filter/bcal_bin.c:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | /*
6 | ** bin cycles through and assigns a bin based on a canopy spacing. The bin
7 | ** value is stored in each point, then the points are sorted by bin.
8 | */
9 |
10 | #include "bcal_filter.h"
11 |
12 | static int compare( const void *a, const void *b )
13 | {
14 | return ((bcal_point*)a)->bin - ((bcal_point*)b)->bin;
15 | }
16 |
17 | CPLErr bcal_bin( bcal_working_set *s )
18 | {
19 | CPLDebug( "BCAL", "Sorting points into bins for initial ground classification." );
20 | double dx, dy;
21 | dx = s->env.MaxX - s->env.MinX;
22 | dy = s->env.MaxY - s->env.MinY;
23 | uint32 nx = (dx / s->spacing) + 1;
24 | uint32 ny = (dy / s->spacing) + 1;
25 | uint32 i;
26 | uint32 x, y;
27 | for( i = 0; i < s->n; i++ )
28 | {
29 | x = (s->p[i].x - s->env.MinX) / s->spacing;
30 | y = (s->env.MaxY - s->p[i].y) / s->spacing;
31 | s->p[i].bin = y * nx + x;
32 | }
33 | qsort( s->p, s->n, sizeof( bcal_point ), *compare );
34 | return CE_None;
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/c/src/filter/bcal_filter.h:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #ifndef BCAL_FILTER_H_
6 | #define BCAL_FILTER_H_
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #include "bcal_point.h"
13 | #include "bcal_types.h"
14 |
15 | #include
16 |
17 | typedef OGREnvelope bcal_env;
18 |
19 | typedef struct bcal_filter_data
20 | {
21 | char *input;
22 | char *output;
23 | int jobs;
24 | double merge_buf;
25 | double spacing;
26 | } bcal_filter_data;
27 |
28 | typedef struct bcal_domain
29 | {
30 | bcal_env env;
31 | bcal_env *sub_envs;
32 | uint32 n;
33 | } bcal_domain;
34 |
35 | typedef struct bcal_decomposition
36 | {
37 | uint32 n;
38 | bcal_env *envs;
39 | } bcal_decomposition;
40 |
41 | typedef struct bcal_working_set
42 | {
43 | uint32 n;
44 | bcal_env env;
45 | bcal_point *p;
46 | double spacing;
47 | } bcal_working_set;
48 |
49 | int bcal_filter_app( int argc, char *argv[] );
50 |
51 | CPLErr bcal_filter( bcal_filter_data *b);
52 |
53 | CPLErr bcal_partition( bcal_domain *d, uint32 jobs );
54 |
55 | CPLErr bcal_bin( bcal_working_set *s );
56 |
57 | #endif /* BCAL_FILTER_H_ */
58 |
59 |
--------------------------------------------------------------------------------
/c/src/filter/bcal_partition.c:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "bcal_filter.h"
6 | #include "bcal_point.h"
7 |
8 | #include "gdal.h"
9 | #include "cpl_conv.h"
10 |
11 | /*
12 | ** bcal_partiiton partitions a domain into tiles. These tiles will be spread
13 | ** over threads to do work.
14 | */
15 | CPLErr bcal_partition( bcal_domain *d, uint32 jobs )
16 | {
17 | if( d == NULL )
18 | {
19 | return CE_Failure;
20 | }
21 | if( jobs == 1 )
22 | {
23 | d->sub_envs = malloc( sizeof( OGREnvelope ) );
24 | d->sub_envs[0] = d->env;
25 | d->n = 1;
26 | return CE_None;
27 | }
28 | uint32 env_count = 0;
29 | while( env_count * env_count < jobs )
30 | {
31 | env_count++;
32 | }
33 | uint32 ec2 = env_count * env_count;
34 | CPLDebug( "BCAL", "partitioning domain into %d fields", env_count );
35 | double x, y;
36 | double dx, dy;
37 | x = d->env.MinX;
38 | y = d->env.MaxY;
39 | dx = (d->env.MaxX - d->env.MinX) / (double)env_count;
40 | dy = (d->env.MaxY - d->env.MinY) / (double)env_count;
41 | CPLDebug( "BCAL", "using dx:%lf and dy:%lf to build grid", dx, dy );
42 | d->sub_envs = malloc( sizeof( bcal_env ) * ec2 );
43 | d->n = ec2;
44 | int i, j, k;
45 | for( i = 0; i < env_count; i++ )
46 | {
47 | for( j = 0; j < env_count; j++ )
48 | {
49 | d->sub_envs[i+j].MinX = x + dx * j;
50 | d->sub_envs[i+j].MaxX = x + (dx * (j + 1));
51 | d->sub_envs[i+j].MaxY = y + dy * i;
52 | d->sub_envs[i+j].MinY = y - (dy * (j + 1));
53 | CPLDebug( "BCAL", "using envelope:{%lf,%lf,%lf,%lf} for grid",
54 | d->sub_envs[i].MinX, d->sub_envs[i].MaxX,
55 | d->sub_envs[i].MinY, d->sub_envs[i].MinY );
56 | }
57 | }
58 | return CE_None;
59 | }
60 |
61 | void bcal_free_decomp( bcal_domain *d )
62 | {
63 | free( d->sub_envs );
64 | d->sub_envs = NULL;
65 | }
66 |
--------------------------------------------------------------------------------
/c/src/sqlite/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Boise State University. All rights reserved.
2 | # Use of this source code is governed by a BSD-style
3 | # license that can be found in the LICENSE file.
4 |
5 | cmake_minimum_required(VERSION 2.8.8)
6 |
7 | add_library(sqlite OBJECT sqlite3.c)
8 |
9 |
--------------------------------------------------------------------------------
/c/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Boise State University. All rights reserved.
2 | # Use of this source code is governed by a BSD-style
3 | # license that can be found in the LICENSE file.
4 |
5 | cmake_minimum_required(VERSION 2.8.8)
6 |
7 |
8 | include_directories(${PROJECT_SOURCE_DIR}/src
9 | ${PROJECT_SOURCE_DIR}/src/filter
10 | ${GDAL_INCLUDE_DIR})
11 |
12 | #set(bcal_objects
13 |
14 | file(GLOB ctests ${PROJECT_SOURCE_DIR}/test/*.c)
15 | foreach(ctest ${ctests})
16 | get_filename_component(base ${ctest} NAME_WE)
17 | add_executable(${base} ${ctest} $)
18 | target_link_libraries(${base} ${GDAL_LIBRARY})
19 | add_test(${base} ${base})
20 | endforeach(ctest ${ctests})
21 |
22 |
--------------------------------------------------------------------------------
/c/test/test_partition1.c:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Boise State University. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "bcal_filter.h"
6 |
7 | int main()
8 | {
9 | OGREnvelope env;
10 | bcal_domain d;
11 | d.env.MinX = 0.;
12 | d.env.MaxX = 10.;
13 | d.env.MinY = 0.;
14 | d.env.MaxY = 10.;
15 | CPLErr e = bcal_partition( &d, 4 );
16 | if( e != CE_None )
17 | {
18 | return 1;
19 | }
20 | if( d.n != 4 )
21 | {
22 | return 1;
23 | }
24 | if( !CPLIsEqual( d.sub_envs[0].MinX, 0. ) ||
25 | !CPLIsEqual( d.sub_envs[0].MaxX, 5. ) ||
26 | !CPLIsEqual( d.sub_envs[0].MinY, 5. ) ||
27 | !CPLIsEqual( d.sub_envs[0].MaxY, 10. ) )
28 | {
29 | return 1;
30 | }
31 | bcal_free_decomp( &d );
32 | return 0;
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/LidarToolsHelp_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
; NAME:
;
; LiDARToolsHelp_BCAL
;
; PURPOSE:
;
; The purpose of this program is to display help file for the LiDAR Tools
;
; PRODUCTS:
;
;
; AUTHOR:
;
; Rupesh Shrestha
; Boise Center Aerospace Laboratory
; Idaho State University
; 322 E. Front St., Ste. 240
; Boise, ID 83702
; http://bcal.geology.isu.edu/
;
; DEPENDENCIES:
;
;
; MODIFICATION HISTORY:
;
; Written by Rupesh Shrestha, August 2010.
; Changed online help from HTML to PDF for cross-platform compatibility
; and easier maintenance.
;
;###########################################################################
;
; LICENSE
;
; This software is OSI Certified Open Source Software.
; OSI Certified is a certification mark of the Open Source Initiative.
;
; Copyright @ 2010 Rupesh Shrestha, Idaho State University.
;
; This software is provided "as-is", without any express or
; implied warranty. In no event will the authors be held liable
; for any damages arising from the use of this software.
;
; Permission is granted to anyone to use this software for any
; purpose, including commercial applications, and to alter it and
; redistribute it freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must
; not claim you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation
; would be appreciated, but is not required.
;
; 2. Altered source versions must be plainly marked as such, and must
; not be misrepresented as being the original software.
;
; 3. This notice may not be removed or altered from any source distribution.
;
; For more information on Open Source Software, visit the Open Source
; web site: http://www.opensource.org.
;
;###########################################################################
; Begin main program
pro LiDARToolsHelp_BCAL, event
compile_opt idl2
widget_control, event.id, get_uvalue=helpAbout
case helpAbout of
'LiDARToolsHelp': begin
oJavaDesktop = OBJ_NEW('IDLJavaObject$Static$JAVA_AWT_DESKTOP', $
'java.awt.Desktop')
oJavaURI = OBJ_NEW('IDLJavaObject$JAVA_NET_URI', 'java.net.URI', $
'https://github.com/bcal-lidar/tools/wiki')
if (oJavaDesktop->isDesktopSupported()) then begin
oBrowser = oJavaDesktop->getDesktop()
oBrowser->browse,oJavaURI
OBJ_DESTROY, oBrowser
endif
OBJ_DESTROY, oJavaURI, oJavaDesktop
end
'LiDARToolsUpdates': begin
oJavaDesktop = OBJ_NEW('IDLJavaObject$Static$JAVA_AWT_DESKTOP', $
'java.awt.Desktop')
oJavaURI = OBJ_NEW('IDLJavaObject$JAVA_NET_URI', 'java.net.URI', $
'https://bcal.boisestate.edu/tools/lidar')
if (oJavaDesktop->isDesktopSupported()) then begin
oBrowser = oJavaDesktop->getDesktop()
oBrowser->browse,oJavaURI
OBJ_DESTROY, oBrowser
endif
OBJ_DESTROY, oJavaURI, oJavaDesktop
end
'AboutLiDARTools': begin
envi_center, xoff, yoff
widget_control, event.top, get_uvalue = info
aboutBase = widget_base(Title = 'About', /col, xoffset = xoff, $
yoffset = yoff, xsize=250)
dummy = widget_label(aboutBase, value='', /align_center)
dummy = widget_label(aboutBase, value='BCAL LiDAR Tools 5.3', /align_center)
dummy = widget_label(aboutBase, value='Boise Center for Aerospace Laboratory', /align_center)
dummy = widget_label(aboutBase, value='Boise State University', /align_center)
dummy = widget_label(aboutBase, value='1910 University Dr, Boise, Idaho', /align_center)
dummy = widget_label(aboutBase, value='bcal@boisestate.edu', /align_center)
dummy = widget_label(aboutBase, value='', /align_center)
widget_control, aboutBase, /realize
end
endcase
end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/bcal_lidar_tools_envi52.sav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcal-lidar/tools/b4f976f922ca3b021a40946ab6da35b8f21da3a3/src/bcal_lidar_tools_envi52/bcal_lidar_tools_envi52.sav
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/bcal_lidar_tools_envi52_classic.sav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcal-lidar/tools/b4f976f922ca3b021a40946ab6da35b8f21da3a3/src/bcal_lidar_tools_envi52/bcal_lidar_tools_envi52_classic.sav
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/GetIndex_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; GetIndex_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function is used for "index chunking", in combination with the output of
9 | ; the REVERSE_INDICES keyword of the HISTOGRAM function. For a given array element
10 | ; and search radius, the function returns all indices within those elements.
11 | ;
12 | ; AUTHOR:
13 | ;
14 | ; David Streutker
15 | ; Boise Center Aerospace Laboratory
16 | ; Idaho State University
17 | ; 322 E. Front St., Ste. 240
18 | ; Boise, ID 83702
19 | ; http://geology.isu.edu/BCAL
20 | ;
21 | ; CALLING SEQUENCE:
22 | ;
23 | ; index = GetIndex_BCAL(I,J,xDim,yDim,ArrayIndex,Factor)
24 | ;
25 | ; I and J are the coordinates within the array, xDim and yDim are the dimensions of
26 | ; the array, ArrayIndex is the output of the REVERSE_INDICES keyword of the HISTOGRAM
27 | ; function, and Factor is the search radius. (Factor = 0 searches the single element,
28 | ; Factor = 1 searches the nine-element neighborhood, and so on.)
29 | ;
30 | ; RETURN VALUE:
31 | ;
32 | ; The function returns the indices corresponding to the specified element and the
33 | ; elements within the radius specified by the value of Factor.
34 | ;
35 | ; If no indices are found, the function returns a value of -1.
36 | ;
37 | ; KNOWN ISSUES:
38 | ;
39 | ; None.
40 | ;
41 | ; MODIFICATION HISTORY:
42 | ;
43 | ; Written by David Streutker, March 2006.
44 | ;
45 | ;###########################################################################
46 | ;
47 | ; LICENSE
48 | ;
49 | ; This software is OSI Certified Open Source Software.
50 | ; OSI Certified is a certification mark of the Open Source Initiative.
51 | ;
52 | ; Copyright � 2006 David Streutker, Idaho State University.
53 | ;
54 | ; This software is provided "as-is", without any express or
55 | ; implied warranty. In no event will the authors be held liable
56 | ; for any damages arising from the use of this software.
57 | ;
58 | ; Permission is granted to anyone to use this software for any
59 | ; purpose, including commercial applications, and to alter it and
60 | ; redistribute it freely, subject to the following restrictions:
61 | ;
62 | ; 1. The origin of this software must not be misrepresented; you must
63 | ; not claim you wrote the original software. If you use this software
64 | ; in a product, an acknowledgment in the product documentation
65 | ; would be appreciated, but is not required.
66 | ;
67 | ; 2. Altered source versions must be plainly marked as such, and must
68 | ; not be misrepresented as being the original software.
69 | ;
70 | ; 3. This notice may not be removed or altered from any source distribution.
71 | ;
72 | ; For more information on Open Source Software, visit the Open Source
73 | ; web site: http://www.opensource.org.
74 | ;
75 | ;###########################################################################
76 |
77 | function GetIndex_BCAL, i, j, xDim, yDim, arrayIndex, factor
78 |
79 | compile_opt idl2, logical_predicate
80 |
81 | ; Convert the two-dimensional array coordinates to a one-dimensional coordinate.
82 |
83 | k = j * xDim + i
84 |
85 | ; Set initial return value
86 |
87 | index = -1
88 |
89 | if ((factor eq 0) and (arrayIndex[k] ne arrayIndex[k+1])) then $
90 |
91 | ; If no expansion is needed, simply get the indices
92 |
93 | index = arrayIndex[arrayIndex[k]:arrayIndex[k+1]-1] $
94 |
95 | else begin
96 |
97 | doInd = 0
98 |
99 | ; If an expansion is needed, get the expanded coordinates.
100 |
101 | iStart = (i - factor) > 0
102 | iEnd = (i + factor) < (xDim - 1)
103 | iEnd += 1
104 |
105 | jStart = (j - factor) > 0
106 | jEnd = (j + factor) < (yDim - 1)
107 |
108 | ; Convert the 2D coordiates to 1D coordinates.
109 |
110 | jRange = jEnd - jStart
111 | kStart = (jStart + lindgen(jRange + 1)) * xDim
112 |
113 | kEnd = kStart + iEnd
114 | kStart = kStart + iStart
115 |
116 | for a=0,jRange do begin
117 |
118 | ; If they exist, get all the corresponding indices.
119 |
120 | if arrayIndex[kStart[a]] ne arrayIndex[kEnd[a]] then begin
121 |
122 | index = [index,arrayIndex[arrayIndex[kStart[a]]:arrayIndex[kEnd[a]]-1]]
123 | doInd = 1
124 |
125 | endif
126 |
127 | endfor
128 |
129 | ; If indices were found, remove the first, '-1' element.
130 |
131 | if doInd then index = index[1:*]
132 |
133 | endelse
134 |
135 | return, index
136 |
137 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/GetUniqLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; GetUniqLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function is used to remove points in the LAS file that have same
9 | ; coordinates.
10 | ;
11 | ; AUTHOR:
12 | ;
13 | ; David Streutker
14 | ; Boise Center Aerospace Laboratory
15 | ; Idaho State University
16 | ; 322 E. Front St., Ste. 240
17 | ; Boise, ID 83702
18 | ; http://bcal.geology.isu.edu
19 | ;
20 | ; CALLING SEQUENCE:
21 | ;
22 | ; index = GetUniqLAS_BCAL(header, data)
23 | ;
24 | ; 'header' are the LAS file header obtained using ReadHeaderLAS_BCAL, and 'data'
25 | ; are LAS file data obtained by ReadLAS_BCAL procedures.
26 | ;
27 | ; RETURN VALUE:
28 | ;
29 | ; The function returns the LAS header and data for points with only unique
30 | ; coordinates
31 | ;
32 | ; KNOWN ISSUES:
33 | ;
34 | ; None.
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, March 2006.
39 | ;
40 | ;###########################################################################
41 | ;
42 | ; LICENSE
43 | ;
44 | ; This software is OSI Certified Open Source Software.
45 | ; OSI Certified is a certification mark of the Open Source Initiative.
46 | ;
47 | ; Copyright @ 2006 David Streutker, Idaho State University.
48 | ;
49 | ; This software is provided "as-is", without any express or
50 | ; implied warranty. In no event will the authors be held liable
51 | ; for any damages arising from the use of this software.
52 | ;
53 | ; Permission is granted to anyone to use this software for any
54 | ; purpose, including commercial applications, and to alter it and
55 | ; redistribute it freely, subject to the following restrictions:
56 | ;
57 | ; 1. The origin of this software must not be misrepresented; you must
58 | ; not claim you wrote the original software. If you use this software
59 | ; in a product, an acknowledgment in the product documentation
60 | ; would be appreciated, but is not required.
61 | ;
62 | ; 2. Altered source versions must be plainly marked as such, and must
63 | ; not be misrepresented as being the original software.
64 | ;
65 | ; 3. This notice may not be removed or altered from any source distribution.
66 | ;
67 | ; For more information on Open Source Software, visit the Open Source
68 | ; web site: http://www.opensource.org.
69 | ;
70 | ;###########################################################################
71 |
72 | pro GetUniqLAS_BCAL, header, data
73 |
74 | compile_opt idl2, logical_predicate
75 |
76 | xMax = max(data.east, min=xMin)
77 | yMax = max(data.north, min=yMin)
78 | zMin = min(data.elev)
79 |
80 | eastRange = ulong64(xMax - xMin)
81 | northRange = ulong64(yMax - yMin)
82 |
83 | uniqCoords = eastRange * northRange * (data.elev - zMin) $
84 | + eastRange * (data.north - yMin) $
85 | + (data.east - xMin)
86 |
87 | uniqCoords = uniq(uniqCoords, sort(uniqCoords))
88 |
89 | nUniq = n_elements(uniqCoords)
90 |
91 | if nUniq ne header.nPoints then begin
92 |
93 | data = data[uniqCoords]
94 |
95 | header.nPoints = nUniq
96 |
97 | endif
98 |
99 |
100 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/InitRecordLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; InitRecordLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read a variable length record from an .las
9 | ; lidar file.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; David Streutker
16 | ; Boise Center Aerospace Laboratory
17 | ; Idaho State University
18 | ; 322 E. Front St., Ste. 240
19 | ; Boise, ID 83702
20 | ; http://bcal.geology.isu.edu
21 | ;
22 | ; CALLING SEQUENCE:
23 | ;
24 | ; record = InitRecordLAS(NODATA=NODATA, versionMajor=versionMajor, versionMinor=versionMinor)
25 | ;
26 | ; RETURN VALUE:
27 | ;
28 | ; The function returns a structure corresponding to the variable length record of the .las
29 | ; file specification. Set the NODATA keyword to return a structure that does not contain
30 | ; the data pointer.
31 | ;
32 | ; MODIFICATION HISTORY:
33 | ;
34 | ; Written by David Streutker, July 2007.
35 | ; Added version keywords to handle LAS 1.4, April 2016
36 | ;
37 | ;###########################################################################
38 | ;
39 | ; LICENSE
40 | ;
41 | ; This software is OSI Certified Open Source Software.
42 | ; OSI Certified is a certification mark of the Open Source Initiative.
43 | ;
44 | ; Copyright � 2007 David Streutker, Idaho State University.
45 | ;
46 | ; This software is provided "as-is", without any express or
47 | ; implied warranty. In no event will the authors be held liable
48 | ; for any damages arising from the use of this software.
49 | ;
50 | ; Permission is granted to anyone to use this software for any
51 | ; purpose, including commercial applications, and to alter it and
52 | ; redistribute it freely, subject to the following restrictions:
53 | ;
54 | ; 1. The origin of this software must not be misrepresented; you must
55 | ; not claim you wrote the original software. If you use this software
56 | ; in a product, an acknowledgment in the product documentation
57 | ; would be appreciated, but is not required.
58 | ;
59 | ; 2. Altered source versions must be plainly marked as such, and must
60 | ; not be misrepresented as being the original software.
61 | ;
62 | ; 3. This notice may not be removed or altered from any source distribution.
63 | ;
64 | ; For more information on Open Source Software, visit the Open Source
65 | ; web site: http://www.opensource.org.
66 | ;
67 | ;###########################################################################
68 |
69 | function InitRecordLAS_BCAL, noData = noData, versionMajor=versionMajor, versionMinor=versionMinor
70 |
71 | compile_opt idl2, logical_predicate
72 |
73 | ; Define the variable length header structure
74 |
75 | record = {formatR0, $
76 | signature : 0US, $ ; Record signature
77 | userID : bytarr(16), $ ; User ID
78 | recordID : 0US, $ ; Record ID
79 | recordLength : 0US, $ ; Record length after header
80 | description : bytarr(32) $ ; Description
81 | }
82 |
83 | if ~ keyword_set(noData) then record = {formatR1, inherits formatR0, data : ptr_new(/allocate)} ; Data pointer
84 |
85 | if (N_Elements(versionMajor) && N_Elements(versionMior)) then begin
86 |
87 | ; If LAS 1.4, define the variable length header structure differently
88 |
89 | if (versionMajor eq 1) && (versionMinor eq 4) then begin
90 | record = {formatR14, $
91 | signature : 0US, $ ; Record signature
92 | userID : bytarr(16), $ ; User ID
93 | recordID : 0US, $ ; Record ID
94 | recordLength : 0ULL, $ ; Record length after header
95 | description : bytarr(32) $ ; Description
96 | }
97 |
98 | if ~ keyword_set(noData) then record = {formatR14n, inherits formatR14, data : ptr_new(/allocate)} ; Data pointer
99 | endif
100 |
101 | endif
102 |
103 | return, record
104 |
105 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/ReadCommonHeaderLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReadCommonHeaderLAS
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read some begining part in the header of a .las
9 | ; lidar file, which is in a common format for versions 1.2 and up.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; Exelis VIS
16 | ;
17 | ; CALLING SEQUENCE:
18 | ;
19 | ; commonHeader = ReadCommonHeaderLAS(lasFile)
20 | ;
21 | ; RETURN VALUE:
22 | ;
23 | ; The function returns a structure corresponding to items from File Signature to Header Size in the header of a .las file.
24 | ;
25 | ; KNOWN ISSUES:
26 | ;
27 | ; None.
28 | ;
29 | ; MODIFICATION HISTORY:
30 | ;
31 | ; Written by Exelis VIS, April, 2016.
32 | ;
33 | ;###########################################################################
34 | ;
35 | ; LICENSE
36 | ;
37 | ; This software is OSI Certified Open Source Software.
38 | ; OSI Certified is a certification mark of the Open Source Initiative.
39 | ;
40 | ; Copyright � 2006 David Streutker, Idaho State University.
41 | ;
42 | ; This software is provided "as-is", without any express or
43 | ; implied warranty. In no event will the authors be held liable
44 | ; for any damages arising from the use of this software.
45 | ;
46 | ; Permission is granted to anyone to use this software for any
47 | ; purpose, including commercial applications, and to alter it and
48 | ; redistribute it freely, subject to the following restrictions:
49 | ;
50 | ; 1. The origin of this software must not be misrepresented; you must
51 | ; not claim you wrote the original software. If you use this software
52 | ; in a product, an acknowledgment in the product documentation
53 | ; would be appreciated, but is not required.
54 | ;
55 | ; 2. Altered source versions must be plainly marked as such, and must
56 | ; not be misrepresented as being the original software.
57 | ;
58 | ; 3. This notice may not be removed or altered from any source distribution.
59 | ;
60 | ; For more information on Open Source Software, visit the Open Source
61 | ; web site: http://www.opensource.org.
62 | ;
63 | ;###########################################################################
64 |
65 | function ReadCommonHeaderLAS_BCAL, inputFile
66 |
67 | compile_opt idl2, logical_predicate
68 |
69 | ; Define the public header structure
70 |
71 | header = { $
72 | signature : byte('LASF'), $ ; File signature
73 | fileSource : 0US, $ ; File source ID
74 | reserved : 0US, $ ; Reserved
75 | guid1 : 0UL, $ ; Project ID - GUID data 1
76 | guid2 : 0US, $ ; Project ID - GUID data 2
77 | guid3 : 0US, $ ; Project ID - GUID data 3
78 | guid4 : bytarr(8), $ ; Project ID - GUID data 4
79 | versionMajor : 1B, $ ; Version major
80 | versionMinor : 1B, $ ; Version minor
81 | systemID : bytarr(32), $ ; System identifier
82 | softwareID : bytarr(32), $ ; Generating software
83 | day : 0US, $ ; File creation day of year
84 | year : 0US, $ ; File creation year
85 | headerSize : 227US $ ; Header size
86 | }
87 |
88 | ; Open the file and read the common header parts from it
89 |
90 | openr, inputLun, inputFile, /get_lun, /swap_if_big_endian
91 | readu, inputLun, header
92 | free_lun, inputLun
93 | return, header
94 |
95 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/ReadHeaderLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReadHeaderLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This program reads the header from the specified .las file.
9 | ;
10 | ; For more information on the .las lidar data format, see http://www.lasformat.org
11 | ;
12 | ; AUTHOR:
13 | ;
14 | ; David Streutker
15 | ; Boise Center Aerospace Laboratory
16 | ; Idaho State University
17 | ; 322 E. Front St., Ste. 240
18 | ; Boise, ID 83702
19 | ; http://bcal.geology.isu.edu
20 | ;
21 | ; CALLING SEQUENCE:
22 | ;
23 | ; ReadHeaderLAS, inputFile, header
24 | ;
25 | ; InputFile is the name of the requested .las file.
26 | ;
27 | ; RETURN VALUE:
28 | ;
29 | ; The program returns a structure containing the header information from the
30 | ; specified .las file.
31 | ;
32 | ; KNOWN ISSUES:
33 | ;
34 | ; None.
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, March 2006.
39 | ; Changed CLOSE command to FREE_LUN, April 2006 (DRS)
40 | ; Replaced by NODATA keyword in ReadLAS_BCAL.pro, June 2007
41 | ; Modified to handle LAS 1.3 and 1.4, April 2016
42 | ;
43 | ;###########################################################################
44 | ;
45 | ; LICENSE
46 | ;
47 | ; This software is OSI Certified Open Source Software.
48 | ; OSI Certified is a certification mark of the Open Source Initiative.
49 | ;
50 | ; Copyright � 2006 David Streutker, Idaho State University.
51 | ;
52 | ; This software is provided "as-is", without any express or
53 | ; implied warranty. In no event will the authors be held liable
54 | ; for any damages arising from the use of this software.
55 | ;
56 | ; Permission is granted to anyone to use this software for any
57 | ; purpose, including commercial applications, and to alter it and
58 | ; redistribute it freely, subject to the following restrictions:
59 | ;
60 | ; 1. The origin of this software must not be misrepresented; you must
61 | ; not claim you wrote the original software. If you use this software
62 | ; in a product, an acknowledgment in the product documentation
63 | ; would be appreciated, but is not required.
64 | ;
65 | ; 2. Altered source versions must be plainly marked as such, and must
66 | ; not be misrepresented as being the original software.
67 | ;
68 | ; 3. This notice may not be removed or altered from any source distribution.
69 | ;
70 | ; For more information on Open Source Software, visit the Open Source
71 | ; web site: http://www.opensource.org.
72 | ;
73 | ;###########################################################################
74 |
75 | pro ReadHeaderLAS_BCAL, inputFile, header
76 |
77 | compile_opt idl2, logical_predicate
78 |
79 | ; Create the header structure
80 |
81 | commonHeader = ReadCommonHeaderLAS_BCAL(inputFile)
82 | header = InitHeaderLAS_BCAL(versionMajor=commonHeader.versionMajor, versionMinor=commonHeader.versionMinor)
83 |
84 | ; Open the file and read the header from it
85 |
86 | openr, inputLun, inputFile, /get_lun, /swap_if_big_endian
87 | readu, inputLun, header
88 | free_lun, inputLun
89 |
90 |
91 |
92 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/ScalePoly_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ScalePoly_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function scales a polygon by the requested amount.
9 | ;
10 | ; AUTHOR:
11 | ;
12 | ; David Streutker
13 | ; Boise Center Aerospace Laboratory
14 | ; Idaho State University
15 | ; 322 E. Front St., Ste. 240
16 | ; Boise, ID 83702
17 | ; http://bcal.geology.isu.edu
18 | ;
19 | ; CALLING SEQUENCE:
20 | ;
21 | ; result = ScalePoly(Coordinates,Factor)
22 | ;
23 | ; RETURN VALUE:
24 | ;
25 | ; The function returns the coordinates scaled by the factor amount.
26 | ;
27 | ; Coordinates is a [2,n] array of polygon coordinates. Factor is the value by which
28 | ; the coordinates are scaled. Factor can be vector to scale the polygon differently in
29 | ; each direction. Positive values of Factor increase the size of the polygon, while
30 | ; negative values decrease it.
31 | ;
32 | ; DEPENDENCIES:
33 | ;
34 | ; GetBounds_BCAL.pro
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, June 2006.
39 | ;
40 | ;###########################################################################
41 | ;
42 | ; LICENSE
43 | ;
44 | ; This software is OSI Certified Open Source Software.
45 | ; OSI Certified is a certification mark of the Open Source Initiative.
46 | ;
47 | ; Copyright @ 2006 David Streutker, Idaho State University.
48 | ;
49 | ; This software is provided "as-is", without any express or
50 | ; implied warranty. In no event will the authors be held liable
51 | ; for any damages arising from the use of this software.
52 | ;
53 | ; Permission is granted to anyone to use this software for any
54 | ; purpose, including commercial applications, and to alter it and
55 | ; redistribute it freely, subject to the following restrictions:
56 | ;
57 | ; 1. The origin of this software must not be misrepresented; you must
58 | ; not claim you wrote the original software. If you use this software
59 | ; in a product, an acknowledgment in the product documentation
60 | ; would be appreciated, but is not required.
61 | ;
62 | ; 2. Altered source versions must be plainly marked as such, and must
63 | ; not be misrepresented as being the original software.
64 | ;
65 | ; 3. This notice may not be removed or altered from any source distribution.
66 | ;
67 | ; For more information on Open Source Software, visit the Open Source
68 | ; web site: http://www.opensource.org.
69 | ;
70 | ;###########################################################################
71 |
72 |
73 | function ScalePoly_BCAL, coords, d
74 |
75 | compile_opt idl2, logical_predicate
76 |
77 | ; Check whether the scale factor is one or two elements.
78 |
79 | if n_elements(d) eq 1 then d = [d,d]
80 |
81 | ; Get the x and y values of the coordinates and determine the mid-points and the ranges.
82 |
83 | x = coords[0,*]
84 | y = coords[1,*]
85 |
86 | xRange = max(x) - min(x)
87 | yRange = max(y) - min(y)
88 |
89 | xMid = (max(x) + min(x)) / 2
90 | yMid = (max(y) + min(y)) / 2
91 |
92 | ; Determine if the points are on the positive or negative side of the mid-points.
93 |
94 | xPos = where(x gt xMid, complement=xNeg)
95 | yPos = where(y gt yMid, complement=yNeg)
96 |
97 | ; Make sure the polygon is larger than the amount by which it is to be scaled. (This
98 | ; only applies for a negative scaling.)
99 |
100 | if xRange gt (-2)*d[0] then begin
101 |
102 | ; Scale the x coordinates
103 |
104 | x[xPos] = x[xPos] + d[0]
105 | x[xNeg] = x[xNeg] - d[0]
106 |
107 | endif
108 |
109 | if yRange gt (-2)*d[1] then begin
110 |
111 | ; Scale the y coordinates
112 |
113 | y[yPos] = y[yPos] + d[1]
114 | y[yNeg] = y[yNeg] - d[1]
115 |
116 | endif
117 |
118 | ; Call GetBounds_BCAL to eliminate any redundant points.
119 |
120 | bounds = GetBounds_BCAL(x,y)
121 | bounds = transpose(bounds)
122 |
123 | ; Return the new coordinates.
124 |
125 | return, [x[bounds],y[bounds]]
126 |
127 | end
128 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/lib/fsc/normalize_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ; NORMALIZE
4 | ;
5 | ; PURPOSE:
6 | ;
7 | ; This is a utility routine to calculate the scaling vector
8 | ; required to position a graphics primitive of specified range
9 | ; at a specific position in an arbitray coordinate system. The
10 | ; scaling vector is given as a two-element array like this:
11 | ;
12 | ; scalingVector = [translationFactor, scalingFactor]
13 | ;
14 | ; The scaling vector should be used with the [XYZ]COORD_CONV
15 | ; keywords of a graphics object or model. For example, if you
16 | ; wanted to scale an X axis into the coordinate range of -0.5 to 0.5,
17 | ; you might type something like this:
18 | ;
19 | ; xAxis->GetProperty, Range=xRange
20 | ; xScale = Normalize(xRange, Position=[-0.5, 0.5])
21 | ; xAxis, XCoord_Conv=xScale
22 | ;
23 | ; AUTHOR:
24 | ;
25 | ; FANNING SOFTWARE CONSULTING
26 | ; David Fanning, Ph.D.
27 | ; 1645 Sheely Drive
28 | ; Fort Collins, CO 80526 USA
29 | ; Phone: 970-221-0438
30 | ; E-mail: davidf@dfanning.com
31 | ; Coyote's Guide to IDL Programming: http://www.dfanning.com
32 | ;
33 | ; CATEGORY:
34 |
35 | ; Object Graphics
36 | ;
37 | ; CALLING SEQUENCE:
38 | ; xscaling = NORMALIZE(xrange, POSITION=position)
39 | ;
40 | ; INPUTS:
41 | ; XRANGE: A two-element vector specifying the data range.
42 | ;
43 | ; KEYWORD PARAMETERS:
44 | ; POSITION: A two-element vector specifying the location
45 | ; in the coordinate system you are scaling into. The vector [0,1]
46 | ; is used by default if POSITION is not specified.
47 | ;
48 | ; COMMON BLOCKS:
49 | ; None.
50 | ;
51 | ; EXAMPLE:
52 | ; See above.
53 | ;
54 | ; MODIFICATION HISTORY:
55 | ; Written by: David W. Fanning, OCT 1997.
56 | ; Fixed a problem with illegal divide by zero. 21 April 2005. DWF.
57 | ;-
58 |
59 | FUNCTION Normalize_BCAL, range, Position=position
60 | compile_opt idl2
61 |
62 | On_Error, 1
63 | IF N_Params() EQ 0 THEN Message, 'Please pass range vector as argument.'
64 |
65 | IF (N_Elements(position) EQ 0) THEN position = [0.0D, 1.0D] ELSE $
66 | position=Double(position)
67 | range = Double(range)
68 |
69 | scale = [((position[0]*range[1])-(position[1]*range[0])) / $
70 | ((range[1]-range[0]) > 1e-12), (position[1]-position[0])/((range[1]-range[0]) > 1e-12)]
71 |
72 | RETURN, scale
73 | END
74 | ;-------------------------------------------------------------------------
75 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/AddProjectionLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; AddProjectionLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; The purpose of this program is add projection information to LAS files
9 | ;
10 | ; PRODUCTS:
11 | ;
12 | ; The output is a new LAS file for each input LAS file. The output files have the same
13 | ; name as the input files.
14 | ;
15 | ; AUTHOR:
16 | ;
17 | ; David Streutker
18 | ; Boise Center Aerospace Laboratory
19 | ; Idaho State University
20 | ; 322 E. Front St., Ste. 240
21 | ; Boise, ID 83702
22 | ; http://bcal.geology.isu.edu/
23 | ;
24 | ; DEPENDENCIES:
25 | ;
26 | ; ReadLAS_BCAL.pro
27 | ; WriteLAS_BCAL.pro
28 | ; RecordsToProj_BCAL.pro
29 | ;
30 | ; MODIFICATION HISTORY:
31 | ;
32 | ; Written by David Streutker, June 2007.
33 | ; Modified to handle LAS 1.3 and 1.4, April 2016
34 | ;
35 | ;###########################################################################
36 | ;
37 | ; LICENSE
38 | ;
39 | ; This software is OSI Certified Open Source Software.
40 | ; OSI Certified is a certification mark of the Open Source Initiative.
41 | ;
42 | ; Copyright @ 2007 David Streutker, Idaho State University.
43 | ;
44 | ; This software is provided "as-is", without any express or
45 | ; implied warranty. In no event will the authors be held liable
46 | ; for any damages arising from the use of this software.
47 | ;
48 | ; Permission is granted to anyone to use this software for any
49 | ; purpose, including commercial applications, and to alter it and
50 | ; redistribute it freely, subject to the following restrictions:
51 | ;
52 | ; 1. The origin of this software must not be misrepresented; you must
53 | ; not claim you wrote the original software. If you use this software
54 | ; in a product, an acknowledgment in the product documentation
55 | ; would be appreciated, but is not required.
56 | ;
57 | ; 2. Altered source versions must be plainly marked as such, and must
58 | ; not be misrepresented as being the original software.
59 | ;
60 | ; 3. This notice may not be removed or altered from any source distribution.
61 | ;
62 | ; For more information on Open Source Software, visit the Open Source
63 | ; web site: http://www.opensource.org.
64 | ;
65 | ;###########################################################################
66 | ; Begin main program
67 |
68 | pro AddProjectionLAS_BCAL, event
69 |
70 | compile_opt idl2, logical_predicate
71 |
72 | ; Establish error handler. The most likely problem is that the user will open a data
73 | ; file that is too large to process.
74 |
75 | catch, theError
76 | if theError ne 0 then begin
77 | catch, /cancel
78 | help, /last_message, output=errText
79 | errMsg = dialog_message(errText, /error, title='Error processing request')
80 | return
81 | endif
82 |
83 | ; Get the input file(s)
84 |
85 | inputFiles = dialog_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files, /path)
86 | if (inputFiles[0] eq '') then return
87 |
88 | nFiles = n_elements(inputFiles)
89 |
90 | ; Get the output projection and the output directory
91 |
92 | readBase = widget_auto_base(title='Select Projection')
93 |
94 | dummy = widget_label(readBase, value='Set output projection:')
95 | dummy = widget_map(readBase, default_map=[0,0], default_proj=envi_proj_create(), uvalue='proj', /auto)
96 | dummy = widget_outf(readBase, /directory, prompt='Select output directory', uvalue='outDir', /auto)
97 |
98 | result = auto_wid_mng(readBase)
99 | if result.accept eq 0 then return
100 |
101 | proj = result.proj.proj
102 |
103 | outputDir = result.outDir
104 |
105 | ; Set up status message window
106 |
107 | statText = 'Initializing'
108 | statBase = widget_auto_base(title='Adding Projections')
109 | statField = widget_text(statBase, /scroll, value=statText, xsize=80, ysize=4)
110 | widget_control, statBase, /realize
111 |
112 | ; Process each data file individually
113 |
114 | for a=0,nFiles-1 do begin
115 |
116 | ; Update the status window
117 |
118 | statText = ['Adding projection to ' + inputFiles[a], statText]
119 | widget_control, statField, set_value=statText
120 |
121 | ; Read the input file
122 |
123 | ReadLAS_BCAL, inputFiles[a], header, data, records=records, versionMajor=versionMajor, versionMinor=versionMinor
124 |
125 | ; Update the array of records
126 |
127 | newRecord = RecordsToProj_BCAL(proj, versionMajor=versionMajor, versionMinor=versionMinor, /reverse)
128 |
129 | if n_tags(records) then begin
130 |
131 | rIndex = where(records.recordID eq 34735, rCount)
132 |
133 | if rCount then begin
134 |
135 | mText = 'The file ' + file_basename(inputFiles[a]) + ' appears to already contain projection ' $
136 | + 'information. Do you want to rewrite it the projection?'
137 | query = dialog_message(mText, /center, /question, /default_no)
138 |
139 | if query eq 'Yes' then records[rIndex] = newRecord
140 |
141 | endif else records = [records,newRecord]
142 |
143 | endif else records = newRecord
144 |
145 | ; Write the new file
146 |
147 | outputFile = outputDir + '\' + file_basename(inputFiles[a])
148 |
149 | WriteLAS_BCAL, outputFile, header, data, records=records, /check
150 |
151 | endfor
152 |
153 | ; Destroy the status window
154 |
155 | widget_control, statBase, /destroy
156 |
157 |
158 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/LidarMetrics_BCAL.pro:
--------------------------------------------------------------------------------
1 |
2 | PRO LidarMetrics_BCAL, event
3 |
4 | compile_opt idl2, logical_predicate
5 |
6 | Catch, theError
7 | IF theError NE 0 THEN BEGIN
8 | Catch, /Cancel
9 | Help, /last_message, output=errText
10 | errMsg = dialog_message(errText, /error, title='Error processing file')
11 | return
12 | ENDIF
13 |
14 | ; read LAS files
15 |
16 | inputFiles = dialog_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files, /path)
17 | if (inputFiles[0] eq '') then return
18 |
19 | nFiles = n_elements(inputFiles)
20 |
21 | ; Read the first data file for header info
22 |
23 | ReadLAS_BCAL, inputFiles[0], header, /nodata
24 |
25 | treturns = header.nreturns
26 |
27 |
28 | ; read EVF files
29 |
30 | evfFiles = dialog_pickfile(title='Select EVF file(s)', filter='*.evf', /path)
31 | if (evfFiles[0] eq '') then return
32 |
33 | oEvf = Obj_New('IDLanROIGroup')
34 |
35 | for b=0, n_elements(evfFiles)-1 do begin
36 |
37 | evfID = envi_evf_open(evfFiles[b])
38 | envi_evf_info, evfID, num_recs=nrecs
39 |
40 | for c = 0, nrecs-1 do begin
41 | evfCoords = envi_evf_read_record(evfID, c)
42 | oEvf->Add, Obj_New('IDLanROI', evfCoords)
43 | endfor
44 |
45 | envi_evf_close, evfID
46 | endfor
47 |
48 | ; Create list of metrics
49 |
50 | metrics = {minElev :{title:'Minimum', index:-1, doIt:0}, $
51 | maxElev :{title:'Maximum', index:-1, doIt:0}, $
52 | rangeElev :{title:'Range', index:-1, doIt:0}, $
53 | meanElev :{title:'Arithmetic mean', index:-1, doIt:0}, $
54 | stdevElev :{title:'Standard deviation',index:-1, doIt:0}, $
55 | varElev :{title:'Variance', index:-1, doIt:0}, $
56 | skewElev :{title:'Skewness', index:-1, doIt:0}, $
57 | kurElev :{title:'Kurtosis', index:-1, doIt:0}, $
58 | cvElev :{title:'Coefficient of variation', index:-1, doIt:0}}
59 |
60 | nmetrics = n_tags(metrics)
61 | metricsList = strarr(nmetrics)
62 | metricsIndex = bytarr(nmetrics)
63 | metricsIndex[0] = 1
64 | for f=0, nmetrics-1 do metricsList[f] = metrics.(f).title
65 |
66 | ; initialize the user interface
67 |
68 | nReturns = n_elements(tReturns)
69 |
70 | returnList = indgen(nReturns) + 1
71 | returnList = ' Return ' + strcompress(returnList)
72 | returnList = ['All Returns', returnList]
73 |
74 | gridBase = widget_auto_base(title='Lidar Metrics')
75 | topBase = widget_base(gridBase, /row)
76 | leftBase = widget_base(topBase, /column)
77 |
78 | returnBase = widget_base(leftBase, /row)
79 | dummy = widget_pmenu(returnBase, list=returnList, default=nReturns, prompt='Select return number: ', $
80 | uvalue='returns', /auto_manage)
81 | dummy = widget_outf(leftBase, default='output.csv', prompt='Enter name of output file ', $
82 | uvalue='outFile', /auto)
83 |
84 | rightBase = widget_base(topBase)
85 | dummy = widget_multi(rightBase, list=metricsList, prompt='Select metrics:', /no_range, ysize=250, $
86 | default=metricsIndex, uvalue='metrics', /auto)
87 |
88 | result = auto_wid_mng(gridBase)
89 |
90 | if (result.accept eq 0) then return
91 | retNum = result.returns + 1
92 | metricsIndex = result.metrics
93 | CsvFile = result.outFile
94 |
95 | ; Create the list of metrics names
96 |
97 | bNames = metricsList[where(metricsIndex eq 1)]
98 | nBands = total(metricsIndex)
99 |
100 | ; Open output csv file for writing
101 |
102 | openw, CSVmetrics, CsvFile, /get_lun, width=1600
103 |
104 |
105 | for a=0, nFiles-1 do begin
106 |
107 | ; Read the data file.
108 |
109 | ReadLAS_BCAL, inputFiles[a], header, projection=defProj, pData
110 |
111 | iDim = ceil((header.xMax - xMinTile) / 0.5)
112 | jDim = ceil((header.yMax - yMinTile) / 0.5)
113 |
114 | arrayHist = histogram(floor((header.yOffset - header.yMin + pData.north * header.yScale) / baseScale) * xDim $
115 | + floor((header.xOffset - header.xMin + pData.east * header.xScale) / baseScale) $
116 | + xDim * yDim * ((retNum le nReturns) and ((pData.nReturn mod 8) ne retNum)) $
117 | + xDim * yDim * (pData.class eq 1), $
118 | reverse_indices=arrayIndex, min=0d, max=xDim*yDim)
119 |
120 | endfor
121 |
122 |
123 | for o=0, oEvf->Count()-1 do begin
124 | oTemp = oEvf->Get(position=o)
125 | oTemp->GetProperty, data=evfCoords
126 | printf, CSVmetrics, evfCoords[0,*], evfCoords[1,*]
127 | endfor
128 |
129 |
130 | free_lun, CSVmetrics
131 | close, CSVmetrics
132 |
133 | ;widget_control, gridBase, /destroy
134 | obj_destroy, oEvf
135 |
136 | END
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/NormalizeElevLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; NormalizeElevLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; Basically the same as NormalizeElev_ui
9 | ;
10 | ; DEPENDENCIES:
11 | ;
12 | ; ReadLAS_BCAL.pro
13 | ; WriteLAS_BCAL.pro
14 | ;
15 | ; MODIFICATION HISTORY:
16 | ;
17 | ; Implemented by Exelis VIS, April 2016.
18 | ;
19 | ;###########################################################################
20 | ;
21 | ; LICENSE
22 | ;
23 | ; This software is OSI Certified Open Source Software.
24 | ; OSI Certified is a certification mark of the Open Source Initiative.
25 | ;
26 | ; Copyright � 2006 David Streutker, Idaho State University.
27 | ;
28 | ; This software is provided "as-is", without any express or
29 | ; implied warranty. In no event will the authors be held liable
30 | ; for any damages arising from the use of this software.
31 | ;
32 | ; Permission is granted to anyone to use this software for any
33 | ; purpose, including commercial applications, and to alter it and
34 | ; redistribute it freely, subject to the following restrictions:
35 | ;
36 | ; 1. The origin of this software must not be misrepresented; you must
37 | ; not claim you wrote the original software. If you use this software
38 | ; in a product, an acknowledgment in the product documentation
39 | ; would be appreciated, but is not required.
40 | ;
41 | ; 2. Altered source versions must be plainly marked as such, and must
42 | ; not be misrepresented as being the original software.
43 | ;
44 | ; 3. This notice may not be removed or altered from any source distribution.
45 | ;
46 | ; For more information on Open Source Software, visit the Open Source
47 | ; web site: http://www.opensource.org.
48 | ;
49 | ;###########################################################################
50 |
51 |
52 | ; Begin main program
53 |
54 | pro NormalizeElevLAS_BCAL, event
55 |
56 | compile_opt idl2, logical_predicate
57 |
58 | ; Establish an error handler.
59 |
60 | catch, theError
61 | if theError ne 0 then begin
62 | catch, /cancel
63 | help, /last_message, output=errText
64 | errMsg = dialog_message(errText, /error, title='Error processing file', /center)
65 | return
66 | endif
67 |
68 |
69 | doProfile = 0
70 |
71 | ; Get the input file(s).
72 | inputFiles = envi_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files)
73 | if (inputFiles[0] eq '') then return
74 |
75 | outputDir = envi_pickfile(title='Select output directory', /directory)
76 | if outputDir eq '' then return
77 |
78 | ; Begin processesing each file
79 |
80 | minN = 0.05
81 | maxN = 1.8
82 |
83 | for a=0,n_elements(inputFiles)-1 do begin
84 |
85 | ; Establish the status reporting widget. This will report the processing status
86 | ; for each data file.
87 |
88 | statBase = widget_auto_base(title='Assigning')
89 | statText = ['Normalizing Progress:', file_basename(inputFiles[a]), $
90 | 'File' + strcompress(a+1) + ' of' + strcompress(n_elements(inputFiles))]
91 | envi_report_init, statText, base=statBase, /interrupt, title='Normalizing elevation...'
92 |
93 | ; Read the input data file.
94 |
95 | ReadLAS_BCAL, inputFiles[a], header, pData, records=records
96 |
97 | envi_report_stat, statBase, 33, 100, cancel=cancel
98 |
99 | g_index = where(pdata.source le ((minN - header.zOffset) / header.zScale), g_count, complement=t_index, ncomplement=t_count)
100 |
101 | if g_count ne 0 then begin
102 | pdata[g_index].class = 2
103 | pdata[g_index].source = 0
104 | endif
105 |
106 | if t_count ne 0 then pdata[t_index].class = 3
107 |
108 | envi_report_stat, statBase, 66, 100, cancel=cancel
109 |
110 | v_index = where(pdata.source gt ((maxN - header.zOffset) / header.zScale), v_count)
111 |
112 | if v_count ne 0 then begin
113 | pdata[v_index].class = 1
114 | pdata[v_index].source = 2^16 - 1
115 | endif
116 |
117 | envi_report_stat, statBase, 99, 100, cancel=cancel
118 |
119 | outputFile = outputDir + path_sep() + file_basename(inputFiles[a])
120 | WriteLAS_BCAL, outputFile, header, pData, records=records, /check
121 |
122 | envi_report_stat, statBase, 100, 100, cancel=cancel
123 | envi_report_init, base=statBase, /finish
124 |
125 | endfor
126 |
127 |
128 | end
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/ReclassifyLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReclassifyLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; The purpose of this program is to reclassify a LAS file
9 | ;
10 | ; PRODUCTS:
11 | ;
12 | ; The output is LAS file(s) with assigned reclassification
13 | ;
14 | ; AUTHOR:
15 | ;
16 | ; Rupesh Shrestha
17 | ; Boise Center Aerospace Laboratory
18 | ; Idaho State University
19 | ; 322 E. Front St., Ste. 240
20 | ; Boise, ID 83702
21 | ; http://bcal.geology.isu.edu/
22 | ;
23 | ; DEPENDENCIES:
24 | ;
25 | ; ReadLAS_BCAL.pro
26 | ; WriteLAS_BCAL.pro
27 | ;
28 | ; MODIFICATION HISTORY:
29 | ;
30 | ;
31 | ;###########################################################################
32 | ;
33 | ; LICENSE
34 | ;
35 | ; This software is OSI Certified Open Source Software.
36 | ; OSI Certified is a certification mark of the Open Source Initiative.
37 | ;
38 | ; Copyright @ 2010 Idaho State University.
39 | ;
40 | ; This software is provided "as-is", without any express or
41 | ; implied warranty. In no event will the authors be held liable
42 | ; for any damages arising from the use of this software.
43 | ;
44 | ; Permission is granted to anyone to use this software for any
45 | ; purpose, including commercial applications, and to alter it and
46 | ; redistribute it freely, subject to the following restrictions:
47 | ;
48 | ; 1. The origin of this software must not be misrepresented; you must
49 | ; not claim you wrote the original software. If you use this software
50 | ; in a product, an acknowledgment in the product documentation
51 | ; would be appreciated, but is not required.
52 | ;
53 | ; 2. Altered source versions must be plainly marked as such, and must
54 | ; not be misrepresented as being the original software.
55 | ;
56 | ; 3. This notice may not be removed or altered from any source distribution.
57 | ;
58 | ; For more information on Open Source Software, visit the Open Source
59 | ; web site: http://www.opensource.org.
60 | ;
61 | ;###########################################################################
62 |
63 | ; Begin main program
64 |
65 | pro ReclassifyLAS_BCAL, event
66 |
67 | compile_opt idl2, logical_predicate
68 |
69 | ; Establish error handler.
70 |
71 | catch, theError
72 | if theError ne 0 then begin
73 | catch, /cancel
74 | help, /last_message, output=errText
75 | errMsg = dialog_message(errText, /error, title='Error processing request')
76 | return
77 | endif
78 |
79 | ; Open input files
80 |
81 | inputFiles = dialog_pickfile(title='Select LiDAR file(s)', filter='*.las', /multiple_files)
82 | if (inputFiles[0] eq '') then return
83 |
84 | nFiles = n_elements(inputFiles)
85 |
86 | list = ['Class 0 :','Class 1 :','Class 2 :','Class 3 :','Class 4 :','Class 5 :','Class 6 :', $
87 | 'Class 7 :','Class 8 :','Class 9 :','Class 10 :','Class 11 :','Class 12 :']
88 |
89 | classIndex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
90 | ; Get the user parameters
91 |
92 | readBase = widget_auto_base(title='Reclassify LAS files')
93 |
94 | tileBase = widget_base(readBase, /row)
95 | dummy = widget_edit(tileBase, dt=2, list=list, $
96 | prompt='Reclassification:', vals=classIndex, ysize=13, uvalue='newIndex', /auto)
97 |
98 | outputBase = widget_base(readBase, /row)
99 | fileBase = widget_base(outputBase, /column)
100 | outputField = widget_outf(fileBase, prompt='Select output directory ', /directory, $
101 | uvalue='lasName', /auto)
102 |
103 | result = auto_wid_mng(readBase)
104 | if (result.accept eq 0) then return
105 |
106 | newIndex = result.newIndex
107 |
108 | outputDir = result.lasName
109 |
110 | cIndex = where(classIndex ne newIndex, nOut)
111 |
112 | if nOut ne 0 then begin
113 |
114 | classNames = classIndex[cIndex]
115 |
116 | ; Set up ENVI status reporting box
117 | statText1 = 'Reclassifying...'
118 | statText2 = 'LAS file: ' + FILE_BASENAME(inputFiles)
119 | statText = [statText1,statText2]
120 | statBase = widget_auto_base(title='Reclassification')
121 | ENVI_REPORT_INIT, statText, BASE=statBase, TITLE='Reclassifying'
122 | envi_report_inc, statBase, nFiles
123 |
124 | for a=0,nFiles-1 do begin
125 |
126 | ; Read input lidar data to an array of structures
127 |
128 | ReadLAS_BCAL, inputFiles[a], header, data, records=records, check=check, projection=projection
129 |
130 | for i = 0, nOut-1 do begin
131 |
132 | dindex = where(data.class eq classNames[i], count)
133 |
134 | if count ne 0 then begin
135 |
136 | data[dindex].class = newIndex[cIndex[i]]
137 |
138 | endif
139 |
140 | endfor
141 |
142 | outputFile = outputDir + '\' + file_basename(inputFiles[a])
143 |
144 | WriteLAS_BCAL, outputFile, header, data, records=records, /check
145 |
146 | envi_report_inc, statBase, a
147 |
148 |
149 | endfor
150 |
151 | endif else msgBox = DIALOG_MESSAGE('No new classification was assigned', /ERROR)
152 |
153 | ;; Complete status reporting widget
154 | envi_report_init, base=StatBase, /finish
155 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/ReturnsLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ; Sara Ehinger
2 | ; March 31, 2010
3 | ; Export Selected Returns Only
4 | ; First, Second, Third, Fouth, Fifth, Last
5 | ; DEPENDENCIES:
6 | ;
7 | ; INITDATALAS_BCAL.pro
8 |
9 | PRO ReturnsLAS_BCAL, event
10 |
11 | compile_opt idl2, logical_predicate
12 |
13 | Catch, theError
14 | IF theError NE 0 THEN BEGIN
15 | Catch, /Cancel
16 | Help, /last_message, output=errText
17 | errMsg = dialog_message(errText, /error, title='Error processing file')
18 | return
19 | ENDIF
20 |
21 | inputFile = envi_pickfile(title='Select LAS file', filter='*.las')
22 | if (inputFile eq '') then return
23 |
24 | ; ugh, need a god damn widget
25 | ; for return number and output file name
26 | ; for now hard code
27 | ; Drop down:
28 | ; Last Returns, 0
29 | ; First Returns, 1
30 | ; Second Returns, 2
31 | ; Third Returns, 3
32 | ; Fouth Returns, 4
33 | ; Fifth Returns, 5
34 | ; sReturn = result
35 | ; try first with old school idl widgets
36 | ; never mind, just use fancy envi auto widgets
37 |
38 | ReadLAS_BCAL, inputFile, header, data, records=records, projection=projection
39 | numOrigPts = header.nPoints
40 | numReturns = header.nReturns
41 |
42 | topBase = widget_auto_base(title='Export lidar data by return number')
43 |
44 | labelText = 'Selected File: ' + file_basename(inputFile)
45 | labelBase = widget_slabel(topBase, prompt=labelText, /frame)
46 |
47 | returnList = ['Last Returns','First Returns','Second Returns','Third Returns','Fourth Returns','Fifth Returns']
48 | returnBase = widget_pmenu(topBase, prompt='Select Returns', list=returnList, uvalue='outr', /auto)
49 |
50 | defOutF = file_dirname(inputFile) + '\' + file_basename(inputFile, '.las') + '_selected' + '.las'
51 | outBase = widget_outf(topBase, default=defOutF, uvalue='outf', /auto)
52 |
53 | result = auto_wid_mng(topBase)
54 | if result.accept eq 0 then return
55 |
56 |
57 | sReturn = result.outr
58 | outputFile = result.outf
59 |
60 |
61 |
62 | CASE sReturn OF
63 | 0: exportA = WHERE(floor(data.nReturn/8) mod 8 - data.nReturn mod 8 EQ sReturn, count)
64 | ELSE: exportA = WHERE(data.nReturn mod 8 EQ sReturn, count)
65 | ENDCASE
66 | ; warning if count = 0!
67 |
68 | IF count GT 0 THEN BEGIN
69 | dataStr2 = InitDataLAS_BCAL(pointFormat=header.POINTFORMAT)
70 | data2 = replicate(dataStr2, count)
71 | for a=0,count-1 do begin
72 | tempIndex = exportA[a]
73 | data2[a] = data[tempIndex]
74 | endfor
75 | ENDIF ELSE BEGIN
76 | msgText = 'There were no returns that matched your selection. Export cancelled.'
77 | msgBox = dialog_message(msgText)
78 | ; Add a return to widget?
79 | RETURN
80 | ENDELSE
81 |
82 | WriteLAS_BCAL, outputFile, header, data2, records=records, /check
83 |
84 | msgText = strcompress([sReturn, numOrigPts, count])
85 | msgBox = dialog_message(msgText, /information)
86 |
87 | data = 0B
88 | data2 = 0B
89 | header = 0B
90 |
91 | END ; ReturnsLAS.pro
92 |
93 |
94 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/Wizard/Wizard_Data_Input.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; This function is to act as the data input tool. We will try to perform some operations automatically and save
3 | ; files automatically along the way.
4 | function GetFileList, id
5 |
6 | stash = WIDGET_INFO(id, /CHILD)
7 | WIDGET_CONTROL, stash, GET_UVALUE=fileLoadStash, /NO_COPY
8 | files = fileLoadStash.fileList
9 |
10 | WIDGET_CONTROL, stash, SET_UVALUE=fileLoadStash, /NO_COPY
11 | return, files
12 | end
13 |
14 | function Wizard_Data_Input, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
15 |
16 | dataInputBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_LEFT, $
17 | XSIZE=width, SPACE=20, EVENT_PRO='WIZARD_DATA_INPUT_EV', FUNC_GET_VALUE='GetFileList')
18 |
19 | titleText = WIDGET_LABEL(dataInputBase, value='Data Preprocessing', FONT='Arial*BOLD*UNDERLINE', $
20 | /ALIGN_CENTER)
21 |
22 |
23 | descriptionLabel = WIDGET_LABEL(dataInputBase, value= $
24 | 'Please start by uploading a LiDAR dataset either in ' + String(13b) $
25 | + '.las or another text format (ASCII).', /ALIGN_LEFT, YSIZE=135, FONT='Arial*16')
26 |
27 | ;base widget for the file upload line
28 | fileLoadRowBase = WIDGET_BASE(dataInputBase, /ROW, /ALIGN_CENTER, XSIZE=width)
29 | fileLoadLabel = WIDGET_LABEL(fileLoadRowBase, UVALUE='fileLoadLabel', value='Input Dataset: ', /ALIGN_LEFT, FONT='Arial*15')
30 |
31 | fileLoadList = WIDGET_LIST(fileLoadRowBase, XSIZE=50, YSIZE=10, XOFFSET=10, UVALUE='fileList')
32 | fileList = ['']
33 | selected = -1
34 |
35 | btnsGroup = WIDGET_BASE(fileLoadRowBase, UVALUE='btnBase', XSIZE=125, /COLUMN)
36 |
37 | fileLoadBtn = WIDGET_BUTTON(btnsGroup, XSIZE=125, FONT='Arial*15', VALUE='Add File', UVALUE='FileBrowse', YSIZE=30)
38 | fileRemoveBtn = WIDGET_BUTTON(btnsGroup, XSIZE=125, FONT='Arial*15', VALUE='Remove Selected', UVALUE='fileRemove',YSIZE=30, YOFFSET=20)
39 |
40 |
41 |
42 | fileLoadStash = {fileLoadList:fileLoadList, selected:selected, fileList:fileList}
43 |
44 | WIDGET_CONTROL, WIDGET_INFO(dataInputBase, /CHILD), SET_UVALUE=fileLoadStash, /NO_COPY
45 |
46 | return, dataInputBase
47 | END
48 |
49 | ;function to get the file from the user and perform analysis
50 | function GetFiles
51 |
52 | inputFiles = ENVI_PICKFILE(TITLE='Select Input LiDAR Dataset', FILTER='*.las', /MULTIPLE_FILES)
53 | return, inputFiles
54 |
55 | end
56 |
57 | PRO WIZARD_DATA_INPUT_EV, ev
58 |
59 | ;This grabs the local stashed variable
60 | base = ev.handler
61 | stash = WIDGET_INFO(base, /CHILD)
62 | WIDGET_CONTROL, stash, GET_UVALUE=fileLoadStash, /NO_COPY
63 |
64 | ;get the button pressed
65 | WIDGET_CONTROL, ev.ID, GET_UVALUE=command
66 | CASE command OF
67 | 'FileBrowse': BEGIN
68 | ;get the file
69 | inputFiles = GetFiles()
70 | ;get the array
71 |
72 | ;list = WIDGET_INFO(fileLoadStash.fileLoadList)
73 | ;append to existing
74 | if fileLoadStash.fileList[0] EQ '' then begin
75 | files = inputFiles
76 | endif else begin
77 | files = [fileLoadStash.fileList, inputFiles]
78 | endelse
79 |
80 | ;set back to list
81 | WIDGET_CONTROL, fileLoadStash.fileLoadList, SET_VALUE=files
82 |
83 |
84 | ;now we want to try and make the top level next button visible
85 | WIDGET_CONTROL, ev.TOP, GET_UVALUE=MainStash
86 | Widget_Control, MainStash.nextBtn, Sensitive=1
87 |
88 | ;recreate the stash as we have a new array
89 | fileLoadStash ={fileLoadList:fileLoadStash.fileLoadList, selected:fileLoadStash.selected, fileList:files}
90 |
91 | END
92 | 'fileList': BEGIN
93 | ;set the currently selected item
94 | fileLoadStash.selected = ev.INDEX
95 |
96 | END
97 | 'fileRemove': BEGIN
98 | if fileLoadStash.selected NE -1 then begin
99 | index = fileLoadStash.selected
100 | array = fileLoadStash.fileList
101 | first = 0
102 | last = N_Elements(array)-1
103 | if last ne 0 then begin
104 | CASE index OF
105 | first: array = array[1:*]
106 | last: array = array[first:last-1]
107 | ELSE: array = [ array[first:index-1], array[index+1:last] ]
108 | ENDCASE
109 | endif else begin
110 | array = ['']
111 | endelse
112 | ;set back to list
113 | WIDGET_CONTROL, fileLoadStash.fileLoadList, SET_VALUE=array
114 | fileLoadStash ={fileLoadList:fileLoadStash.fileLoadList, selected:fileLoadStash.selected, fileList:array}
115 | endif
116 |
117 | END
118 | ENDCASE
119 | WIDGET_CONTROL, stash, SET_UVALUE=fileLoadStash, /NO_COPY
120 |
121 | END
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/Wizard/Wizard_Generate_Data.pro:
--------------------------------------------------------------------------------
1 |
2 | function Wizard_Generate_Data, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
3 | genDataBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_CENTER, XSIZE=width, SPACE=20)
4 | titleText = WIDGET_LABEL(genDataBase, value='Generate Result Data', FONT='Arial*BOLD*UNDERLINE', $
5 | /ALIGN_CENTER)
6 | textWidget = WIDGET_TEXT(genDataBase, value="With Height Filtering complete, all that is left is" $
7 | + " to generate the rasters. Pressing the 'Finish' button will launch the Generate Rasters tool." $
8 | + " Once complete, the data will reside in a subdirectory off of the input file.", /WRAP, XSIZE=64, YSIZE=4)
9 |
10 |
11 | ;have to specify the event-handler manually when inside a function apparently
12 | ;XMANAGER, 'Wizard_Generate_Data', genDataBase, EVENT_HANDLER='Wizard_Generate_Data_ev'
13 | return, genDataBase
14 | END
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/Wizard/Wizard_Height_Filtering.pro:
--------------------------------------------------------------------------------
1 | ; This file contains the ui for the height filtering
2 | ; We will include the ability to utilize a previously height filtered data set
3 |
4 | PRO Wizard_Height_Filtering_EV, event
5 | END
6 |
7 | FUNCTION Wizard_Height_Filtering, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
8 |
9 | HeightFilterBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_LEFT, $
10 | XSIZE=width, SPACE=20, EVENT_PRO='Wizard_Height_Filtering_EV', FUNC_GET_VALUE='GetHeightFilteringSelection')
11 |
12 | titleText = WIDGET_LABEL(HeightFilterBase, value='Height Filtering', FONT='Arial*BOLD*UNDERLINE', $
13 | /ALIGN_CENTER)
14 |
15 | descriptionLabel = WIDGET_TEXT( HeightFilterBase, VALUE="Now that the data has been prepared, we need to perform height" + $
16 | " filtering. In some cases, height fltering may have already been performed either by BCAL tools, or" + $
17 | " other toolsets. If you don't know, just click the 'Next' button below.", /WRAP, XSIZE=64, YSIZE=6)
18 |
19 | RadioButtonBase = WIDGET_BASE(HeightFilterBase, SCR_XSIZE=500, /Exclusive)
20 |
21 | NotFilteredBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Not Height Filtered")
22 | FilteredBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Height Filtered Using External Tools")
23 | FilteredBCALBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Height Filtered using BCAL tools")
24 | ;set the default state to be not filtered
25 | Widget_Control, NotFilteredBtn, Set_Button=1
26 |
27 | heightFilterStash = {NotFiltered:NotFilteredBtn, Filtered:FilteredBtn, FilteredBCAL:FilteredBCALBtn}
28 | WIDGET_CONTROL, WIDGET_INFO(HeightFilterBase, /CHILD), SET_UVALUE=heightFilterStash, /NO_COPY
29 |
30 | return, HeightFilterBase
31 |
32 | END
33 |
34 | FUNCTION GetHeightFilteringSelection, id
35 | ; we are going to use return values of 0, 1, and 2 for not filtered, filtered using external tools
36 | ; and filtered using BCAL tools respectively
37 | stash = WIDGET_INFO(id, /CHILD)
38 | WIDGET_CONTROL, stash, GET_UVALUE=heightFilterStash, /NO_COPY
39 | ;grab the buttons
40 | notFiltered = WIDGET_INFO(heightFilterStash.NotFiltered, /BUTTON_SET)
41 | Filtered = WIDGET_INFO(heightFilterStash.Filtered, /BUTTON_SET)
42 | FilteredBCAL = WIDGET_INFO(heightFilterStash.FilteredBCAL, /BUTTON_SET)
43 |
44 | ;WIDGET_CONTROL, heightFilterStash.Filtered, GET_VALUE=FilteredBtn
45 | ;WIDGET_CONTROL, heightFilterStash.FilteredBCAL, GET_VALUE=FilteredBCALBtn
46 | if (notFiltered EQ 1) then return, 0
47 | if (Filtered EQ 1) then return, 1
48 | if (FilteredBCAL EQ 1) then return, 2
49 |
50 |
51 | END
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/Wizard/Wizard_Intro.pro:
--------------------------------------------------------------------------------
1 | PRO Wizard_Intro_Event, ev
2 | base = ev.handler
3 | stash = WIDGET_INFO(base, /CHILD)
4 | WIDGET_CONTROL, stash, GET_UVALUE=introStash, /NO_COPY
5 |
6 | ;get the button pressed
7 | WIDGET_CONTROL, ev.ID, GET_UVALUE=command
8 | CASE command OF
9 | 'folderBrowse': BEGIN
10 | folder = ENVI_PICKFILE(TITLE='Choose an Output Folder', /DIRECTORY) + '\'
11 | ;folder = 'C:\proc' + '\'
12 | WIDGET_CONTROL, introStash.folderLoadText, SET_VALUE=folder
13 | WIDGET_CONTROL, ev.TOP, GET_UVALUE=MainStash
14 | Widget_Control, MainStash.nextBtn, Sensitive=1
15 |
16 | END
17 | END
18 |
19 | WIDGET_CONTROL, stash, SET_UVALUE=introStash, /NO_COPY
20 | END
21 |
22 |
23 | function Wizard_Intro, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode
24 | ;COMPILE_OPT hidden
25 |
26 | introBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, /BASE_ALIGN_TOP, XSIZE=450, YSIZE=550, FUNC_GET_VALUE='GetRootFolder', EVENT_PRO='Wizard_Intro_Event')
27 |
28 | titleText = WIDGET_LABEL(introBase, value='BCAL LiDAR Processing Wizard', FONT='Arial*BOLD*UNDERLINE', $
29 | /ALIGN_CENTER)
30 |
31 | descriptionText = WIDGET_LABEL(introBase, value= String(13B) $
32 | + 'Welcome to the BCAL LiDAR Processing Wizard. '$
33 | + String(13B) $
34 | + String(13B) $
35 | + 'This wizard will guide you through several processing steps '$
36 | + String(13B) $
37 | + 'typical for analysing LiDAR data with the BCAL tools. '$
38 | + String(13B) $
39 | + 'This tool will only include common workflows.' $
40 | + String(13B) $
41 | + 'More refined processing may require further investigation with ' $
42 | + String(13B) $
43 | + 'the other BCAL LiDAR tools.',$
44 | /ALIGN_CENTER, YSIZE=300, FONT='Arial*18')
45 |
46 | ;Directory chooser
47 | folderLoadRowBase = WIDGET_BASE(introBase, /ROW, /ALIGN_CENTER, XSIZE=width, YOFFSET=50)
48 | folderLoadLabel = WIDGET_LABEL(folderLoadRowBase, UVALUE='folderLoadLabel', value='Output Folder ', /ALIGN_LEFT, FONT='Arial*15')
49 | folderLoadText = WIDGET_TEXT(folderLoadRowBase, XSIZE=40, XOFFSET=10, UVALUE='folderName')
50 | folderLoadBtn = WIDGET_BUTTON(folderLoadRowBase, XSIZE=80, FONT='Arial*15', VALUE='Browse...', UVALUE='folderBrowse', YSIZE=30)
51 |
52 | ;save structure for events
53 | introStash = {folderLoadText:folderLoadText}
54 | WIDGET_CONTROL, WIDGET_INFO(introBase, /CHILD), SET_UVALUE=introStash, /NO_COPY
55 |
56 | return, introBase
57 | END
58 |
59 | function GetRootFolder, id
60 |
61 | stash = WIDGET_INFO(id, /CHILD)
62 | WIDGET_CONTROL, stash, GET_UVALUE=introStash, /NO_COPY
63 | WIDGET_CONTROL, introStash.folderLoadText, GET_VALUE=folder
64 |
65 | WIDGET_CONTROL, stash, SET_UVALUE=introStash, /NO_COPY
66 | return, folder
67 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi52/procedures/Wizard/Wizard_Utils.pro:
--------------------------------------------------------------------------------
1 | function DirectoryFromFile, fileName
2 | lastIndex = STRPOS(fileName, '/', /REVERSE_SEARCH)
3 |
4 | if (lastIndex EQ -1) THEN BEGIN
5 | ;search for windows style path
6 | lastIndex = STRPOS(filename, '\', /REVERSE_SEARCH)
7 | endif
8 |
9 | Directory = STRMID(fileName, 0, lastIndex+1)
10 | return, Directory
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/LidarToolsHelp_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
; NAME:
;
; LiDARToolsHelp_BCAL
;
; PURPOSE:
;
; The purpose of this program is to display help file for the LiDAR Tools
;
; PRODUCTS:
;
;
; AUTHOR:
;
; Rupesh Shrestha
; Boise Center Aerospace Laboratory
; Idaho State University
; 322 E. Front St., Ste. 240
; Boise, ID 83702
; http://bcal.geology.isu.edu/
;
; DEPENDENCIES:
;
;
; MODIFICATION HISTORY:
;
; Written by Rupesh Shrestha, August 2010.
; Changed online help from HTML to PDF for cross-platform compatibility
; and easier maintenance.
;
;###########################################################################
;
; LICENSE
;
; This software is OSI Certified Open Source Software.
; OSI Certified is a certification mark of the Open Source Initiative.
;
; Copyright @ 2010 Rupesh Shrestha, Idaho State University.
;
; This software is provided "as-is", without any express or
; implied warranty. In no event will the authors be held liable
; for any damages arising from the use of this software.
;
; Permission is granted to anyone to use this software for any
; purpose, including commercial applications, and to alter it and
; redistribute it freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must
; not claim you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation
; would be appreciated, but is not required.
;
; 2. Altered source versions must be plainly marked as such, and must
; not be misrepresented as being the original software.
;
; 3. This notice may not be removed or altered from any source distribution.
;
; For more information on Open Source Software, visit the Open Source
; web site: http://www.opensource.org.
;
;###########################################################################
; Begin main program
pro LiDARToolsHelp_BCAL, event
compile_opt idl2
widget_control, event.id, get_uvalue=helpAbout
case helpAbout of
'LiDARToolsHelp': begin
oJavaDesktop = OBJ_NEW('IDLJavaObject$Static$JAVA_AWT_DESKTOP', $
'java.awt.Desktop')
oJavaURI = OBJ_NEW('IDLJavaObject$JAVA_NET_URI', 'java.net.URI', $
'https://github.com/bcal-lidar/tools/wiki')
if (oJavaDesktop->isDesktopSupported()) then begin
oBrowser = oJavaDesktop->getDesktop()
oBrowser->browse,oJavaURI
OBJ_DESTROY, oBrowser
endif
OBJ_DESTROY, oJavaURI, oJavaDesktop
end
'LiDARToolsUpdates': begin
oJavaDesktop = OBJ_NEW('IDLJavaObject$Static$JAVA_AWT_DESKTOP', $
'java.awt.Desktop')
oJavaURI = OBJ_NEW('IDLJavaObject$JAVA_NET_URI', 'java.net.URI', $
'https://bcal.boisestate.edu/tools/lidar')
if (oJavaDesktop->isDesktopSupported()) then begin
oBrowser = oJavaDesktop->getDesktop()
oBrowser->browse,oJavaURI
OBJ_DESTROY, oBrowser
endif
OBJ_DESTROY, oJavaURI, oJavaDesktop
end
'AboutLiDARTools': begin
envi_center, xoff, yoff
widget_control, event.top, get_uvalue = info
aboutBase = widget_base(Title = 'About', /col, xoffset = xoff, $
yoffset = yoff, xsize=250)
dummy = widget_label(aboutBase, value='', /align_center)
dummy = widget_label(aboutBase, value='BCAL LiDAR Tools 5.3', /align_center)
dummy = widget_label(aboutBase, value='Boise Center for Aerospace Laboratory', /align_center)
dummy = widget_label(aboutBase, value='Boise State University', /align_center)
dummy = widget_label(aboutBase, value='1910 University Dr, Boise, Idaho', /align_center)
dummy = widget_label(aboutBase, value='bcal@boisestate.edu', /align_center)
dummy = widget_label(aboutBase, value='', /align_center)
widget_control, aboutBase, /realize
end
endcase
end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/bcal_lidar_tools_envi53.sav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcal-lidar/tools/b4f976f922ca3b021a40946ab6da35b8f21da3a3/src/bcal_lidar_tools_envi53/bcal_lidar_tools_envi53.sav
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/bcal_lidar_tools_envi53_classic.sav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcal-lidar/tools/b4f976f922ca3b021a40946ab6da35b8f21da3a3/src/bcal_lidar_tools_envi53/bcal_lidar_tools_envi53_classic.sav
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/GetIndex_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; GetIndex_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function is used for "index chunking", in combination with the output of
9 | ; the REVERSE_INDICES keyword of the HISTOGRAM function. For a given array element
10 | ; and search radius, the function returns all indices within those elements.
11 | ;
12 | ; AUTHOR:
13 | ;
14 | ; David Streutker
15 | ; Boise Center Aerospace Laboratory
16 | ; Idaho State University
17 | ; 322 E. Front St., Ste. 240
18 | ; Boise, ID 83702
19 | ; http://geology.isu.edu/BCAL
20 | ;
21 | ; CALLING SEQUENCE:
22 | ;
23 | ; index = GetIndex_BCAL(I,J,xDim,yDim,ArrayIndex,Factor)
24 | ;
25 | ; I and J are the coordinates within the array, xDim and yDim are the dimensions of
26 | ; the array, ArrayIndex is the output of the REVERSE_INDICES keyword of the HISTOGRAM
27 | ; function, and Factor is the search radius. (Factor = 0 searches the single element,
28 | ; Factor = 1 searches the nine-element neighborhood, and so on.)
29 | ;
30 | ; RETURN VALUE:
31 | ;
32 | ; The function returns the indices corresponding to the specified element and the
33 | ; elements within the radius specified by the value of Factor.
34 | ;
35 | ; If no indices are found, the function returns a value of -1.
36 | ;
37 | ; KNOWN ISSUES:
38 | ;
39 | ; None.
40 | ;
41 | ; MODIFICATION HISTORY:
42 | ;
43 | ; Written by David Streutker, March 2006.
44 | ;
45 | ;###########################################################################
46 | ;
47 | ; LICENSE
48 | ;
49 | ; This software is OSI Certified Open Source Software.
50 | ; OSI Certified is a certification mark of the Open Source Initiative.
51 | ;
52 | ; Copyright � 2006 David Streutker, Idaho State University.
53 | ;
54 | ; This software is provided "as-is", without any express or
55 | ; implied warranty. In no event will the authors be held liable
56 | ; for any damages arising from the use of this software.
57 | ;
58 | ; Permission is granted to anyone to use this software for any
59 | ; purpose, including commercial applications, and to alter it and
60 | ; redistribute it freely, subject to the following restrictions:
61 | ;
62 | ; 1. The origin of this software must not be misrepresented; you must
63 | ; not claim you wrote the original software. If you use this software
64 | ; in a product, an acknowledgment in the product documentation
65 | ; would be appreciated, but is not required.
66 | ;
67 | ; 2. Altered source versions must be plainly marked as such, and must
68 | ; not be misrepresented as being the original software.
69 | ;
70 | ; 3. This notice may not be removed or altered from any source distribution.
71 | ;
72 | ; For more information on Open Source Software, visit the Open Source
73 | ; web site: http://www.opensource.org.
74 | ;
75 | ;###########################################################################
76 |
77 | function GetIndex_BCAL, i, j, xDim, yDim, arrayIndex, factor
78 |
79 | compile_opt idl2, logical_predicate
80 |
81 | ; Convert the two-dimensional array coordinates to a one-dimensional coordinate.
82 |
83 | k = j * xDim + i
84 |
85 | ; Set initial return value
86 |
87 | index = -1
88 |
89 | if ((factor eq 0) and (arrayIndex[k] ne arrayIndex[k+1])) then $
90 |
91 | ; If no expansion is needed, simply get the indices
92 |
93 | index = arrayIndex[arrayIndex[k]:arrayIndex[k+1]-1] $
94 |
95 | else begin
96 |
97 | doInd = 0
98 |
99 | ; If an expansion is needed, get the expanded coordinates.
100 |
101 | iStart = (i - factor) > 0
102 | iEnd = (i + factor) < (xDim - 1)
103 | iEnd += 1
104 |
105 | jStart = (j - factor) > 0
106 | jEnd = (j + factor) < (yDim - 1)
107 |
108 | ; Convert the 2D coordiates to 1D coordinates.
109 |
110 | jRange = jEnd - jStart
111 | kStart = (jStart + lindgen(jRange + 1)) * xDim
112 |
113 | kEnd = kStart + iEnd
114 | kStart = kStart + iStart
115 |
116 | for a=0,jRange do begin
117 |
118 | ; If they exist, get all the corresponding indices.
119 |
120 | if arrayIndex[kStart[a]] ne arrayIndex[kEnd[a]] then begin
121 |
122 | index = [index,arrayIndex[arrayIndex[kStart[a]]:arrayIndex[kEnd[a]]-1]]
123 | doInd = 1
124 |
125 | endif
126 |
127 | endfor
128 |
129 | ; If indices were found, remove the first, '-1' element.
130 |
131 | if doInd then index = index[1:*]
132 |
133 | endelse
134 |
135 | return, index
136 |
137 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/GetUniqLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; GetUniqLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function is used to remove points in the LAS file that have same
9 | ; coordinates.
10 | ;
11 | ; AUTHOR:
12 | ;
13 | ; David Streutker
14 | ; Boise Center Aerospace Laboratory
15 | ; Idaho State University
16 | ; 322 E. Front St., Ste. 240
17 | ; Boise, ID 83702
18 | ; http://bcal.geology.isu.edu
19 | ;
20 | ; CALLING SEQUENCE:
21 | ;
22 | ; index = GetUniqLAS_BCAL(header, data)
23 | ;
24 | ; 'header' are the LAS file header obtained using ReadHeaderLAS_BCAL, and 'data'
25 | ; are LAS file data obtained by ReadLAS_BCAL procedures.
26 | ;
27 | ; RETURN VALUE:
28 | ;
29 | ; The function returns the LAS header and data for points with only unique
30 | ; coordinates
31 | ;
32 | ; KNOWN ISSUES:
33 | ;
34 | ; None.
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, March 2006.
39 | ;
40 | ;###########################################################################
41 | ;
42 | ; LICENSE
43 | ;
44 | ; This software is OSI Certified Open Source Software.
45 | ; OSI Certified is a certification mark of the Open Source Initiative.
46 | ;
47 | ; Copyright @ 2006 David Streutker, Idaho State University.
48 | ;
49 | ; This software is provided "as-is", without any express or
50 | ; implied warranty. In no event will the authors be held liable
51 | ; for any damages arising from the use of this software.
52 | ;
53 | ; Permission is granted to anyone to use this software for any
54 | ; purpose, including commercial applications, and to alter it and
55 | ; redistribute it freely, subject to the following restrictions:
56 | ;
57 | ; 1. The origin of this software must not be misrepresented; you must
58 | ; not claim you wrote the original software. If you use this software
59 | ; in a product, an acknowledgment in the product documentation
60 | ; would be appreciated, but is not required.
61 | ;
62 | ; 2. Altered source versions must be plainly marked as such, and must
63 | ; not be misrepresented as being the original software.
64 | ;
65 | ; 3. This notice may not be removed or altered from any source distribution.
66 | ;
67 | ; For more information on Open Source Software, visit the Open Source
68 | ; web site: http://www.opensource.org.
69 | ;
70 | ;###########################################################################
71 |
72 | pro GetUniqLAS_BCAL, header, data
73 |
74 | compile_opt idl2, logical_predicate
75 |
76 | xMax = max(data.east, min=xMin)
77 | yMax = max(data.north, min=yMin)
78 | zMin = min(data.elev)
79 |
80 | eastRange = ulong64(xMax - xMin)
81 | northRange = ulong64(yMax - yMin)
82 |
83 | uniqCoords = eastRange * northRange * (data.elev - zMin) $
84 | + eastRange * (data.north - yMin) $
85 | + (data.east - xMin)
86 |
87 | uniqCoords = uniq(uniqCoords, sort(uniqCoords))
88 |
89 | nUniq = n_elements(uniqCoords)
90 |
91 | if nUniq ne header.nPoints then begin
92 |
93 | data = data[uniqCoords]
94 |
95 | header.nPoints = nUniq
96 |
97 | endif
98 |
99 |
100 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/InitRecordLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; InitRecordLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read a variable length record from an .las
9 | ; lidar file.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; David Streutker
16 | ; Boise Center Aerospace Laboratory
17 | ; Idaho State University
18 | ; 322 E. Front St., Ste. 240
19 | ; Boise, ID 83702
20 | ; http://bcal.geology.isu.edu
21 | ;
22 | ; CALLING SEQUENCE:
23 | ;
24 | ; record = InitRecordLAS(NODATA=NODATA, versionMajor=versionMajor, versionMinor=versionMinor)
25 | ;
26 | ; RETURN VALUE:
27 | ;
28 | ; The function returns a structure corresponding to the variable length record of the .las
29 | ; file specification. Set the NODATA keyword to return a structure that does not contain
30 | ; the data pointer.
31 | ;
32 | ; MODIFICATION HISTORY:
33 | ;
34 | ; Written by David Streutker, July 2007.
35 | ; Added version keywords to handle LAS 1.4, April 2016
36 | ;
37 | ;###########################################################################
38 | ;
39 | ; LICENSE
40 | ;
41 | ; This software is OSI Certified Open Source Software.
42 | ; OSI Certified is a certification mark of the Open Source Initiative.
43 | ;
44 | ; Copyright � 2007 David Streutker, Idaho State University.
45 | ;
46 | ; This software is provided "as-is", without any express or
47 | ; implied warranty. In no event will the authors be held liable
48 | ; for any damages arising from the use of this software.
49 | ;
50 | ; Permission is granted to anyone to use this software for any
51 | ; purpose, including commercial applications, and to alter it and
52 | ; redistribute it freely, subject to the following restrictions:
53 | ;
54 | ; 1. The origin of this software must not be misrepresented; you must
55 | ; not claim you wrote the original software. If you use this software
56 | ; in a product, an acknowledgment in the product documentation
57 | ; would be appreciated, but is not required.
58 | ;
59 | ; 2. Altered source versions must be plainly marked as such, and must
60 | ; not be misrepresented as being the original software.
61 | ;
62 | ; 3. This notice may not be removed or altered from any source distribution.
63 | ;
64 | ; For more information on Open Source Software, visit the Open Source
65 | ; web site: http://www.opensource.org.
66 | ;
67 | ;###########################################################################
68 |
69 | function InitRecordLAS_BCAL, noData = noData, versionMajor=versionMajor, versionMinor=versionMinor
70 |
71 | compile_opt idl2, logical_predicate
72 |
73 | ; Define the variable length header structure
74 |
75 | record = {formatR0, $
76 | signature : 0US, $ ; Record signature
77 | userID : bytarr(16), $ ; User ID
78 | recordID : 0US, $ ; Record ID
79 | recordLength : 0US, $ ; Record length after header
80 | description : bytarr(32) $ ; Description
81 | }
82 |
83 | if ~ keyword_set(noData) then record = {formatR1, inherits formatR0, data : ptr_new(/allocate)} ; Data pointer
84 |
85 | if (N_Elements(versionMajor) && N_Elements(versionMior)) then begin
86 |
87 | ; If LAS 1.4, define the variable length header structure differently
88 |
89 | if (versionMajor eq 1) && (versionMinor eq 4) then begin
90 | record = {formatR14, $
91 | signature : 0US, $ ; Record signature
92 | userID : bytarr(16), $ ; User ID
93 | recordID : 0US, $ ; Record ID
94 | recordLength : 0ULL, $ ; Record length after header
95 | description : bytarr(32) $ ; Description
96 | }
97 |
98 | if ~ keyword_set(noData) then record = {formatR14n, inherits formatR14, data : ptr_new(/allocate)} ; Data pointer
99 | endif
100 |
101 | endif
102 |
103 | return, record
104 |
105 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/ReadCommonHeaderLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReadCommonHeaderLAS
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read some begining part in the header of a .las
9 | ; lidar file, which is in a common format for versions 1.2 and up.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; Exelis VIS
16 | ;
17 | ; CALLING SEQUENCE:
18 | ;
19 | ; commonHeader = ReadCommonHeaderLAS(lasFile)
20 | ;
21 | ; RETURN VALUE:
22 | ;
23 | ; The function returns a structure corresponding to items from File Signature to Header Size in the header of a .las file.
24 | ;
25 | ; KNOWN ISSUES:
26 | ;
27 | ; None.
28 | ;
29 | ; MODIFICATION HISTORY:
30 | ;
31 | ; Written by Exelis VIS, April, 2016.
32 | ;
33 | ;###########################################################################
34 | ;
35 | ; LICENSE
36 | ;
37 | ; This software is OSI Certified Open Source Software.
38 | ; OSI Certified is a certification mark of the Open Source Initiative.
39 | ;
40 | ; Copyright � 2006 David Streutker, Idaho State University.
41 | ;
42 | ; This software is provided "as-is", without any express or
43 | ; implied warranty. In no event will the authors be held liable
44 | ; for any damages arising from the use of this software.
45 | ;
46 | ; Permission is granted to anyone to use this software for any
47 | ; purpose, including commercial applications, and to alter it and
48 | ; redistribute it freely, subject to the following restrictions:
49 | ;
50 | ; 1. The origin of this software must not be misrepresented; you must
51 | ; not claim you wrote the original software. If you use this software
52 | ; in a product, an acknowledgment in the product documentation
53 | ; would be appreciated, but is not required.
54 | ;
55 | ; 2. Altered source versions must be plainly marked as such, and must
56 | ; not be misrepresented as being the original software.
57 | ;
58 | ; 3. This notice may not be removed or altered from any source distribution.
59 | ;
60 | ; For more information on Open Source Software, visit the Open Source
61 | ; web site: http://www.opensource.org.
62 | ;
63 | ;###########################################################################
64 |
65 | function ReadCommonHeaderLAS_BCAL, inputFile
66 |
67 | compile_opt idl2, logical_predicate
68 |
69 | ; Define the public header structure
70 |
71 | header = { $
72 | signature : byte('LASF'), $ ; File signature
73 | fileSource : 0US, $ ; File source ID
74 | reserved : 0US, $ ; Reserved
75 | guid1 : 0UL, $ ; Project ID - GUID data 1
76 | guid2 : 0US, $ ; Project ID - GUID data 2
77 | guid3 : 0US, $ ; Project ID - GUID data 3
78 | guid4 : bytarr(8), $ ; Project ID - GUID data 4
79 | versionMajor : 1B, $ ; Version major
80 | versionMinor : 1B, $ ; Version minor
81 | systemID : bytarr(32), $ ; System identifier
82 | softwareID : bytarr(32), $ ; Generating software
83 | day : 0US, $ ; File creation day of year
84 | year : 0US, $ ; File creation year
85 | headerSize : 227US $ ; Header size
86 | }
87 |
88 | ; Open the file and read the common header parts from it
89 |
90 | openr, inputLun, inputFile, /get_lun, /swap_if_big_endian
91 | readu, inputLun, header
92 | free_lun, inputLun
93 | return, header
94 |
95 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/ReadHeaderLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReadHeaderLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This program reads the header from the specified .las file.
9 | ;
10 | ; For more information on the .las lidar data format, see http://www.lasformat.org
11 | ;
12 | ; AUTHOR:
13 | ;
14 | ; David Streutker
15 | ; Boise Center Aerospace Laboratory
16 | ; Idaho State University
17 | ; 322 E. Front St., Ste. 240
18 | ; Boise, ID 83702
19 | ; http://bcal.geology.isu.edu
20 | ;
21 | ; CALLING SEQUENCE:
22 | ;
23 | ; ReadHeaderLAS, inputFile, header
24 | ;
25 | ; InputFile is the name of the requested .las file.
26 | ;
27 | ; RETURN VALUE:
28 | ;
29 | ; The program returns a structure containing the header information from the
30 | ; specified .las file.
31 | ;
32 | ; KNOWN ISSUES:
33 | ;
34 | ; None.
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, March 2006.
39 | ; Changed CLOSE command to FREE_LUN, April 2006 (DRS)
40 | ; Replaced by NODATA keyword in ReadLAS_BCAL.pro, June 2007
41 | ; Modified to handle LAS 1.3 and 1.4, April 2016
42 | ;
43 | ;###########################################################################
44 | ;
45 | ; LICENSE
46 | ;
47 | ; This software is OSI Certified Open Source Software.
48 | ; OSI Certified is a certification mark of the Open Source Initiative.
49 | ;
50 | ; Copyright � 2006 David Streutker, Idaho State University.
51 | ;
52 | ; This software is provided "as-is", without any express or
53 | ; implied warranty. In no event will the authors be held liable
54 | ; for any damages arising from the use of this software.
55 | ;
56 | ; Permission is granted to anyone to use this software for any
57 | ; purpose, including commercial applications, and to alter it and
58 | ; redistribute it freely, subject to the following restrictions:
59 | ;
60 | ; 1. The origin of this software must not be misrepresented; you must
61 | ; not claim you wrote the original software. If you use this software
62 | ; in a product, an acknowledgment in the product documentation
63 | ; would be appreciated, but is not required.
64 | ;
65 | ; 2. Altered source versions must be plainly marked as such, and must
66 | ; not be misrepresented as being the original software.
67 | ;
68 | ; 3. This notice may not be removed or altered from any source distribution.
69 | ;
70 | ; For more information on Open Source Software, visit the Open Source
71 | ; web site: http://www.opensource.org.
72 | ;
73 | ;###########################################################################
74 |
75 | pro ReadHeaderLAS_BCAL, inputFile, header
76 |
77 | compile_opt idl2, logical_predicate
78 |
79 | ; Create the header structure
80 |
81 | commonHeader = ReadCommonHeaderLAS_BCAL(inputFile)
82 | header = InitHeaderLAS_BCAL(versionMajor=commonHeader.versionMajor, versionMinor=commonHeader.versionMinor)
83 |
84 | ; Open the file and read the header from it
85 |
86 | openr, inputLun, inputFile, /get_lun, /swap_if_big_endian
87 | readu, inputLun, header
88 | free_lun, inputLun
89 |
90 |
91 |
92 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/ScalePoly_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ScalePoly_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function scales a polygon by the requested amount.
9 | ;
10 | ; AUTHOR:
11 | ;
12 | ; David Streutker
13 | ; Boise Center Aerospace Laboratory
14 | ; Idaho State University
15 | ; 322 E. Front St., Ste. 240
16 | ; Boise, ID 83702
17 | ; http://bcal.geology.isu.edu
18 | ;
19 | ; CALLING SEQUENCE:
20 | ;
21 | ; result = ScalePoly(Coordinates,Factor)
22 | ;
23 | ; RETURN VALUE:
24 | ;
25 | ; The function returns the coordinates scaled by the factor amount.
26 | ;
27 | ; Coordinates is a [2,n] array of polygon coordinates. Factor is the value by which
28 | ; the coordinates are scaled. Factor can be vector to scale the polygon differently in
29 | ; each direction. Positive values of Factor increase the size of the polygon, while
30 | ; negative values decrease it.
31 | ;
32 | ; DEPENDENCIES:
33 | ;
34 | ; GetBounds_BCAL.pro
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, June 2006.
39 | ;
40 | ;###########################################################################
41 | ;
42 | ; LICENSE
43 | ;
44 | ; This software is OSI Certified Open Source Software.
45 | ; OSI Certified is a certification mark of the Open Source Initiative.
46 | ;
47 | ; Copyright @ 2006 David Streutker, Idaho State University.
48 | ;
49 | ; This software is provided "as-is", without any express or
50 | ; implied warranty. In no event will the authors be held liable
51 | ; for any damages arising from the use of this software.
52 | ;
53 | ; Permission is granted to anyone to use this software for any
54 | ; purpose, including commercial applications, and to alter it and
55 | ; redistribute it freely, subject to the following restrictions:
56 | ;
57 | ; 1. The origin of this software must not be misrepresented; you must
58 | ; not claim you wrote the original software. If you use this software
59 | ; in a product, an acknowledgment in the product documentation
60 | ; would be appreciated, but is not required.
61 | ;
62 | ; 2. Altered source versions must be plainly marked as such, and must
63 | ; not be misrepresented as being the original software.
64 | ;
65 | ; 3. This notice may not be removed or altered from any source distribution.
66 | ;
67 | ; For more information on Open Source Software, visit the Open Source
68 | ; web site: http://www.opensource.org.
69 | ;
70 | ;###########################################################################
71 |
72 |
73 | function ScalePoly_BCAL, coords, d
74 |
75 | compile_opt idl2, logical_predicate
76 |
77 | ; Check whether the scale factor is one or two elements.
78 |
79 | if n_elements(d) eq 1 then d = [d,d]
80 |
81 | ; Get the x and y values of the coordinates and determine the mid-points and the ranges.
82 |
83 | x = coords[0,*]
84 | y = coords[1,*]
85 |
86 | xRange = max(x) - min(x)
87 | yRange = max(y) - min(y)
88 |
89 | xMid = (max(x) + min(x)) / 2
90 | yMid = (max(y) + min(y)) / 2
91 |
92 | ; Determine if the points are on the positive or negative side of the mid-points.
93 |
94 | xPos = where(x gt xMid, complement=xNeg)
95 | yPos = where(y gt yMid, complement=yNeg)
96 |
97 | ; Make sure the polygon is larger than the amount by which it is to be scaled. (This
98 | ; only applies for a negative scaling.)
99 |
100 | if xRange gt (-2)*d[0] then begin
101 |
102 | ; Scale the x coordinates
103 |
104 | x[xPos] = x[xPos] + d[0]
105 | x[xNeg] = x[xNeg] - d[0]
106 |
107 | endif
108 |
109 | if yRange gt (-2)*d[1] then begin
110 |
111 | ; Scale the y coordinates
112 |
113 | y[yPos] = y[yPos] + d[1]
114 | y[yNeg] = y[yNeg] - d[1]
115 |
116 | endif
117 |
118 | ; Call GetBounds_BCAL to eliminate any redundant points.
119 |
120 | bounds = GetBounds_BCAL(x,y)
121 | bounds = transpose(bounds)
122 |
123 | ; Return the new coordinates.
124 |
125 | return, [x[bounds],y[bounds]]
126 |
127 | end
128 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/lib/fsc/normalize_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ; NORMALIZE
4 | ;
5 | ; PURPOSE:
6 | ;
7 | ; This is a utility routine to calculate the scaling vector
8 | ; required to position a graphics primitive of specified range
9 | ; at a specific position in an arbitray coordinate system. The
10 | ; scaling vector is given as a two-element array like this:
11 | ;
12 | ; scalingVector = [translationFactor, scalingFactor]
13 | ;
14 | ; The scaling vector should be used with the [XYZ]COORD_CONV
15 | ; keywords of a graphics object or model. For example, if you
16 | ; wanted to scale an X axis into the coordinate range of -0.5 to 0.5,
17 | ; you might type something like this:
18 | ;
19 | ; xAxis->GetProperty, Range=xRange
20 | ; xScale = Normalize(xRange, Position=[-0.5, 0.5])
21 | ; xAxis, XCoord_Conv=xScale
22 | ;
23 | ; AUTHOR:
24 | ;
25 | ; FANNING SOFTWARE CONSULTING
26 | ; David Fanning, Ph.D.
27 | ; 1645 Sheely Drive
28 | ; Fort Collins, CO 80526 USA
29 | ; Phone: 970-221-0438
30 | ; E-mail: davidf@dfanning.com
31 | ; Coyote's Guide to IDL Programming: http://www.dfanning.com
32 | ;
33 | ; CATEGORY:
34 |
35 | ; Object Graphics
36 | ;
37 | ; CALLING SEQUENCE:
38 | ; xscaling = NORMALIZE(xrange, POSITION=position)
39 | ;
40 | ; INPUTS:
41 | ; XRANGE: A two-element vector specifying the data range.
42 | ;
43 | ; KEYWORD PARAMETERS:
44 | ; POSITION: A two-element vector specifying the location
45 | ; in the coordinate system you are scaling into. The vector [0,1]
46 | ; is used by default if POSITION is not specified.
47 | ;
48 | ; COMMON BLOCKS:
49 | ; None.
50 | ;
51 | ; EXAMPLE:
52 | ; See above.
53 | ;
54 | ; MODIFICATION HISTORY:
55 | ; Written by: David W. Fanning, OCT 1997.
56 | ; Fixed a problem with illegal divide by zero. 21 April 2005. DWF.
57 | ;-
58 |
59 | FUNCTION Normalize_BCAL, range, Position=position
60 | compile_opt idl2
61 |
62 | On_Error, 1
63 | IF N_Params() EQ 0 THEN Message, 'Please pass range vector as argument.'
64 |
65 | IF (N_Elements(position) EQ 0) THEN position = [0.0D, 1.0D] ELSE $
66 | position=Double(position)
67 | range = Double(range)
68 |
69 | scale = [((position[0]*range[1])-(position[1]*range[0])) / $
70 | ((range[1]-range[0]) > 1e-12), (position[1]-position[0])/((range[1]-range[0]) > 1e-12)]
71 |
72 | RETURN, scale
73 | END
74 | ;-------------------------------------------------------------------------
75 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/AddProjectionLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; AddProjectionLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; The purpose of this program is add projection information to LAS files
9 | ;
10 | ; PRODUCTS:
11 | ;
12 | ; The output is a new LAS file for each input LAS file. The output files have the same
13 | ; name as the input files.
14 | ;
15 | ; AUTHOR:
16 | ;
17 | ; David Streutker
18 | ; Boise Center Aerospace Laboratory
19 | ; Idaho State University
20 | ; 322 E. Front St., Ste. 240
21 | ; Boise, ID 83702
22 | ; http://bcal.geology.isu.edu/
23 | ;
24 | ; DEPENDENCIES:
25 | ;
26 | ; ReadLAS_BCAL.pro
27 | ; WriteLAS_BCAL.pro
28 | ; RecordsToProj_BCAL.pro
29 | ;
30 | ; MODIFICATION HISTORY:
31 | ;
32 | ; Written by David Streutker, June 2007.
33 | ; Modified to handle LAS 1.3 and 1.4, April 2016
34 | ;
35 | ;###########################################################################
36 | ;
37 | ; LICENSE
38 | ;
39 | ; This software is OSI Certified Open Source Software.
40 | ; OSI Certified is a certification mark of the Open Source Initiative.
41 | ;
42 | ; Copyright @ 2007 David Streutker, Idaho State University.
43 | ;
44 | ; This software is provided "as-is", without any express or
45 | ; implied warranty. In no event will the authors be held liable
46 | ; for any damages arising from the use of this software.
47 | ;
48 | ; Permission is granted to anyone to use this software for any
49 | ; purpose, including commercial applications, and to alter it and
50 | ; redistribute it freely, subject to the following restrictions:
51 | ;
52 | ; 1. The origin of this software must not be misrepresented; you must
53 | ; not claim you wrote the original software. If you use this software
54 | ; in a product, an acknowledgment in the product documentation
55 | ; would be appreciated, but is not required.
56 | ;
57 | ; 2. Altered source versions must be plainly marked as such, and must
58 | ; not be misrepresented as being the original software.
59 | ;
60 | ; 3. This notice may not be removed or altered from any source distribution.
61 | ;
62 | ; For more information on Open Source Software, visit the Open Source
63 | ; web site: http://www.opensource.org.
64 | ;
65 | ;###########################################################################
66 | ; Begin main program
67 |
68 | pro AddProjectionLAS_BCAL, event
69 |
70 | compile_opt idl2, logical_predicate
71 |
72 | ; Establish error handler. The most likely problem is that the user will open a data
73 | ; file that is too large to process.
74 |
75 | catch, theError
76 | if theError ne 0 then begin
77 | catch, /cancel
78 | help, /last_message, output=errText
79 | errMsg = dialog_message(errText, /error, title='Error processing request')
80 | return
81 | endif
82 |
83 | ; Get the input file(s)
84 |
85 | inputFiles = dialog_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files, /path)
86 | if (inputFiles[0] eq '') then return
87 |
88 | nFiles = n_elements(inputFiles)
89 |
90 | ; Get the output projection and the output directory
91 |
92 | readBase = widget_auto_base(title='Select Projection')
93 |
94 | dummy = widget_label(readBase, value='Set output projection:')
95 | dummy = widget_map(readBase, default_map=[0,0], default_proj=envi_proj_create(), uvalue='proj', /auto)
96 | dummy = widget_outf(readBase, /directory, prompt='Select output directory', uvalue='outDir', /auto)
97 |
98 | result = auto_wid_mng(readBase)
99 | if result.accept eq 0 then return
100 |
101 | proj = result.proj.proj
102 |
103 | outputDir = result.outDir
104 |
105 | ; Set up status message window
106 |
107 | statText = 'Initializing'
108 | statBase = widget_auto_base(title='Adding Projections')
109 | statField = widget_text(statBase, /scroll, value=statText, xsize=80, ysize=4)
110 | widget_control, statBase, /realize
111 |
112 | ; Process each data file individually
113 |
114 | for a=0,nFiles-1 do begin
115 |
116 | ; Update the status window
117 |
118 | statText = ['Adding projection to ' + inputFiles[a], statText]
119 | widget_control, statField, set_value=statText
120 |
121 | ; Read the input file
122 |
123 | ReadLAS_BCAL, inputFiles[a], header, data, records=records, versionMajor=versionMajor, versionMinor=versionMinor
124 |
125 | ; Update the array of records
126 |
127 | newRecord = RecordsToProj_BCAL(proj, versionMajor=versionMajor, versionMinor=versionMinor, /reverse)
128 |
129 | if n_tags(records) then begin
130 |
131 | rIndex = where(records.recordID eq 34735, rCount)
132 |
133 | if rCount then begin
134 |
135 | mText = 'The file ' + file_basename(inputFiles[a]) + ' appears to already contain projection ' $
136 | + 'information. Do you want to rewrite it the projection?'
137 | query = dialog_message(mText, /center, /question, /default_no)
138 |
139 | if query eq 'Yes' then records[rIndex] = newRecord
140 |
141 | endif else records = [records,newRecord]
142 |
143 | endif else records = newRecord
144 |
145 | ; Write the new file
146 |
147 | outputFile = outputDir + '\' + file_basename(inputFiles[a])
148 |
149 | WriteLAS_BCAL, outputFile, header, data, records=records, /check
150 |
151 | endfor
152 |
153 | ; Destroy the status window
154 |
155 | widget_control, statBase, /destroy
156 |
157 |
158 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/LidarMetrics_BCAL.pro:
--------------------------------------------------------------------------------
1 |
2 | PRO LidarMetrics_BCAL, event
3 |
4 | compile_opt idl2, logical_predicate
5 |
6 | Catch, theError
7 | IF theError NE 0 THEN BEGIN
8 | Catch, /Cancel
9 | Help, /last_message, output=errText
10 | errMsg = dialog_message(errText, /error, title='Error processing file')
11 | return
12 | ENDIF
13 |
14 | ; read LAS files
15 |
16 | inputFiles = dialog_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files, /path)
17 | if (inputFiles[0] eq '') then return
18 |
19 | nFiles = n_elements(inputFiles)
20 |
21 | ; Read the first data file for header info
22 |
23 | ReadLAS_BCAL, inputFiles[0], header, /nodata
24 |
25 | treturns = header.nreturns
26 |
27 |
28 | ; read EVF files
29 |
30 | evfFiles = dialog_pickfile(title='Select EVF file(s)', filter='*.evf', /path)
31 | if (evfFiles[0] eq '') then return
32 |
33 | oEvf = Obj_New('IDLanROIGroup')
34 |
35 | for b=0, n_elements(evfFiles)-1 do begin
36 |
37 | evfID = envi_evf_open(evfFiles[b])
38 | envi_evf_info, evfID, num_recs=nrecs
39 |
40 | for c = 0, nrecs-1 do begin
41 | evfCoords = envi_evf_read_record(evfID, c)
42 | oEvf->Add, Obj_New('IDLanROI', evfCoords)
43 | endfor
44 |
45 | envi_evf_close, evfID
46 | endfor
47 |
48 | ; Create list of metrics
49 |
50 | metrics = {minElev :{title:'Minimum', index:-1, doIt:0}, $
51 | maxElev :{title:'Maximum', index:-1, doIt:0}, $
52 | rangeElev :{title:'Range', index:-1, doIt:0}, $
53 | meanElev :{title:'Arithmetic mean', index:-1, doIt:0}, $
54 | stdevElev :{title:'Standard deviation',index:-1, doIt:0}, $
55 | varElev :{title:'Variance', index:-1, doIt:0}, $
56 | skewElev :{title:'Skewness', index:-1, doIt:0}, $
57 | kurElev :{title:'Kurtosis', index:-1, doIt:0}, $
58 | cvElev :{title:'Coefficient of variation', index:-1, doIt:0}}
59 |
60 | nmetrics = n_tags(metrics)
61 | metricsList = strarr(nmetrics)
62 | metricsIndex = bytarr(nmetrics)
63 | metricsIndex[0] = 1
64 | for f=0, nmetrics-1 do metricsList[f] = metrics.(f).title
65 |
66 | ; initialize the user interface
67 |
68 | nReturns = n_elements(tReturns)
69 |
70 | returnList = indgen(nReturns) + 1
71 | returnList = ' Return ' + strcompress(returnList)
72 | returnList = ['All Returns', returnList]
73 |
74 | gridBase = widget_auto_base(title='Lidar Metrics')
75 | topBase = widget_base(gridBase, /row)
76 | leftBase = widget_base(topBase, /column)
77 |
78 | returnBase = widget_base(leftBase, /row)
79 | dummy = widget_pmenu(returnBase, list=returnList, default=nReturns, prompt='Select return number: ', $
80 | uvalue='returns', /auto_manage)
81 | dummy = widget_outf(leftBase, default='output.csv', prompt='Enter name of output file ', $
82 | uvalue='outFile', /auto)
83 |
84 | rightBase = widget_base(topBase)
85 | dummy = widget_multi(rightBase, list=metricsList, prompt='Select metrics:', /no_range, ysize=250, $
86 | default=metricsIndex, uvalue='metrics', /auto)
87 |
88 | result = auto_wid_mng(gridBase)
89 |
90 | if (result.accept eq 0) then return
91 | retNum = result.returns + 1
92 | metricsIndex = result.metrics
93 | CsvFile = result.outFile
94 |
95 | ; Create the list of metrics names
96 |
97 | bNames = metricsList[where(metricsIndex eq 1)]
98 | nBands = total(metricsIndex)
99 |
100 | ; Open output csv file for writing
101 |
102 | openw, CSVmetrics, CsvFile, /get_lun, width=1600
103 |
104 |
105 | for a=0, nFiles-1 do begin
106 |
107 | ; Read the data file.
108 |
109 | ReadLAS_BCAL, inputFiles[a], header, projection=defProj, pData
110 |
111 | iDim = ceil((header.xMax - xMinTile) / 0.5)
112 | jDim = ceil((header.yMax - yMinTile) / 0.5)
113 |
114 | arrayHist = histogram(floor((header.yOffset - header.yMin + pData.north * header.yScale) / baseScale) * xDim $
115 | + floor((header.xOffset - header.xMin + pData.east * header.xScale) / baseScale) $
116 | + xDim * yDim * ((retNum le nReturns) and ((pData.nReturn mod 8) ne retNum)) $
117 | + xDim * yDim * (pData.class eq 1), $
118 | reverse_indices=arrayIndex, min=0d, max=xDim*yDim)
119 |
120 | endfor
121 |
122 |
123 | for o=0, oEvf->Count()-1 do begin
124 | oTemp = oEvf->Get(position=o)
125 | oTemp->GetProperty, data=evfCoords
126 | printf, CSVmetrics, evfCoords[0,*], evfCoords[1,*]
127 | endfor
128 |
129 |
130 | free_lun, CSVmetrics
131 | close, CSVmetrics
132 |
133 | ;widget_control, gridBase, /destroy
134 | obj_destroy, oEvf
135 |
136 | END
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/NormalizeElevLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; NormalizeElevLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; Basically the same as NormalizeElev_ui
9 | ;
10 | ; DEPENDENCIES:
11 | ;
12 | ; ReadLAS_BCAL.pro
13 | ; WriteLAS_BCAL.pro
14 | ;
15 | ; MODIFICATION HISTORY:
16 | ;
17 | ; Implemented by Exelis VIS, April 2016.
18 | ;
19 | ;###########################################################################
20 | ;
21 | ; LICENSE
22 | ;
23 | ; This software is OSI Certified Open Source Software.
24 | ; OSI Certified is a certification mark of the Open Source Initiative.
25 | ;
26 | ; Copyright � 2006 David Streutker, Idaho State University.
27 | ;
28 | ; This software is provided "as-is", without any express or
29 | ; implied warranty. In no event will the authors be held liable
30 | ; for any damages arising from the use of this software.
31 | ;
32 | ; Permission is granted to anyone to use this software for any
33 | ; purpose, including commercial applications, and to alter it and
34 | ; redistribute it freely, subject to the following restrictions:
35 | ;
36 | ; 1. The origin of this software must not be misrepresented; you must
37 | ; not claim you wrote the original software. If you use this software
38 | ; in a product, an acknowledgment in the product documentation
39 | ; would be appreciated, but is not required.
40 | ;
41 | ; 2. Altered source versions must be plainly marked as such, and must
42 | ; not be misrepresented as being the original software.
43 | ;
44 | ; 3. This notice may not be removed or altered from any source distribution.
45 | ;
46 | ; For more information on Open Source Software, visit the Open Source
47 | ; web site: http://www.opensource.org.
48 | ;
49 | ;###########################################################################
50 |
51 |
52 | ; Begin main program
53 |
54 | pro NormalizeElevLAS_BCAL, event
55 |
56 | compile_opt idl2, logical_predicate
57 |
58 | ; Establish an error handler.
59 |
60 | catch, theError
61 | if theError ne 0 then begin
62 | catch, /cancel
63 | help, /last_message, output=errText
64 | errMsg = dialog_message(errText, /error, title='Error processing file', /center)
65 | return
66 | endif
67 |
68 |
69 | doProfile = 0
70 |
71 | ; Get the input file(s).
72 | inputFiles = envi_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files)
73 | if (inputFiles[0] eq '') then return
74 |
75 | outputDir = envi_pickfile(title='Select output directory', /directory)
76 | if outputDir eq '' then return
77 |
78 | ; Begin processesing each file
79 |
80 | minN = 0.05
81 | maxN = 1.8
82 |
83 | for a=0,n_elements(inputFiles)-1 do begin
84 |
85 | ; Establish the status reporting widget. This will report the processing status
86 | ; for each data file.
87 |
88 | statBase = widget_auto_base(title='Assigning')
89 | statText = ['Normalizing Progress:', file_basename(inputFiles[a]), $
90 | 'File' + strcompress(a+1) + ' of' + strcompress(n_elements(inputFiles))]
91 | envi_report_init, statText, base=statBase, /interrupt, title='Normalizing elevation...'
92 |
93 | ; Read the input data file.
94 |
95 | ReadLAS_BCAL, inputFiles[a], header, pData, records=records
96 |
97 | envi_report_stat, statBase, 33, 100, cancel=cancel
98 |
99 | g_index = where(pdata.source le ((minN - header.zOffset) / header.zScale), g_count, complement=t_index, ncomplement=t_count)
100 |
101 | if g_count ne 0 then begin
102 | pdata[g_index].class = 2
103 | pdata[g_index].source = 0
104 | endif
105 |
106 | if t_count ne 0 then pdata[t_index].class = 3
107 |
108 | envi_report_stat, statBase, 66, 100, cancel=cancel
109 |
110 | v_index = where(pdata.source gt ((maxN - header.zOffset) / header.zScale), v_count)
111 |
112 | if v_count ne 0 then begin
113 | pdata[v_index].class = 1
114 | pdata[v_index].source = 2^16 - 1
115 | endif
116 |
117 | envi_report_stat, statBase, 99, 100, cancel=cancel
118 |
119 | outputFile = outputDir + path_sep() + file_basename(inputFiles[a])
120 | WriteLAS_BCAL, outputFile, header, pData, records=records, /check
121 |
122 | envi_report_stat, statBase, 100, 100, cancel=cancel
123 | envi_report_init, base=statBase, /finish
124 |
125 | endfor
126 |
127 |
128 | end
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/ReclassifyLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReclassifyLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; The purpose of this program is to reclassify a LAS file
9 | ;
10 | ; PRODUCTS:
11 | ;
12 | ; The output is LAS file(s) with assigned reclassification
13 | ;
14 | ; AUTHOR:
15 | ;
16 | ; Rupesh Shrestha
17 | ; Boise Center Aerospace Laboratory
18 | ; Idaho State University
19 | ; 322 E. Front St., Ste. 240
20 | ; Boise, ID 83702
21 | ; http://bcal.geology.isu.edu/
22 | ;
23 | ; DEPENDENCIES:
24 | ;
25 | ; ReadLAS_BCAL.pro
26 | ; WriteLAS_BCAL.pro
27 | ;
28 | ; MODIFICATION HISTORY:
29 | ;
30 | ;
31 | ;###########################################################################
32 | ;
33 | ; LICENSE
34 | ;
35 | ; This software is OSI Certified Open Source Software.
36 | ; OSI Certified is a certification mark of the Open Source Initiative.
37 | ;
38 | ; Copyright @ 2010 Idaho State University.
39 | ;
40 | ; This software is provided "as-is", without any express or
41 | ; implied warranty. In no event will the authors be held liable
42 | ; for any damages arising from the use of this software.
43 | ;
44 | ; Permission is granted to anyone to use this software for any
45 | ; purpose, including commercial applications, and to alter it and
46 | ; redistribute it freely, subject to the following restrictions:
47 | ;
48 | ; 1. The origin of this software must not be misrepresented; you must
49 | ; not claim you wrote the original software. If you use this software
50 | ; in a product, an acknowledgment in the product documentation
51 | ; would be appreciated, but is not required.
52 | ;
53 | ; 2. Altered source versions must be plainly marked as such, and must
54 | ; not be misrepresented as being the original software.
55 | ;
56 | ; 3. This notice may not be removed or altered from any source distribution.
57 | ;
58 | ; For more information on Open Source Software, visit the Open Source
59 | ; web site: http://www.opensource.org.
60 | ;
61 | ;###########################################################################
62 |
63 | ; Begin main program
64 |
65 | pro ReclassifyLAS_BCAL, event
66 |
67 | compile_opt idl2, logical_predicate
68 |
69 | ; Establish error handler.
70 |
71 | catch, theError
72 | if theError ne 0 then begin
73 | catch, /cancel
74 | help, /last_message, output=errText
75 | errMsg = dialog_message(errText, /error, title='Error processing request')
76 | return
77 | endif
78 |
79 | ; Open input files
80 |
81 | inputFiles = dialog_pickfile(title='Select LiDAR file(s)', filter='*.las', /multiple_files)
82 | if (inputFiles[0] eq '') then return
83 |
84 | nFiles = n_elements(inputFiles)
85 |
86 | list = ['Class 0 :','Class 1 :','Class 2 :','Class 3 :','Class 4 :','Class 5 :','Class 6 :', $
87 | 'Class 7 :','Class 8 :','Class 9 :','Class 10 :','Class 11 :','Class 12 :']
88 |
89 | classIndex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
90 | ; Get the user parameters
91 |
92 | readBase = widget_auto_base(title='Reclassify LAS files')
93 |
94 | tileBase = widget_base(readBase, /row)
95 | dummy = widget_edit(tileBase, dt=2, list=list, $
96 | prompt='Reclassification:', vals=classIndex, ysize=13, uvalue='newIndex', /auto)
97 |
98 | outputBase = widget_base(readBase, /row)
99 | fileBase = widget_base(outputBase, /column)
100 | outputField = widget_outf(fileBase, prompt='Select output directory ', /directory, $
101 | uvalue='lasName', /auto)
102 |
103 | result = auto_wid_mng(readBase)
104 | if (result.accept eq 0) then return
105 |
106 | newIndex = result.newIndex
107 |
108 | outputDir = result.lasName
109 |
110 | cIndex = where(classIndex ne newIndex, nOut)
111 |
112 | if nOut ne 0 then begin
113 |
114 | classNames = classIndex[cIndex]
115 |
116 | ; Set up ENVI status reporting box
117 | statText1 = 'Reclassifying...'
118 | statText2 = 'LAS file: ' + FILE_BASENAME(inputFiles)
119 | statText = [statText1,statText2]
120 | statBase = widget_auto_base(title='Reclassification')
121 | ENVI_REPORT_INIT, statText, BASE=statBase, TITLE='Reclassifying'
122 | envi_report_inc, statBase, nFiles
123 |
124 | for a=0,nFiles-1 do begin
125 |
126 | ; Read input lidar data to an array of structures
127 |
128 | ReadLAS_BCAL, inputFiles[a], header, data, records=records, check=check, projection=projection
129 |
130 | for i = 0, nOut-1 do begin
131 |
132 | dindex = where(data.class eq classNames[i], count)
133 |
134 | if count ne 0 then begin
135 |
136 | data[dindex].class = newIndex[cIndex[i]]
137 |
138 | endif
139 |
140 | endfor
141 |
142 | outputFile = outputDir + '\' + file_basename(inputFiles[a])
143 |
144 | WriteLAS_BCAL, outputFile, header, data, records=records, /check
145 |
146 | envi_report_inc, statBase, a
147 |
148 |
149 | endfor
150 |
151 | endif else msgBox = DIALOG_MESSAGE('No new classification was assigned', /ERROR)
152 |
153 | ;; Complete status reporting widget
154 | envi_report_init, base=StatBase, /finish
155 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/ReturnsLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ; Sara Ehinger
2 | ; March 31, 2010
3 | ; Export Selected Returns Only
4 | ; First, Second, Third, Fouth, Fifth, Last
5 | ; DEPENDENCIES:
6 | ;
7 | ; INITDATALAS_BCAL.pro
8 |
9 | PRO ReturnsLAS_BCAL, event
10 |
11 | compile_opt idl2, logical_predicate
12 |
13 | Catch, theError
14 | IF theError NE 0 THEN BEGIN
15 | Catch, /Cancel
16 | Help, /last_message, output=errText
17 | errMsg = dialog_message(errText, /error, title='Error processing file')
18 | return
19 | ENDIF
20 |
21 | inputFile = envi_pickfile(title='Select LAS file', filter='*.las')
22 | if (inputFile eq '') then return
23 |
24 | ; ugh, need a god damn widget
25 | ; for return number and output file name
26 | ; for now hard code
27 | ; Drop down:
28 | ; Last Returns, 0
29 | ; First Returns, 1
30 | ; Second Returns, 2
31 | ; Third Returns, 3
32 | ; Fouth Returns, 4
33 | ; Fifth Returns, 5
34 | ; sReturn = result
35 | ; try first with old school idl widgets
36 | ; never mind, just use fancy envi auto widgets
37 |
38 | ReadLAS_BCAL, inputFile, header, data, records=records, projection=projection
39 | numOrigPts = header.nPoints
40 | numReturns = header.nReturns
41 |
42 | topBase = widget_auto_base(title='Export lidar data by return number')
43 |
44 | labelText = 'Selected File: ' + file_basename(inputFile)
45 | labelBase = widget_slabel(topBase, prompt=labelText, /frame)
46 |
47 | returnList = ['Last Returns','First Returns','Second Returns','Third Returns','Fourth Returns','Fifth Returns']
48 | returnBase = widget_pmenu(topBase, prompt='Select Returns', list=returnList, uvalue='outr', /auto)
49 |
50 | defOutF = file_dirname(inputFile) + '\' + file_basename(inputFile, '.las') + '_selected' + '.las'
51 | outBase = widget_outf(topBase, default=defOutF, uvalue='outf', /auto)
52 |
53 | result = auto_wid_mng(topBase)
54 | if result.accept eq 0 then return
55 |
56 |
57 | sReturn = result.outr
58 | outputFile = result.outf
59 |
60 |
61 |
62 | CASE sReturn OF
63 | 0: exportA = WHERE(floor(data.nReturn/8) mod 8 - data.nReturn mod 8 EQ sReturn, count)
64 | ELSE: exportA = WHERE(data.nReturn mod 8 EQ sReturn, count)
65 | ENDCASE
66 | ; warning if count = 0!
67 |
68 | IF count GT 0 THEN BEGIN
69 | dataStr2 = InitDataLAS_BCAL(pointFormat=header.POINTFORMAT)
70 | data2 = replicate(dataStr2, count)
71 | for a=0,count-1 do begin
72 | tempIndex = exportA[a]
73 | data2[a] = data[tempIndex]
74 | endfor
75 | ENDIF ELSE BEGIN
76 | msgText = 'There were no returns that matched your selection. Export cancelled.'
77 | msgBox = dialog_message(msgText)
78 | ; Add a return to widget?
79 | RETURN
80 | ENDELSE
81 |
82 | WriteLAS_BCAL, outputFile, header, data2, records=records, /check
83 |
84 | msgText = strcompress([sReturn, numOrigPts, count])
85 | msgBox = dialog_message(msgText, /information)
86 |
87 | data = 0B
88 | data2 = 0B
89 | header = 0B
90 |
91 | END ; ReturnsLAS.pro
92 |
93 |
94 |
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/Wizard/Wizard_Data_Input.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; This function is to act as the data input tool. We will try to perform some operations automatically and save
3 | ; files automatically along the way.
4 | function GetFileList, id
5 |
6 | stash = WIDGET_INFO(id, /CHILD)
7 | WIDGET_CONTROL, stash, GET_UVALUE=fileLoadStash, /NO_COPY
8 | files = fileLoadStash.fileList
9 |
10 | WIDGET_CONTROL, stash, SET_UVALUE=fileLoadStash, /NO_COPY
11 | return, files
12 | end
13 |
14 | function Wizard_Data_Input, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
15 |
16 | dataInputBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_LEFT, $
17 | XSIZE=width, SPACE=20, EVENT_PRO='WIZARD_DATA_INPUT_EV', FUNC_GET_VALUE='GetFileList')
18 |
19 | titleText = WIDGET_LABEL(dataInputBase, value='Data Preprocessing', FONT='Arial*BOLD*UNDERLINE', $
20 | /ALIGN_CENTER)
21 |
22 |
23 | descriptionLabel = WIDGET_LABEL(dataInputBase, value= $
24 | 'Please start by uploading a LiDAR dataset either in ' + String(13b) $
25 | + '.las or another text format (ASCII).', /ALIGN_LEFT, YSIZE=135, FONT='Arial*16')
26 |
27 | ;base widget for the file upload line
28 | fileLoadRowBase = WIDGET_BASE(dataInputBase, /ROW, /ALIGN_CENTER, XSIZE=width)
29 | fileLoadLabel = WIDGET_LABEL(fileLoadRowBase, UVALUE='fileLoadLabel', value='Input Dataset: ', /ALIGN_LEFT, FONT='Arial*15')
30 |
31 | fileLoadList = WIDGET_LIST(fileLoadRowBase, XSIZE=50, YSIZE=10, XOFFSET=10, UVALUE='fileList')
32 | fileList = ['']
33 | selected = -1
34 |
35 | btnsGroup = WIDGET_BASE(fileLoadRowBase, UVALUE='btnBase', XSIZE=125, /COLUMN)
36 |
37 | fileLoadBtn = WIDGET_BUTTON(btnsGroup, XSIZE=125, FONT='Arial*15', VALUE='Add File', UVALUE='FileBrowse', YSIZE=30)
38 | fileRemoveBtn = WIDGET_BUTTON(btnsGroup, XSIZE=125, FONT='Arial*15', VALUE='Remove Selected', UVALUE='fileRemove',YSIZE=30, YOFFSET=20)
39 |
40 |
41 |
42 | fileLoadStash = {fileLoadList:fileLoadList, selected:selected, fileList:fileList}
43 |
44 | WIDGET_CONTROL, WIDGET_INFO(dataInputBase, /CHILD), SET_UVALUE=fileLoadStash, /NO_COPY
45 |
46 | return, dataInputBase
47 | END
48 |
49 | ;function to get the file from the user and perform analysis
50 | function GetFiles
51 |
52 | inputFiles = ENVI_PICKFILE(TITLE='Select Input LiDAR Dataset', FILTER='*.las', /MULTIPLE_FILES)
53 | return, inputFiles
54 |
55 | end
56 |
57 | PRO WIZARD_DATA_INPUT_EV, ev
58 |
59 | ;This grabs the local stashed variable
60 | base = ev.handler
61 | stash = WIDGET_INFO(base, /CHILD)
62 | WIDGET_CONTROL, stash, GET_UVALUE=fileLoadStash, /NO_COPY
63 |
64 | ;get the button pressed
65 | WIDGET_CONTROL, ev.ID, GET_UVALUE=command
66 | CASE command OF
67 | 'FileBrowse': BEGIN
68 | ;get the file
69 | inputFiles = GetFiles()
70 | ;get the array
71 |
72 | ;list = WIDGET_INFO(fileLoadStash.fileLoadList)
73 | ;append to existing
74 | if fileLoadStash.fileList[0] EQ '' then begin
75 | files = inputFiles
76 | endif else begin
77 | files = [fileLoadStash.fileList, inputFiles]
78 | endelse
79 |
80 | ;set back to list
81 | WIDGET_CONTROL, fileLoadStash.fileLoadList, SET_VALUE=files
82 |
83 |
84 | ;now we want to try and make the top level next button visible
85 | WIDGET_CONTROL, ev.TOP, GET_UVALUE=MainStash
86 | Widget_Control, MainStash.nextBtn, Sensitive=1
87 |
88 | ;recreate the stash as we have a new array
89 | fileLoadStash ={fileLoadList:fileLoadStash.fileLoadList, selected:fileLoadStash.selected, fileList:files}
90 |
91 | END
92 | 'fileList': BEGIN
93 | ;set the currently selected item
94 | fileLoadStash.selected = ev.INDEX
95 |
96 | END
97 | 'fileRemove': BEGIN
98 | if fileLoadStash.selected NE -1 then begin
99 | index = fileLoadStash.selected
100 | array = fileLoadStash.fileList
101 | first = 0
102 | last = N_Elements(array)-1
103 | if last ne 0 then begin
104 | CASE index OF
105 | first: array = array[1:*]
106 | last: array = array[first:last-1]
107 | ELSE: array = [ array[first:index-1], array[index+1:last] ]
108 | ENDCASE
109 | endif else begin
110 | array = ['']
111 | endelse
112 | ;set back to list
113 | WIDGET_CONTROL, fileLoadStash.fileLoadList, SET_VALUE=array
114 | fileLoadStash ={fileLoadList:fileLoadStash.fileLoadList, selected:fileLoadStash.selected, fileList:array}
115 | endif
116 |
117 | END
118 | ENDCASE
119 | WIDGET_CONTROL, stash, SET_UVALUE=fileLoadStash, /NO_COPY
120 |
121 | END
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/Wizard/Wizard_Generate_Data.pro:
--------------------------------------------------------------------------------
1 |
2 | function Wizard_Generate_Data, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
3 | genDataBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_CENTER, XSIZE=width, SPACE=20)
4 | titleText = WIDGET_LABEL(genDataBase, value='Generate Result Data', FONT='Arial*BOLD*UNDERLINE', $
5 | /ALIGN_CENTER)
6 | textWidget = WIDGET_TEXT(genDataBase, value="With Height Filtering complete, all that is left is" $
7 | + " to generate the rasters. Pressing the 'Finish' button will launch the Generate Rasters tool." $
8 | + " Once complete, the data will reside in a subdirectory off of the input file.", /WRAP, XSIZE=64, YSIZE=4)
9 |
10 |
11 | ;have to specify the event-handler manually when inside a function apparently
12 | ;XMANAGER, 'Wizard_Generate_Data', genDataBase, EVENT_HANDLER='Wizard_Generate_Data_ev'
13 | return, genDataBase
14 | END
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/Wizard/Wizard_Height_Filtering.pro:
--------------------------------------------------------------------------------
1 | ; This file contains the ui for the height filtering
2 | ; We will include the ability to utilize a previously height filtered data set
3 |
4 | PRO Wizard_Height_Filtering_EV, event
5 | END
6 |
7 | FUNCTION Wizard_Height_Filtering, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
8 |
9 | HeightFilterBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_LEFT, $
10 | XSIZE=width, SPACE=20, EVENT_PRO='Wizard_Height_Filtering_EV', FUNC_GET_VALUE='GetHeightFilteringSelection')
11 |
12 | titleText = WIDGET_LABEL(HeightFilterBase, value='Height Filtering', FONT='Arial*BOLD*UNDERLINE', $
13 | /ALIGN_CENTER)
14 |
15 | descriptionLabel = WIDGET_TEXT( HeightFilterBase, VALUE="Now that the data has been prepared, we need to perform height" + $
16 | " filtering. In some cases, height fltering may have already been performed either by BCAL tools, or" + $
17 | " other toolsets. If you don't know, just click the 'Next' button below.", /WRAP, XSIZE=64, YSIZE=6)
18 |
19 | RadioButtonBase = WIDGET_BASE(HeightFilterBase, SCR_XSIZE=500, /Exclusive)
20 |
21 | NotFilteredBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Not Height Filtered")
22 | FilteredBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Height Filtered Using External Tools")
23 | FilteredBCALBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Height Filtered using BCAL tools")
24 | ;set the default state to be not filtered
25 | Widget_Control, NotFilteredBtn, Set_Button=1
26 |
27 | heightFilterStash = {NotFiltered:NotFilteredBtn, Filtered:FilteredBtn, FilteredBCAL:FilteredBCALBtn}
28 | WIDGET_CONTROL, WIDGET_INFO(HeightFilterBase, /CHILD), SET_UVALUE=heightFilterStash, /NO_COPY
29 |
30 | return, HeightFilterBase
31 |
32 | END
33 |
34 | FUNCTION GetHeightFilteringSelection, id
35 | ; we are going to use return values of 0, 1, and 2 for not filtered, filtered using external tools
36 | ; and filtered using BCAL tools respectively
37 | stash = WIDGET_INFO(id, /CHILD)
38 | WIDGET_CONTROL, stash, GET_UVALUE=heightFilterStash, /NO_COPY
39 | ;grab the buttons
40 | notFiltered = WIDGET_INFO(heightFilterStash.NotFiltered, /BUTTON_SET)
41 | Filtered = WIDGET_INFO(heightFilterStash.Filtered, /BUTTON_SET)
42 | FilteredBCAL = WIDGET_INFO(heightFilterStash.FilteredBCAL, /BUTTON_SET)
43 |
44 | ;WIDGET_CONTROL, heightFilterStash.Filtered, GET_VALUE=FilteredBtn
45 | ;WIDGET_CONTROL, heightFilterStash.FilteredBCAL, GET_VALUE=FilteredBCALBtn
46 | if (notFiltered EQ 1) then return, 0
47 | if (Filtered EQ 1) then return, 1
48 | if (FilteredBCAL EQ 1) then return, 2
49 |
50 |
51 | END
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/Wizard/Wizard_Intro.pro:
--------------------------------------------------------------------------------
1 | PRO Wizard_Intro_Event, ev
2 | base = ev.handler
3 | stash = WIDGET_INFO(base, /CHILD)
4 | WIDGET_CONTROL, stash, GET_UVALUE=introStash, /NO_COPY
5 |
6 | ;get the button pressed
7 | WIDGET_CONTROL, ev.ID, GET_UVALUE=command
8 | CASE command OF
9 | 'folderBrowse': BEGIN
10 | folder = ENVI_PICKFILE(TITLE='Choose an Output Folder', /DIRECTORY) + '\'
11 | ;folder = 'C:\proc' + '\'
12 | WIDGET_CONTROL, introStash.folderLoadText, SET_VALUE=folder
13 | WIDGET_CONTROL, ev.TOP, GET_UVALUE=MainStash
14 | Widget_Control, MainStash.nextBtn, Sensitive=1
15 |
16 | END
17 | END
18 |
19 | WIDGET_CONTROL, stash, SET_UVALUE=introStash, /NO_COPY
20 | END
21 |
22 |
23 | function Wizard_Intro, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode
24 | ;COMPILE_OPT hidden
25 |
26 | introBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, /BASE_ALIGN_TOP, XSIZE=450, YSIZE=550, FUNC_GET_VALUE='GetRootFolder', EVENT_PRO='Wizard_Intro_Event')
27 |
28 | titleText = WIDGET_LABEL(introBase, value='BCAL LiDAR Processing Wizard', FONT='Arial*BOLD*UNDERLINE', $
29 | /ALIGN_CENTER)
30 |
31 | descriptionText = WIDGET_LABEL(introBase, value= String(13B) $
32 | + 'Welcome to the BCAL LiDAR Processing Wizard. '$
33 | + String(13B) $
34 | + String(13B) $
35 | + 'This wizard will guide you through several processing steps '$
36 | + String(13B) $
37 | + 'typical for analysing LiDAR data with the BCAL tools. '$
38 | + String(13B) $
39 | + 'This tool will only include common workflows.' $
40 | + String(13B) $
41 | + 'More refined processing may require further investigation with ' $
42 | + String(13B) $
43 | + 'the other BCAL LiDAR tools.',$
44 | /ALIGN_CENTER, YSIZE=300, FONT='Arial*18')
45 |
46 | ;Directory chooser
47 | folderLoadRowBase = WIDGET_BASE(introBase, /ROW, /ALIGN_CENTER, XSIZE=width, YOFFSET=50)
48 | folderLoadLabel = WIDGET_LABEL(folderLoadRowBase, UVALUE='folderLoadLabel', value='Output Folder ', /ALIGN_LEFT, FONT='Arial*15')
49 | folderLoadText = WIDGET_TEXT(folderLoadRowBase, XSIZE=40, XOFFSET=10, UVALUE='folderName')
50 | folderLoadBtn = WIDGET_BUTTON(folderLoadRowBase, XSIZE=80, FONT='Arial*15', VALUE='Browse...', UVALUE='folderBrowse', YSIZE=30)
51 |
52 | ;save structure for events
53 | introStash = {folderLoadText:folderLoadText}
54 | WIDGET_CONTROL, WIDGET_INFO(introBase, /CHILD), SET_UVALUE=introStash, /NO_COPY
55 |
56 | return, introBase
57 | END
58 |
59 | function GetRootFolder, id
60 |
61 | stash = WIDGET_INFO(id, /CHILD)
62 | WIDGET_CONTROL, stash, GET_UVALUE=introStash, /NO_COPY
63 | WIDGET_CONTROL, introStash.folderLoadText, GET_VALUE=folder
64 |
65 | WIDGET_CONTROL, stash, SET_UVALUE=introStash, /NO_COPY
66 | return, folder
67 | end
--------------------------------------------------------------------------------
/src/bcal_lidar_tools_envi53/procedures/Wizard/Wizard_Utils.pro:
--------------------------------------------------------------------------------
1 | function DirectoryFromFile, fileName
2 | lastIndex = STRPOS(fileName, '/', /REVERSE_SEARCH)
3 |
4 | if (lastIndex EQ -1) THEN BEGIN
5 | ;search for windows style path
6 | lastIndex = STRPOS(filename, '\', /REVERSE_SEARCH)
7 | endif
8 |
9 | Directory = STRMID(fileName, 0, lastIndex+1)
10 | return, Directory
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/src/deprecated/LidarToolsHelp_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
; NAME:
;
; LiDARToolsHelp_BCAL
;
; PURPOSE:
;
; The purpose of this program is to display help file for the LiDAR Tools
;
; PRODUCTS:
;
;
; AUTHOR:
;
; Rupesh Shrestha
; Boise Center Aerospace Laboratory
; Idaho State University
; 322 E. Front St., Ste. 240
; Boise, ID 83702
; http://bcal.geology.isu.edu/
;
; DEPENDENCIES:
;
;
; MODIFICATION HISTORY:
;
; Written by Rupesh Shrestha, August 2010.
; Changed online help from HTML to PDF for cross-platform compatibility
; and easier maintenance.
;
;###########################################################################
;
; LICENSE
;
; This software is OSI Certified Open Source Software.
; OSI Certified is a certification mark of the Open Source Initiative.
;
; Copyright @ 2010 Rupesh Shrestha, Idaho State University.
;
; This software is provided "as-is", without any express or
; implied warranty. In no event will the authors be held liable
; for any damages arising from the use of this software.
;
; Permission is granted to anyone to use this software for any
; purpose, including commercial applications, and to alter it and
; redistribute it freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must
; not claim you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation
; would be appreciated, but is not required.
;
; 2. Altered source versions must be plainly marked as such, and must
; not be misrepresented as being the original software.
;
; 3. This notice may not be removed or altered from any source distribution.
;
; For more information on Open Source Software, visit the Open Source
; web site: http://www.opensource.org.
;
;###########################################################################
; Begin main program
pro LiDARToolsHelp_BCAL, event
compile_opt idl2
widget_control, event.id, get_uvalue=helpAbout
case helpAbout of
'LiDARToolsHelp': begin
oJavaDesktop = OBJ_NEW('IDLJavaObject$Static$JAVA_AWT_DESKTOP', $
'java.awt.Desktop')
oJavaURI = OBJ_NEW('IDLJavaObject$JAVA_NET_URI', 'java.net.URI', $
'http://code.google.com/p/bcal-lidar-tools/wiki/TableOfContents')
if (oJavaDesktop->isDesktopSupported()) then begin
oBrowser = oJavaDesktop->getDesktop()
oBrowser->browse,oJavaURI
OBJ_DESTROY, oBrowser
endif
OBJ_DESTROY, oJavaURI, oJavaDesktop
end
'LiDARToolsUpdates': begin
oJavaDesktop = OBJ_NEW('IDLJavaObject$Static$JAVA_AWT_DESKTOP', $
'java.awt.Desktop')
oJavaURI = OBJ_NEW('IDLJavaObject$JAVA_NET_URI', 'java.net.URI', $
'http://code.google.com/p/bcal-lidar-tools/downloads')
if (oJavaDesktop->isDesktopSupported()) then begin
oBrowser = oJavaDesktop->getDesktop()
oBrowser->browse,oJavaURI
OBJ_DESTROY, oBrowser
endif
OBJ_DESTROY, oJavaURI, oJavaDesktop
end
'AboutLiDARTools': begin
envi_center, xoff, yoff
widget_control, event.top, get_uvalue = info
aboutBase = widget_base(Title = 'About', /col, xoffset = xoff, $
yoffset = yoff, xsize=250)
dummy = widget_label(aboutBase, value='', /align_center)
dummy = widget_label(aboutBase, value='BCAL LiDAR Tools 1.5.3', /align_center)
dummy = widget_label(aboutBase, value='Boise Center for Aerospace Laboratory', /align_center)
dummy = widget_label(aboutBase, value='Idaho State University', /align_center)
dummy = widget_label(aboutBase, value='322 E. Front Street Suite 240, Boise, Idaho', /align_center)
dummy = widget_label(aboutBase, value='bcal@isu.edu', /align_center)
dummy = widget_label(aboutBase, value='', /align_center)
widget_control, aboutBase, /realize
end
endcase
end
--------------------------------------------------------------------------------
/src/deprecated/LidarTools_BCAL_Envi5x.pro:
--------------------------------------------------------------------------------
1 | ; Add the extension to the toolbox. Called automatically on ENVI startup.
2 | pro LidarTools_BCAL_Envi5x_extensions_init
3 |
4 | ; Set compile options
5 | compile_opt IDL2
6 |
7 | ; Get ENVI session
8 | e = ENVI(/CURRENT)
9 |
10 | ; Add the extension to a subfolder
11 | e.AddExtension, 'Get LAS Header Info', 'FileInfoLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='LASinfo'
12 | e.AddExtension, 'Single File', 'DataInfoLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Get LAS Data Info', uvalue='DataInfoSingle'
13 | e.AddExtension, 'Multiple Files', 'DataInfoBatchLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Get LAS Data Info', uvalue='DataInfoMulti'
14 | e.AddExtension, 'Add Projection to LAS File(s)', 'AddProjectionLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='addProject'
15 | e.AddExtension, 'Reproject LAS File(s)', 'ReprojectLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='reproject'
16 | e.AddExtension, 'Convert ASCII Data to LAS', 'AsciiToLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='asciiLAS'
17 | e.AddExtension, 'Convert LAS Data to ASCII, Shapefile', 'LASToAscii_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='lasascii'
18 | e.AddExtension, 'Create Boundary EVF, SHP, KML', 'BoundLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='boundLAS'
19 | e.AddExtension, 'Buffer LAS Files', 'BufferLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='bufferLAS'
20 | e.AddExtension, 'Tile LAS File(s)', 'TileLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='tileLAS'
21 | e.AddExtension, 'Reclassify LAS File(s)', 'ReclassifyLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='reclassLAS'
22 | e.AddExtension, 'Decimate by Number', 'DecimateLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Decimate LAS File(s)', uvalue='decimateNo'
23 | e.AddExtension, 'Decimate by Percent', 'DecimateLASper_BCAL', PATH='BCAL LiDAR Tools/LAS File/Decimate LAS File(s)', uvalue='decimatePer'
24 | e.AddExtension, 'Subset via Coordinates', 'SubsetLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Subset LAS File(s)', uvalue='subsetCoords'
25 | e.AddExtension, 'Subset via Image or ROI', 'SubsetLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Subset LAS File(s)', uvalue='subsetROI'
26 | e.AddExtension, 'Export by returns', 'ExportLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Export LAS File(s)', uvalue='exportReturn'
27 | e.AddExtension, 'Export by number of returns', 'ExportLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Export LAS File(s)', uvalue='exportReturnNo'
28 | e.AddExtension, 'Export by classification', 'ExportLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Export LAS File(s)', uvalue='exportClass'
29 | e.AddExtension, 'Export by elevation', 'ExportLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Export LAS File(s)', uvalue='exportElev'
30 | e.AddExtension, 'Export by scan angle', 'ExportLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Export LAS File(s)', uvalue='exportScan'
31 | e.AddExtension, 'Export by intensity', 'ExportLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Export LAS File(s)', uvalue='exportInten'
32 | e.AddExtension, 'Assign from orthoimagery', 'AssignColorLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Assign RGB Data (LAS 1.2)', uvalue='RGBLasOrtho'
33 | e.AddExtension, 'Assign from elevation', 'AssignColorLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Assign RGB Data (LAS 1.2)', uvalue='RGBLasElev'
34 | e.AddExtension, 'Assign from vegetation height', 'AssignColorLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File/Assign RGB Data (LAS 1.2)', uvalue='RGBLasVegHt'
35 | e.AddExtension, 'Extract flight lines from LAS file(s)', 'FlightlineLAS_BCAL', PATH='BCAL LiDAR Tools/LAS File', uvalue='FlightlineLAS'
36 |
37 | e.AddExtension, 'Perform Height Filtering', 'HeightLAS_BCAL', PATH='BCAL LiDAR Tools', uvalue='height'
38 | e.AddExtension, 'Create Bare-earth DEM', 'DEMLAS_BCAL', PATH='BCAL LiDAR Tools', uvalue='raster'
39 |
40 | e.AddExtension, 'Topographic Products (Bare-earth)', 'TopoRasterBare_BCAL', PATH='BCAL LiDAR Tools/Create Raster Products', uvalue='tbmetric'
41 | e.AddExtension, 'Topographic Products (All returns)', 'TopoRasterAll_BCAL', PATH='BCAL LiDAR Tools/Create Raster Products', uvalue='tametric'
42 | e.AddExtension, 'Vegetation Products', 'VegMetrics_BCAL', PATH='BCAL LiDAR Tools/Create Raster Products', uvalue='vmetric'
43 | e.AddExtension, 'Intensity Products', 'IntensityMetrics_BCAL', PATH='BCAL LiDAR Tools/Create Raster Products', uvalue='imetric'
44 | e.AddExtension, 'Prepare LAS file(s)', 'PrepareLAS_BCAL', PATH='BCAL LiDAR Tools/Create Raster Products', uvalue='prepareLAS'
45 | e.AddExtension, 'Create Raster Layer (legacy)', 'LidarRasterLAS_BCAL', PATH='BCAL LiDAR Tools/Create Raster Products', uvalue='raster_legacy'
46 |
47 | e.AddExtension, 'Create Vegetation Height Groups', 'HeightGroupsLAS_BCAL', PATH='BCAL LiDAR Tools', uvalue='heightgroups'
48 | e.AddExtension, 'Create Elevation Profile(s)', 'TransectLAS_BCAL', PATH='BCAL LiDAR Tools', uvalue='transect'
49 | e.AddExtension, '3D Lidar Viewer', 'Visualize3D_BCAL', PATH='BCAL LiDAR Tools', uvalue='visualize'
50 | e.AddExtension, 'LiDAR Processing Wizard', 'Wizard_BCAL', PATH='BCAL LiDAR Tools', uvalue='wizard'
51 |
52 | e.AddExtension, 'Start Help', 'LiDARToolsHelp_BCAL', PATH='BCAL LiDAR Tools/Help', uvalue='LiDARToolsHelp'
53 | e.AddExtension, 'Check for Updates...', 'LiDARToolsHelp_BCAL', PATH='BCAL LiDAR Tools/Help', uvalue='LiDARToolsUpdates'
54 | e.AddExtension, 'About BCAL LiDAR Tools', 'LiDARToolsHelp_BCAL', PATH='BCAL LiDAR Tools/Help', uvalue='AboutLiDARTools'
55 |
56 | end
57 |
58 | ; ENVI Extension code. Called when the toolbox item is chosen.
59 | pro LidarTools_BCAL_Envi5x
60 |
61 |
62 | end
63 |
--------------------------------------------------------------------------------
/src/deprecated/lib/GetIndex_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; GetIndex_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function is used for "index chunking", in combination with the output of
9 | ; the REVERSE_INDICES keyword of the HISTOGRAM function. For a given array element
10 | ; and search radius, the function returns all indices within those elements.
11 | ;
12 | ; AUTHOR:
13 | ;
14 | ; David Streutker
15 | ; Boise Center Aerospace Laboratory
16 | ; Idaho State University
17 | ; 322 E. Front St., Ste. 240
18 | ; Boise, ID 83702
19 | ; http://geology.isu.edu/BCAL
20 | ;
21 | ; CALLING SEQUENCE:
22 | ;
23 | ; index = GetIndex_BCAL(I,J,xDim,yDim,ArrayIndex,Factor)
24 | ;
25 | ; I and J are the coordinates within the array, xDim and yDim are the dimensions of
26 | ; the array, ArrayIndex is the output of the REVERSE_INDICES keyword of the HISTOGRAM
27 | ; function, and Factor is the search radius. (Factor = 0 searches the single element,
28 | ; Factor = 1 searches the nine-element neighborhood, and so on.)
29 | ;
30 | ; RETURN VALUE:
31 | ;
32 | ; The function returns the indices corresponding to the specified element and the
33 | ; elements within the radius specified by the value of Factor.
34 | ;
35 | ; If no indices are found, the function returns a value of -1.
36 | ;
37 | ; KNOWN ISSUES:
38 | ;
39 | ; None.
40 | ;
41 | ; MODIFICATION HISTORY:
42 | ;
43 | ; Written by David Streutker, March 2006.
44 | ;
45 | ;###########################################################################
46 | ;
47 | ; LICENSE
48 | ;
49 | ; This software is OSI Certified Open Source Software.
50 | ; OSI Certified is a certification mark of the Open Source Initiative.
51 | ;
52 | ; Copyright � 2006 David Streutker, Idaho State University.
53 | ;
54 | ; This software is provided "as-is", without any express or
55 | ; implied warranty. In no event will the authors be held liable
56 | ; for any damages arising from the use of this software.
57 | ;
58 | ; Permission is granted to anyone to use this software for any
59 | ; purpose, including commercial applications, and to alter it and
60 | ; redistribute it freely, subject to the following restrictions:
61 | ;
62 | ; 1. The origin of this software must not be misrepresented; you must
63 | ; not claim you wrote the original software. If you use this software
64 | ; in a product, an acknowledgment in the product documentation
65 | ; would be appreciated, but is not required.
66 | ;
67 | ; 2. Altered source versions must be plainly marked as such, and must
68 | ; not be misrepresented as being the original software.
69 | ;
70 | ; 3. This notice may not be removed or altered from any source distribution.
71 | ;
72 | ; For more information on Open Source Software, visit the Open Source
73 | ; web site: http://www.opensource.org.
74 | ;
75 | ;###########################################################################
76 |
77 | function GetIndex_BCAL, i, j, xDim, yDim, arrayIndex, factor
78 |
79 | compile_opt idl2, logical_predicate
80 |
81 | ; Convert the two-dimensional array coordinates to a one-dimensional coordinate.
82 |
83 | k = j * xDim + i
84 |
85 | ; Set initial return value
86 |
87 | index = -1
88 |
89 | if ((factor eq 0) and (arrayIndex[k] ne arrayIndex[k+1])) then $
90 |
91 | ; If no expansion is needed, simply get the indices
92 |
93 | index = arrayIndex[arrayIndex[k]:arrayIndex[k+1]-1] $
94 |
95 | else begin
96 |
97 | doInd = 0
98 |
99 | ; If an expansion is needed, get the expanded coordinates.
100 |
101 | iStart = (i - factor) > 0
102 | iEnd = (i + factor) < (xDim - 1)
103 | iEnd += 1
104 |
105 | jStart = (j - factor) > 0
106 | jEnd = (j + factor) < (yDim - 1)
107 |
108 | ; Convert the 2D coordiates to 1D coordinates.
109 |
110 | jRange = jEnd - jStart
111 | kStart = (jStart + lindgen(jRange + 1)) * xDim
112 |
113 | kEnd = kStart + iEnd
114 | kStart = kStart + iStart
115 |
116 | for a=0,jRange do begin
117 |
118 | ; If they exist, get all the corresponding indices.
119 |
120 | if arrayIndex[kStart[a]] ne arrayIndex[kEnd[a]] then begin
121 |
122 | index = [index,arrayIndex[arrayIndex[kStart[a]]:arrayIndex[kEnd[a]]-1]]
123 | doInd = 1
124 |
125 | endif
126 |
127 | endfor
128 |
129 | ; If indices were found, remove the first, '-1' element.
130 |
131 | if doInd then index = index[1:*]
132 |
133 | endelse
134 |
135 | return, index
136 |
137 | end
--------------------------------------------------------------------------------
/src/deprecated/lib/GetUniqLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; GetUniqLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function is used to remove points in the LAS file that have same
9 | ; coordinates.
10 | ;
11 | ; AUTHOR:
12 | ;
13 | ; David Streutker
14 | ; Boise Center Aerospace Laboratory
15 | ; Idaho State University
16 | ; 322 E. Front St., Ste. 240
17 | ; Boise, ID 83702
18 | ; http://bcal.geology.isu.edu
19 | ;
20 | ; CALLING SEQUENCE:
21 | ;
22 | ; index = GetUniqLAS_BCAL(header, data)
23 | ;
24 | ; 'header' are the LAS file header obtained using ReadHeaderLAS_BCAL, and 'data'
25 | ; are LAS file data obtained by ReadLAS_BCAL procedures.
26 | ;
27 | ; RETURN VALUE:
28 | ;
29 | ; The function returns the LAS header and data for points with only unique
30 | ; coordinates
31 | ;
32 | ; KNOWN ISSUES:
33 | ;
34 | ; None.
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, March 2006.
39 | ;
40 | ;###########################################################################
41 | ;
42 | ; LICENSE
43 | ;
44 | ; This software is OSI Certified Open Source Software.
45 | ; OSI Certified is a certification mark of the Open Source Initiative.
46 | ;
47 | ; Copyright @ 2006 David Streutker, Idaho State University.
48 | ;
49 | ; This software is provided "as-is", without any express or
50 | ; implied warranty. In no event will the authors be held liable
51 | ; for any damages arising from the use of this software.
52 | ;
53 | ; Permission is granted to anyone to use this software for any
54 | ; purpose, including commercial applications, and to alter it and
55 | ; redistribute it freely, subject to the following restrictions:
56 | ;
57 | ; 1. The origin of this software must not be misrepresented; you must
58 | ; not claim you wrote the original software. If you use this software
59 | ; in a product, an acknowledgment in the product documentation
60 | ; would be appreciated, but is not required.
61 | ;
62 | ; 2. Altered source versions must be plainly marked as such, and must
63 | ; not be misrepresented as being the original software.
64 | ;
65 | ; 3. This notice may not be removed or altered from any source distribution.
66 | ;
67 | ; For more information on Open Source Software, visit the Open Source
68 | ; web site: http://www.opensource.org.
69 | ;
70 | ;###########################################################################
71 |
72 | pro GetUniqLAS_BCAL, header, data
73 |
74 | compile_opt idl2, logical_predicate
75 |
76 | xMax = max(data.east, min=xMin)
77 | yMax = max(data.north, min=yMin)
78 | zMin = min(data.elev)
79 |
80 | eastRange = ulong64(xMax - xMin)
81 | northRange = ulong64(yMax - yMin)
82 |
83 | uniqCoords = eastRange * northRange * (data.elev - zMin) $
84 | + eastRange * (data.north - yMin) $
85 | + (data.east - xMin)
86 |
87 | uniqCoords = uniq(uniqCoords, sort(uniqCoords))
88 |
89 | nUniq = n_elements(uniqCoords)
90 |
91 | if nUniq ne header.nPoints then begin
92 |
93 | data = data[uniqCoords]
94 |
95 | header.nPoints = nUniq
96 |
97 | endif
98 |
99 |
100 | end
--------------------------------------------------------------------------------
/src/deprecated/lib/InitDataLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; InitDataLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read each point data record from a .las
9 | ; lidar file.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; David Streutker
16 | ; Boise Center Aerospace Laboratory
17 | ; Idaho State University
18 | ; 322 E. Front St., Ste. 240
19 | ; Boise, ID 83702
20 | ; http://bcal.geology.isu.edu/
21 | ;
22 | ; CALLING SEQUENCE:
23 | ;
24 | ; data = InitDataLAS_BCAL(PointFormat=PointFormat)
25 | ;
26 | ; The PointFormat specifies the requested format of the data record.
27 | ;
28 | ; RETURN VALUE:
29 | ;
30 | ; The program returns a single structure corresponding to a single data
31 | ; record of a .las file.
32 | ;
33 | ; KNOWN ISSUES:
34 | ;
35 | ; None.
36 | ;
37 | ; MODIFICATION HISTORY:
38 | ;
39 | ; Written by David Streutker, March 2006.
40 | ; Change from a procedure to a function, July 2007
41 | ; Added support for LAS 1.2 RGB ancillary image data, June 2010 (Rupesh Shrestha).
42 | ;
43 | ;###########################################################################
44 | ;
45 | ; LICENSE
46 | ;
47 | ; This software is OSI Certified Open Source Software.
48 | ; OSI Certified is a certification mark of the Open Source Initiative.
49 | ;
50 | ; Copyright � 2006 David Streutker, Idaho State University.
51 | ;
52 | ; This software is provided "as-is", without any express or
53 | ; implied warranty. In no event will the authors be held liable
54 | ; for any damages arising from the use of this software.
55 | ;
56 | ; Permission is granted to anyone to use this software for any
57 | ; purpose, including commercial applications, and to alter it and
58 | ; redistribute it freely, subject to the following restrictions:
59 | ;
60 | ; 1. The origin of this software must not be misrepresented; you must
61 | ; not claim you wrote the original software. If you use this software
62 | ; in a product, an acknowledgment in the product documentation
63 | ; would be appreciated, but is not required.
64 | ;
65 | ; 2. Altered source versions must be plainly marked as such, and must
66 | ; not be misrepresented as being the original software.
67 | ;
68 | ; 3. This notice may not be removed or altered from any source distribution.
69 | ;
70 | ; For more information on Open Source Software, visit the Open Source
71 | ; web site: http://www.opensource.org.
72 | ;
73 | ;###########################################################################
74 |
75 | function InitDataLAS_BCAL, pointFormat=pointFormat
76 |
77 | compile_opt idl2, logical_predicate
78 |
79 | ; Define the data structure
80 |
81 | data = {formatD0, $
82 | east : 0L, $ ; X data
83 | north : 0L, $ ; Y data
84 | elev : 0L, $ ; Z data
85 | inten : 0US, $ ; Intensity
86 | nReturn : 0B, $ ; Return number, number of returns, scan direction, edge
87 | class : 0B, $ ; Classification
88 | angle : 0B, $ ; Scan angle
89 | user : 0B, $ ; User data
90 | source : 0US $ ; Point source ID
91 | }
92 |
93 | ; If format 1 is requested, add the time field
94 |
95 | if pointFormat eq 1 then data = {formatD1, inherits formatD0, time:0D} ; GPS time field
96 |
97 | ; If format 2 is requested, add the RGB channel value fields
98 |
99 | if pointFormat eq 2 then data = {formatD2, inherits formatD0, $
100 | red : 0US, $ ; Red image channel value
101 | green : 0US, $ ; Blue image channel value
102 | blue : 0US $ ; Green image channel value
103 | }
104 |
105 | ; If format 3 is requested, add the time field and RGB channel value fields
106 |
107 | if pointFormat eq 3 then data = {formatD3, inherits formatD0, $
108 | time : 0D, $ ; GPS time field
109 | red : 0US, $ ; Red image channel value
110 | green: 0US, $ ; Blue image channel value
111 | blue : 0US $ ; Green image channel value
112 | }
113 |
114 | return, data
115 |
116 | end
--------------------------------------------------------------------------------
/src/deprecated/lib/InitHeaderLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; InitHeaderLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read the header of a .las
9 | ; lidar file.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; David Streutker
16 | ; Boise Center Aerospace Laboratory
17 | ; Idaho State University
18 | ; 322 E. Front St., Ste. 240
19 | ; Boise, ID 83702
20 | ; http://bcal.geology.isu.edu
21 | ;
22 | ; CALLING SEQUENCE:
23 | ;
24 | ; header = InitHeaderLAS_BCAL()
25 | ;
26 | ; RETURN VALUE:
27 | ;
28 | ; The function returns a structure corresponding to the header of a .las file.
29 | ;
30 | ; KNOWN ISSUES:
31 | ;
32 | ; None.
33 | ;
34 | ; MODIFICATION HISTORY:
35 | ;
36 | ; Written by David Streutker, March 2006.
37 | ; Converted from a procedure to a function, July 2007
38 | ;
39 | ;###########################################################################
40 | ;
41 | ; LICENSE
42 | ;
43 | ; This software is OSI Certified Open Source Software.
44 | ; OSI Certified is a certification mark of the Open Source Initiative.
45 | ;
46 | ; Copyright � 2006 David Streutker, Idaho State University.
47 | ;
48 | ; This software is provided "as-is", without any express or
49 | ; implied warranty. In no event will the authors be held liable
50 | ; for any damages arising from the use of this software.
51 | ;
52 | ; Permission is granted to anyone to use this software for any
53 | ; purpose, including commercial applications, and to alter it and
54 | ; redistribute it freely, subject to the following restrictions:
55 | ;
56 | ; 1. The origin of this software must not be misrepresented; you must
57 | ; not claim you wrote the original software. If you use this software
58 | ; in a product, an acknowledgment in the product documentation
59 | ; would be appreciated, but is not required.
60 | ;
61 | ; 2. Altered source versions must be plainly marked as such, and must
62 | ; not be misrepresented as being the original software.
63 | ;
64 | ; 3. This notice may not be removed or altered from any source distribution.
65 | ;
66 | ; For more information on Open Source Software, visit the Open Source
67 | ; web site: http://www.opensource.org.
68 | ;
69 | ;###########################################################################
70 |
71 | function InitHeaderLAS_BCAL
72 |
73 | compile_opt idl2, logical_predicate
74 |
75 | ; Define the public header structure
76 |
77 | header = { $
78 | signature : byte('LASF'), $ ; File signature
79 | fileSource : 0US, $ ; File source ID
80 | reserved : 0US, $ ; Reserved
81 | guid1 : 0UL, $ ; Project ID - GUID data 1
82 | guid2 : 0US, $ ; Project ID - GUID data 2
83 | guid3 : 0US, $ ; Project ID - GUID data 3
84 | guid4 : bytarr(8), $ ; Project ID - GUID data 4
85 | versionMajor : 1B, $ ; Version major
86 | versionMinor : 1B, $ ; Version minor
87 | systemID : bytarr(32), $ ; System identifier
88 | softwareID : bytarr(32), $ ; Generating software
89 | day : 0US, $ ; File creation day of year
90 | year : 0US, $ ; File creation year
91 | headerSize : 227US, $ ; Header size
92 | dataOffset : 227UL, $ ; Offset to point data
93 | nRecords : 0UL, $ ; Number of variable length records
94 | pointFormat : 0B, $ ; Point data format ID
95 | pointLength : 20US, $ ; Point data record length
96 | nPoints : 0UL, $ ; Number of point records
97 | nReturns : ulonarr(5), $ ; Number of points by return
98 | xScale : 0D, $ ; X scale factor
99 | yScale : 0D, $ ; Y scale factor
100 | zScale : 0D, $ ; Z scale factor
101 | xOffset : 0D, $ ; X offset
102 | yOffset : 0D, $ ; Y offset
103 | zOffset : 0D, $ ; Z offset
104 | xMax : 0D, $ ; Max X
105 | xMin : 0D, $ ; Min X
106 | yMax : 0D, $ ; Max Y
107 | yMin : 0D, $ ; Min Y
108 | zMax : 0D, $ ; Max Z
109 | zMin : 0D $ ; Min Z
110 | }
111 |
112 | ; Set the software ID
113 |
114 | header.softwareID = byte('LidarTools, IDL ' + !version.release)
115 |
116 | ; Set the creation date
117 |
118 | date = bin_date(systime(/utc))
119 | day = julday(date[1],date[2],date[0]) - julday(1,1,date[0]) + 1
120 | header.day = uint(day)
121 | header.year = uint(date[0])
122 |
123 | return, header
124 |
125 | end
--------------------------------------------------------------------------------
/src/deprecated/lib/InitRecordLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; InitRecordLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function initializes a structure to read a variable length record from an .las
9 | ; lidar file.
10 | ;
11 | ; For more information on the .las lidar data format, see http://www.lasformat.org
12 | ;
13 | ; AUTHOR:
14 | ;
15 | ; David Streutker
16 | ; Boise Center Aerospace Laboratory
17 | ; Idaho State University
18 | ; 322 E. Front St., Ste. 240
19 | ; Boise, ID 83702
20 | ; http://bcal.geology.isu.edu
21 | ;
22 | ; CALLING SEQUENCE:
23 | ;
24 | ; record = InitRecordLAS(NODATA=NODATA)
25 | ;
26 | ; RETURN VALUE:
27 | ;
28 | ; The function returns a structure corresponding to the variable length record of the .las
29 | ; file specification. Set the NODATA keyword to return a structure that does not contain
30 | ; the data pointer.
31 | ;
32 | ; MODIFICATION HISTORY:
33 | ;
34 | ; Written by David Streutker, July 2007.
35 | ;
36 | ;###########################################################################
37 | ;
38 | ; LICENSE
39 | ;
40 | ; This software is OSI Certified Open Source Software.
41 | ; OSI Certified is a certification mark of the Open Source Initiative.
42 | ;
43 | ; Copyright � 2007 David Streutker, Idaho State University.
44 | ;
45 | ; This software is provided "as-is", without any express or
46 | ; implied warranty. In no event will the authors be held liable
47 | ; for any damages arising from the use of this software.
48 | ;
49 | ; Permission is granted to anyone to use this software for any
50 | ; purpose, including commercial applications, and to alter it and
51 | ; redistribute it freely, subject to the following restrictions:
52 | ;
53 | ; 1. The origin of this software must not be misrepresented; you must
54 | ; not claim you wrote the original software. If you use this software
55 | ; in a product, an acknowledgment in the product documentation
56 | ; would be appreciated, but is not required.
57 | ;
58 | ; 2. Altered source versions must be plainly marked as such, and must
59 | ; not be misrepresented as being the original software.
60 | ;
61 | ; 3. This notice may not be removed or altered from any source distribution.
62 | ;
63 | ; For more information on Open Source Software, visit the Open Source
64 | ; web site: http://www.opensource.org.
65 | ;
66 | ;###########################################################################
67 |
68 | function InitRecordLAS_BCAL, noData = noData
69 |
70 | compile_opt idl2, logical_predicate
71 |
72 | ; Define the variable length header structure
73 |
74 | record = {formatR0, $
75 | signature : 0US, $ ; Record signature
76 | userID : bytarr(16), $ ; User ID
77 | recordID : 0US, $ ; Record ID
78 | recordLength : 0US, $ ; Record length after header
79 | description : bytarr(32) $ ; Description
80 | }
81 |
82 | if ~ keyword_set(noData) then record = {formatR1, inherits formatR0, data : ptr_new(/allocate)} ; Data pointer
83 |
84 | return, record
85 |
86 | end
--------------------------------------------------------------------------------
/src/deprecated/lib/ReadHeaderLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReadHeaderLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This program reads the header from the specified .las file.
9 | ;
10 | ; For more information on the .las lidar data format, see http://www.lasformat.org
11 | ;
12 | ; AUTHOR:
13 | ;
14 | ; David Streutker
15 | ; Boise Center Aerospace Laboratory
16 | ; Idaho State University
17 | ; 322 E. Front St., Ste. 240
18 | ; Boise, ID 83702
19 | ; http://bcal.geology.isu.edu
20 | ;
21 | ; CALLING SEQUENCE:
22 | ;
23 | ; ReadHeaderLAS, inputFile, header
24 | ;
25 | ; InputFile is the name of the requested .las file.
26 | ;
27 | ; RETURN VALUE:
28 | ;
29 | ; The program returns a structure containing the header information from the
30 | ; specified .las file.
31 | ;
32 | ; KNOWN ISSUES:
33 | ;
34 | ; None.
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, March 2006.
39 | ; Changed CLOSE command to FREE_LUN, April 2006 (DRS)
40 | ; Replaced by NODATA keyword in ReadLAS_BCAL.pro, June 2007
41 | ;
42 | ;###########################################################################
43 | ;
44 | ; LICENSE
45 | ;
46 | ; This software is OSI Certified Open Source Software.
47 | ; OSI Certified is a certification mark of the Open Source Initiative.
48 | ;
49 | ; Copyright � 2006 David Streutker, Idaho State University.
50 | ;
51 | ; This software is provided "as-is", without any express or
52 | ; implied warranty. In no event will the authors be held liable
53 | ; for any damages arising from the use of this software.
54 | ;
55 | ; Permission is granted to anyone to use this software for any
56 | ; purpose, including commercial applications, and to alter it and
57 | ; redistribute it freely, subject to the following restrictions:
58 | ;
59 | ; 1. The origin of this software must not be misrepresented; you must
60 | ; not claim you wrote the original software. If you use this software
61 | ; in a product, an acknowledgment in the product documentation
62 | ; would be appreciated, but is not required.
63 | ;
64 | ; 2. Altered source versions must be plainly marked as such, and must
65 | ; not be misrepresented as being the original software.
66 | ;
67 | ; 3. This notice may not be removed or altered from any source distribution.
68 | ;
69 | ; For more information on Open Source Software, visit the Open Source
70 | ; web site: http://www.opensource.org.
71 | ;
72 | ;###########################################################################
73 |
74 | pro ReadHeaderLAS_BCAL, inputFile, header
75 |
76 | compile_opt idl2, logical_predicate
77 |
78 | ; Create the header structure
79 |
80 | header = InitHeaderLAS_BCAL()
81 |
82 | ; Open the file and read the header from it
83 |
84 | openr, inputLun, inputFile, /get_lun, /swap_if_big_endian
85 | readu, inputLun, header
86 | free_lun, inputLun
87 |
88 |
89 |
90 | end
--------------------------------------------------------------------------------
/src/deprecated/lib/ScalePoly_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ScalePoly_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; This function scales a polygon by the requested amount.
9 | ;
10 | ; AUTHOR:
11 | ;
12 | ; David Streutker
13 | ; Boise Center Aerospace Laboratory
14 | ; Idaho State University
15 | ; 322 E. Front St., Ste. 240
16 | ; Boise, ID 83702
17 | ; http://bcal.geology.isu.edu
18 | ;
19 | ; CALLING SEQUENCE:
20 | ;
21 | ; result = ScalePoly(Coordinates,Factor)
22 | ;
23 | ; RETURN VALUE:
24 | ;
25 | ; The function returns the coordinates scaled by the factor amount.
26 | ;
27 | ; Coordinates is a [2,n] array of polygon coordinates. Factor is the value by which
28 | ; the coordinates are scaled. Factor can be vector to scale the polygon differently in
29 | ; each direction. Positive values of Factor increase the size of the polygon, while
30 | ; negative values decrease it.
31 | ;
32 | ; DEPENDENCIES:
33 | ;
34 | ; GetBounds_BCAL.pro
35 | ;
36 | ; MODIFICATION HISTORY:
37 | ;
38 | ; Written by David Streutker, June 2006.
39 | ;
40 | ;###########################################################################
41 | ;
42 | ; LICENSE
43 | ;
44 | ; This software is OSI Certified Open Source Software.
45 | ; OSI Certified is a certification mark of the Open Source Initiative.
46 | ;
47 | ; Copyright @ 2006 David Streutker, Idaho State University.
48 | ;
49 | ; This software is provided "as-is", without any express or
50 | ; implied warranty. In no event will the authors be held liable
51 | ; for any damages arising from the use of this software.
52 | ;
53 | ; Permission is granted to anyone to use this software for any
54 | ; purpose, including commercial applications, and to alter it and
55 | ; redistribute it freely, subject to the following restrictions:
56 | ;
57 | ; 1. The origin of this software must not be misrepresented; you must
58 | ; not claim you wrote the original software. If you use this software
59 | ; in a product, an acknowledgment in the product documentation
60 | ; would be appreciated, but is not required.
61 | ;
62 | ; 2. Altered source versions must be plainly marked as such, and must
63 | ; not be misrepresented as being the original software.
64 | ;
65 | ; 3. This notice may not be removed or altered from any source distribution.
66 | ;
67 | ; For more information on Open Source Software, visit the Open Source
68 | ; web site: http://www.opensource.org.
69 | ;
70 | ;###########################################################################
71 |
72 |
73 | function ScalePoly_BCAL, coords, d
74 |
75 | compile_opt idl2, logical_predicate
76 |
77 | ; Check whether the scale factor is one or two elements.
78 |
79 | if n_elements(d) eq 1 then d = [d,d]
80 |
81 | ; Get the x and y values of the coordinates and determine the mid-points and the ranges.
82 |
83 | x = coords[0,*]
84 | y = coords[1,*]
85 |
86 | xRange = max(x) - min(x)
87 | yRange = max(y) - min(y)
88 |
89 | xMid = (max(x) + min(x)) / 2
90 | yMid = (max(y) + min(y)) / 2
91 |
92 | ; Determine if the points are on the positive or negative side of the mid-points.
93 |
94 | xPos = where(x gt xMid, complement=xNeg)
95 | yPos = where(y gt yMid, complement=yNeg)
96 |
97 | ; Make sure the polygon is larger than the amount by which it is to be scaled. (This
98 | ; only applies for a negative scaling.)
99 |
100 | if xRange gt (-2)*d[0] then begin
101 |
102 | ; Scale the x coordinates
103 |
104 | x[xPos] = x[xPos] + d[0]
105 | x[xNeg] = x[xNeg] - d[0]
106 |
107 | endif
108 |
109 | if yRange gt (-2)*d[1] then begin
110 |
111 | ; Scale the y coordinates
112 |
113 | y[yPos] = y[yPos] + d[1]
114 | y[yNeg] = y[yNeg] - d[1]
115 |
116 | endif
117 |
118 | ; Call GetBounds_BCAL to eliminate any redundant points.
119 |
120 | bounds = GetBounds_BCAL(x,y)
121 | bounds = transpose(bounds)
122 |
123 | ; Return the new coordinates.
124 |
125 | return, [x[bounds],y[bounds]]
126 |
127 | end
128 |
--------------------------------------------------------------------------------
/src/deprecated/lib/fsc/normalize_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ; NORMALIZE
4 | ;
5 | ; PURPOSE:
6 | ;
7 | ; This is a utility routine to calculate the scaling vector
8 | ; required to position a graphics primitive of specified range
9 | ; at a specific position in an arbitray coordinate system. The
10 | ; scaling vector is given as a two-element array like this:
11 | ;
12 | ; scalingVector = [translationFactor, scalingFactor]
13 | ;
14 | ; The scaling vector should be used with the [XYZ]COORD_CONV
15 | ; keywords of a graphics object or model. For example, if you
16 | ; wanted to scale an X axis into the coordinate range of -0.5 to 0.5,
17 | ; you might type something like this:
18 | ;
19 | ; xAxis->GetProperty, Range=xRange
20 | ; xScale = Normalize(xRange, Position=[-0.5, 0.5])
21 | ; xAxis, XCoord_Conv=xScale
22 | ;
23 | ; AUTHOR:
24 | ;
25 | ; FANNING SOFTWARE CONSULTING
26 | ; David Fanning, Ph.D.
27 | ; 1645 Sheely Drive
28 | ; Fort Collins, CO 80526 USA
29 | ; Phone: 970-221-0438
30 | ; E-mail: davidf@dfanning.com
31 | ; Coyote's Guide to IDL Programming: http://www.dfanning.com
32 | ;
33 | ; CATEGORY:
34 |
35 | ; Object Graphics
36 | ;
37 | ; CALLING SEQUENCE:
38 | ; xscaling = NORMALIZE(xrange, POSITION=position)
39 | ;
40 | ; INPUTS:
41 | ; XRANGE: A two-element vector specifying the data range.
42 | ;
43 | ; KEYWORD PARAMETERS:
44 | ; POSITION: A two-element vector specifying the location
45 | ; in the coordinate system you are scaling into. The vector [0,1]
46 | ; is used by default if POSITION is not specified.
47 | ;
48 | ; COMMON BLOCKS:
49 | ; None.
50 | ;
51 | ; EXAMPLE:
52 | ; See above.
53 | ;
54 | ; MODIFICATION HISTORY:
55 | ; Written by: David W. Fanning, OCT 1997.
56 | ; Fixed a problem with illegal divide by zero. 21 April 2005. DWF.
57 | ;-
58 |
59 | FUNCTION Normalize_BCAL, range, Position=position
60 | compile_opt idl2
61 |
62 | On_Error, 1
63 | IF N_Params() EQ 0 THEN Message, 'Please pass range vector as argument.'
64 |
65 | IF (N_Elements(position) EQ 0) THEN position = [0.0D, 1.0D] ELSE $
66 | position=Double(position)
67 | range = Double(range)
68 |
69 | scale = [((position[0]*range[1])-(position[1]*range[0])) / $
70 | ((range[1]-range[0]) > 1e-12), (position[1]-position[0])/((range[1]-range[0]) > 1e-12)]
71 |
72 | RETURN, scale
73 | END
74 | ;-------------------------------------------------------------------------
75 |
--------------------------------------------------------------------------------
/src/deprecated/procedures/AddProjectionLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; AddProjectionLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; The purpose of this program is add projection information to LAS files
9 | ;
10 | ; PRODUCTS:
11 | ;
12 | ; The output is a new LAS file for each input LAS file. The output files have the same
13 | ; name as the input files.
14 | ;
15 | ; AUTHOR:
16 | ;
17 | ; David Streutker
18 | ; Boise Center Aerospace Laboratory
19 | ; Idaho State University
20 | ; 322 E. Front St., Ste. 240
21 | ; Boise, ID 83702
22 | ; http://bcal.geology.isu.edu/
23 | ;
24 | ; DEPENDENCIES:
25 | ;
26 | ; ReadLAS_BCAL.pro
27 | ; WriteLAS_BCAL.pro
28 | ; RecordsToProj_BCAL.pro
29 | ;
30 | ; MODIFICATION HISTORY:
31 | ;
32 | ; Written by David Streutker, June 2007.
33 | ;
34 | ;###########################################################################
35 | ;
36 | ; LICENSE
37 | ;
38 | ; This software is OSI Certified Open Source Software.
39 | ; OSI Certified is a certification mark of the Open Source Initiative.
40 | ;
41 | ; Copyright @ 2007 David Streutker, Idaho State University.
42 | ;
43 | ; This software is provided "as-is", without any express or
44 | ; implied warranty. In no event will the authors be held liable
45 | ; for any damages arising from the use of this software.
46 | ;
47 | ; Permission is granted to anyone to use this software for any
48 | ; purpose, including commercial applications, and to alter it and
49 | ; redistribute it freely, subject to the following restrictions:
50 | ;
51 | ; 1. The origin of this software must not be misrepresented; you must
52 | ; not claim you wrote the original software. If you use this software
53 | ; in a product, an acknowledgment in the product documentation
54 | ; would be appreciated, but is not required.
55 | ;
56 | ; 2. Altered source versions must be plainly marked as such, and must
57 | ; not be misrepresented as being the original software.
58 | ;
59 | ; 3. This notice may not be removed or altered from any source distribution.
60 | ;
61 | ; For more information on Open Source Software, visit the Open Source
62 | ; web site: http://www.opensource.org.
63 | ;
64 | ;###########################################################################
65 | ; Begin main program
66 |
67 | pro AddProjectionLAS_BCAL, event
68 |
69 | compile_opt idl2, logical_predicate
70 |
71 | ; Establish error handler. The most likely problem is that the user will open a data
72 | ; file that is too large to process.
73 |
74 | catch, theError
75 | if theError ne 0 then begin
76 | catch, /cancel
77 | help, /last_message, output=errText
78 | errMsg = dialog_message(errText, /error, title='Error processing request')
79 | return
80 | endif
81 |
82 | ; Get the input file(s)
83 |
84 | inputFiles = dialog_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files, /path)
85 | if (inputFiles[0] eq '') then return
86 |
87 | nFiles = n_elements(inputFiles)
88 |
89 | ; Get the output projection and the output directory
90 |
91 | readBase = widget_auto_base(title='Select Projection')
92 |
93 | dummy = widget_label(readBase, value='Set output projection:')
94 | dummy = widget_map(readBase, default_map=[0,0], default_proj=envi_proj_create(), uvalue='proj', /auto)
95 | dummy = widget_outf(readBase, /directory, prompt='Select output directory', uvalue='outDir', /auto)
96 |
97 | result = auto_wid_mng(readBase)
98 | if result.accept eq 0 then return
99 |
100 | proj = result.proj.proj
101 |
102 | outputDir = result.outDir
103 |
104 | ; Set up status message window
105 |
106 | statText = 'Initializing'
107 | statBase = widget_auto_base(title='Adding Projections')
108 | statField = widget_text(statBase, /scroll, value=statText, xsize=80, ysize=4)
109 | widget_control, statBase, /realize
110 |
111 | ; Process each data file individually
112 |
113 | for a=0,nFiles-1 do begin
114 |
115 | ; Update the status window
116 |
117 | statText = ['Adding projection to ' + inputFiles[a], statText]
118 | widget_control, statField, set_value=statText
119 |
120 | ; Read the input file
121 |
122 | ReadLAS_BCAL, inputFiles[a], header, data, records=records
123 |
124 | ; Update the array of records
125 |
126 | newRecord = RecordsToProj_BCAL(proj, /reverse)
127 |
128 | if n_tags(records) then begin
129 |
130 | rIndex = where(records.recordID eq 34735, rCount)
131 |
132 | if rCount then begin
133 |
134 | mText = 'The file ' + file_basename(inputFiles[a]) + ' appears to already contain projection ' $
135 | + 'information. Do you want to rewrite it the projection?'
136 | query = dialog_message(mText, /center, /question, /default_no)
137 |
138 | if query eq 'Yes' then records[rIndex] = newRecord
139 |
140 | endif else records = [records,newRecord]
141 |
142 | endif else records = newRecord
143 |
144 | ; Write the new file
145 |
146 | outputFile = outputDir + '\' + file_basename(inputFiles[a])
147 |
148 | WriteLAS_BCAL, outputFile, header, data, records=records, /check
149 |
150 | endfor
151 |
152 | ; Destroy the status window
153 |
154 | widget_control, statBase, /destroy
155 |
156 |
157 | end
--------------------------------------------------------------------------------
/src/deprecated/procedures/LidarMetrics_BCAL.pro:
--------------------------------------------------------------------------------
1 |
2 | PRO LidarMetrics_BCAL, event
3 |
4 | compile_opt idl2, logical_predicate
5 |
6 | Catch, theError
7 | IF theError NE 0 THEN BEGIN
8 | Catch, /Cancel
9 | Help, /last_message, output=errText
10 | errMsg = dialog_message(errText, /error, title='Error processing file')
11 | return
12 | ENDIF
13 |
14 | ; read LAS files
15 |
16 | inputFiles = dialog_pickfile(title='Select LAS file(s)', filter='*.las', /multiple_files, /path)
17 | if (inputFiles[0] eq '') then return
18 |
19 | nFiles = n_elements(inputFiles)
20 |
21 | ; Read the first data file for header info
22 |
23 | ReadLAS_BCAL, inputFiles[0], header, /nodata
24 |
25 | treturns = header.nreturns
26 |
27 |
28 | ; read EVF files
29 |
30 | evfFiles = dialog_pickfile(title='Select EVF file(s)', filter='*.evf', /path)
31 | if (evfFiles[0] eq '') then return
32 |
33 | oEvf = Obj_New('IDLanROIGroup')
34 |
35 | for b=0, n_elements(evfFiles)-1 do begin
36 |
37 | evfID = envi_evf_open(evfFiles[b])
38 | envi_evf_info, evfID, num_recs=nrecs
39 |
40 | for c = 0, nrecs-1 do begin
41 | evfCoords = envi_evf_read_record(evfID, c)
42 | oEvf->Add, Obj_New('IDLanROI', evfCoords)
43 | endfor
44 |
45 | envi_evf_close, evfID
46 | endfor
47 |
48 | ; Create list of metrics
49 |
50 | metrics = {minElev :{title:'Minimum', index:-1, doIt:0}, $
51 | maxElev :{title:'Maximum', index:-1, doIt:0}, $
52 | rangeElev :{title:'Range', index:-1, doIt:0}, $
53 | meanElev :{title:'Arithmetic mean', index:-1, doIt:0}, $
54 | stdevElev :{title:'Standard deviation',index:-1, doIt:0}, $
55 | varElev :{title:'Variance', index:-1, doIt:0}, $
56 | skewElev :{title:'Skewness', index:-1, doIt:0}, $
57 | kurElev :{title:'Kurtosis', index:-1, doIt:0}, $
58 | cvElev :{title:'Coefficient of variation', index:-1, doIt:0}}
59 |
60 | nmetrics = n_tags(metrics)
61 | metricsList = strarr(nmetrics)
62 | metricsIndex = bytarr(nmetrics)
63 | metricsIndex[0] = 1
64 | for f=0, nmetrics-1 do metricsList[f] = metrics.(f).title
65 |
66 | ; initialize the user interface
67 |
68 | nReturns = n_elements(tReturns)
69 |
70 | returnList = indgen(nReturns) + 1
71 | returnList = ' Return ' + strcompress(returnList)
72 | returnList = ['All Returns', returnList]
73 |
74 | gridBase = widget_auto_base(title='Lidar Metrics')
75 | topBase = widget_base(gridBase, /row)
76 | leftBase = widget_base(topBase, /column)
77 |
78 | returnBase = widget_base(leftBase, /row)
79 | dummy = widget_pmenu(returnBase, list=returnList, default=nReturns, prompt='Select return number: ', $
80 | uvalue='returns', /auto_manage)
81 | dummy = widget_outf(leftBase, default='output.csv', prompt='Enter name of output file ', $
82 | uvalue='outFile', /auto)
83 |
84 | rightBase = widget_base(topBase)
85 | dummy = widget_multi(rightBase, list=metricsList, prompt='Select metrics:', /no_range, ysize=250, $
86 | default=metricsIndex, uvalue='metrics', /auto)
87 |
88 | result = auto_wid_mng(gridBase)
89 |
90 | if (result.accept eq 0) then return
91 | retNum = result.returns + 1
92 | metricsIndex = result.metrics
93 | CsvFile = result.outFile
94 |
95 | ; Create the list of metrics names
96 |
97 | bNames = metricsList[where(metricsIndex eq 1)]
98 | nBands = total(metricsIndex)
99 |
100 | ; Open output csv file for writing
101 |
102 | openw, CSVmetrics, CsvFile, /get_lun, width=1600
103 |
104 |
105 | for a=0, nFiles-1 do begin
106 |
107 | ; Read the data file.
108 |
109 | ReadLAS_BCAL, inputFiles[a], header, projection=defProj, pData
110 |
111 | iDim = ceil((header.xMax - xMinTile) / 0.5)
112 | jDim = ceil((header.yMax - yMinTile) / 0.5)
113 |
114 | arrayHist = histogram(floor((header.yOffset - header.yMin + pData.north * header.yScale) / baseScale) * xDim $
115 | + floor((header.xOffset - header.xMin + pData.east * header.xScale) / baseScale) $
116 | + xDim * yDim * ((retNum le nReturns) and ((pData.nReturn mod 8) ne retNum)) $
117 | + xDim * yDim * (pData.class eq 1), $
118 | reverse_indices=arrayIndex, min=0d, max=xDim*yDim)
119 |
120 | endfor
121 |
122 |
123 | for o=0, oEvf->Count()-1 do begin
124 | oTemp = oEvf->Get(position=o)
125 | oTemp->GetProperty, data=evfCoords
126 | printf, CSVmetrics, evfCoords[0,*], evfCoords[1,*]
127 | endfor
128 |
129 |
130 | free_lun, CSVmetrics
131 | close, CSVmetrics
132 |
133 | ;widget_control, gridBase, /destroy
134 | obj_destroy, oEvf
135 |
136 | END
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/src/deprecated/procedures/ReclassifyLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; NAME:
3 | ;
4 | ; ReclassifyLAS_BCAL
5 | ;
6 | ; PURPOSE:
7 | ;
8 | ; The purpose of this program is to reclassify a LAS file
9 | ;
10 | ; PRODUCTS:
11 | ;
12 | ; The output is LAS file(s) with assigned reclassification
13 | ;
14 | ; AUTHOR:
15 | ;
16 | ; Rupesh Shrestha
17 | ; Boise Center Aerospace Laboratory
18 | ; Idaho State University
19 | ; 322 E. Front St., Ste. 240
20 | ; Boise, ID 83702
21 | ; http://bcal.geology.isu.edu/
22 | ;
23 | ; DEPENDENCIES:
24 | ;
25 | ; ReadLAS_BCAL.pro
26 | ; WriteLAS_BCAL.pro
27 | ;
28 | ; MODIFICATION HISTORY:
29 | ;
30 | ;
31 | ;###########################################################################
32 | ;
33 | ; LICENSE
34 | ;
35 | ; This software is OSI Certified Open Source Software.
36 | ; OSI Certified is a certification mark of the Open Source Initiative.
37 | ;
38 | ; Copyright @ 2010 Idaho State University.
39 | ;
40 | ; This software is provided "as-is", without any express or
41 | ; implied warranty. In no event will the authors be held liable
42 | ; for any damages arising from the use of this software.
43 | ;
44 | ; Permission is granted to anyone to use this software for any
45 | ; purpose, including commercial applications, and to alter it and
46 | ; redistribute it freely, subject to the following restrictions:
47 | ;
48 | ; 1. The origin of this software must not be misrepresented; you must
49 | ; not claim you wrote the original software. If you use this software
50 | ; in a product, an acknowledgment in the product documentation
51 | ; would be appreciated, but is not required.
52 | ;
53 | ; 2. Altered source versions must be plainly marked as such, and must
54 | ; not be misrepresented as being the original software.
55 | ;
56 | ; 3. This notice may not be removed or altered from any source distribution.
57 | ;
58 | ; For more information on Open Source Software, visit the Open Source
59 | ; web site: http://www.opensource.org.
60 | ;
61 | ;###########################################################################
62 |
63 | ; Begin main program
64 |
65 | pro ReclassifyLAS_BCAL, event
66 |
67 | compile_opt idl2, logical_predicate
68 |
69 | ; Establish error handler.
70 |
71 | catch, theError
72 | if theError ne 0 then begin
73 | catch, /cancel
74 | help, /last_message, output=errText
75 | errMsg = dialog_message(errText, /error, title='Error processing request')
76 | return
77 | endif
78 |
79 | ; Open input files
80 |
81 | inputFiles = dialog_pickfile(title='Select LiDAR file(s)', filter='*.las', /multiple_files)
82 | if (inputFiles[0] eq '') then return
83 |
84 | nFiles = n_elements(inputFiles)
85 |
86 | list = ['Class 0 :','Class 1 :','Class 2 :','Class 3 :','Class 4 :','Class 5 :','Class 6 :', $
87 | 'Class 7 :','Class 8 :','Class 9 :','Class 10 :','Class 11 :','Class 12 :']
88 |
89 | classIndex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
90 | ; Get the user parameters
91 |
92 | readBase = widget_auto_base(title='Reclassify LAS files')
93 |
94 | tileBase = widget_base(readBase, /row)
95 | dummy = widget_edit(tileBase, dt=2, list=list, $
96 | prompt='Reclassification:', vals=classIndex, ysize=13, uvalue='newIndex', /auto)
97 |
98 | outputBase = widget_base(readBase, /row)
99 | fileBase = widget_base(outputBase, /column)
100 | outputField = widget_outf(fileBase, prompt='Select output directory ', /directory, $
101 | uvalue='lasName', /auto)
102 |
103 | result = auto_wid_mng(readBase)
104 | if (result.accept eq 0) then return
105 |
106 | newIndex = result.newIndex
107 |
108 | outputDir = result.lasName
109 |
110 | cIndex = where(classIndex ne newIndex, nOut)
111 |
112 | if nOut ne 0 then begin
113 |
114 | classNames = classIndex[cIndex]
115 |
116 | ; Set up ENVI status reporting box
117 | statText1 = 'Reclassifying...'
118 | statText2 = 'LAS file: ' + FILE_BASENAME(inputFiles)
119 | statText = [statText1,statText2]
120 | statBase = widget_auto_base(title='Reclassification')
121 | ENVI_REPORT_INIT, statText, BASE=statBase, TITLE='Reclassifying'
122 | envi_report_inc, statBase, nFiles
123 |
124 | for a=0,nFiles-1 do begin
125 |
126 | ; Read input lidar data to an array of structures
127 |
128 | ReadLAS_BCAL, inputFiles[a], header, data, records=records, check=check, projection=projection
129 |
130 | for i = 0, nOut-1 do begin
131 |
132 | dindex = where(data.class eq classNames[i], count)
133 |
134 | if count ne 0 then begin
135 |
136 | data[dindex].class = newIndex[cIndex[i]]
137 |
138 | endif
139 |
140 | endfor
141 |
142 | outputFile = outputDir + '\' + file_basename(inputFiles[a])
143 |
144 | WriteLAS_BCAL, outputFile, header, data, records=records, /check
145 |
146 | envi_report_inc, statBase, a
147 |
148 |
149 | endfor
150 |
151 | endif else msgBox = DIALOG_MESSAGE('No new classification was assigned', /ERROR)
152 |
153 | ;; Complete status reporting widget
154 | envi_report_init, base=StatBase, /finish
155 | end
--------------------------------------------------------------------------------
/src/deprecated/procedures/ReturnsLAS_BCAL.pro:
--------------------------------------------------------------------------------
1 | ; Sara Ehinger
2 | ; March 31, 2010
3 | ; Export Selected Returns Only
4 | ; First, Second, Third, Fouth, Fifth, Last
5 | ; DEPENDENCIES:
6 | ;
7 | ; INITDATALAS_BCAL.pro
8 |
9 | PRO ReturnsLAS_BCAL, event
10 |
11 | compile_opt idl2, logical_predicate
12 |
13 | Catch, theError
14 | IF theError NE 0 THEN BEGIN
15 | Catch, /Cancel
16 | Help, /last_message, output=errText
17 | errMsg = dialog_message(errText, /error, title='Error processing file')
18 | return
19 | ENDIF
20 |
21 | inputFile = envi_pickfile(title='Select LAS file', filter='*.las')
22 | if (inputFile eq '') then return
23 |
24 | ; ugh, need a god damn widget
25 | ; for return number and output file name
26 | ; for now hard code
27 | ; Drop down:
28 | ; Last Returns, 0
29 | ; First Returns, 1
30 | ; Second Returns, 2
31 | ; Third Returns, 3
32 | ; Fouth Returns, 4
33 | ; Fifth Returns, 5
34 | ; sReturn = result
35 | ; try first with old school idl widgets
36 | ; never mind, just use fancy envi auto widgets
37 |
38 | ReadLAS_BCAL, inputFile, header, data, records=records, projection=projection
39 | numOrigPts = header.nPoints
40 | numReturns = header.nReturns
41 |
42 | topBase = widget_auto_base(title='Export lidar data by return number')
43 |
44 | labelText = 'Selected File: ' + file_basename(inputFile)
45 | labelBase = widget_slabel(topBase, prompt=labelText, /frame)
46 |
47 | returnList = ['Last Returns','First Returns','Second Returns','Third Returns','Fourth Returns','Fifth Returns']
48 | returnBase = widget_pmenu(topBase, prompt='Select Returns', list=returnList, uvalue='outr', /auto)
49 |
50 | defOutF = file_dirname(inputFile) + '\' + file_basename(inputFile, '.las') + '_selected' + '.las'
51 | outBase = widget_outf(topBase, default=defOutF, uvalue='outf', /auto)
52 |
53 | result = auto_wid_mng(topBase)
54 | if result.accept eq 0 then return
55 |
56 |
57 | sReturn = result.outr
58 | outputFile = result.outf
59 |
60 |
61 |
62 | CASE sReturn OF
63 | 0: exportA = WHERE(floor(data.nReturn/8) mod 8 - data.nReturn mod 8 EQ sReturn, count)
64 | ELSE: exportA = WHERE(data.nReturn mod 8 EQ sReturn, count)
65 | ENDCASE
66 | ; warning if count = 0!
67 |
68 | IF count GT 0 THEN BEGIN
69 | dataStr2 = InitDataLAS_BCAL(pointFormat=header.POINTFORMAT)
70 | data2 = replicate(dataStr2, count)
71 | for a=0,count-1 do begin
72 | tempIndex = exportA[a]
73 | data2[a] = data[tempIndex]
74 | endfor
75 | ENDIF ELSE BEGIN
76 | msgText = 'There were no returns that matched your selection. Export cancelled.'
77 | msgBox = dialog_message(msgText)
78 | ; Add a return to widget?
79 | RETURN
80 | ENDELSE
81 |
82 | WriteLAS_BCAL, outputFile, header, data2, records=records, /check
83 |
84 | msgText = strcompress([sReturn, numOrigPts, count])
85 | msgBox = dialog_message(msgText, /information)
86 |
87 | data = 0B
88 | data2 = 0B
89 | header = 0B
90 |
91 | END ; ReturnsLAS.pro
92 |
93 |
94 |
--------------------------------------------------------------------------------
/src/deprecated/procedures/Wizard/Wizard_Data_Input.pro:
--------------------------------------------------------------------------------
1 | ;+
2 | ; This function is to act as the data input tool. We will try to perform some operations automatically and save
3 | ; files automatically along the way.
4 | function GetFileList, id
5 |
6 | stash = WIDGET_INFO(id, /CHILD)
7 | WIDGET_CONTROL, stash, GET_UVALUE=fileLoadStash, /NO_COPY
8 | files = fileLoadStash.fileList
9 |
10 | WIDGET_CONTROL, stash, SET_UVALUE=fileLoadStash, /NO_COPY
11 | return, files
12 | end
13 |
14 | function Wizard_Data_Input, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
15 |
16 | dataInputBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_LEFT, $
17 | XSIZE=width, SPACE=20, EVENT_PRO='WIZARD_DATA_INPUT_EV', FUNC_GET_VALUE='GetFileList')
18 |
19 | titleText = WIDGET_LABEL(dataInputBase, value='Data Preprocessing', FONT='Arial*BOLD*UNDERLINE', $
20 | /ALIGN_CENTER)
21 |
22 |
23 | descriptionLabel = WIDGET_LABEL(dataInputBase, value= $
24 | 'Please start by uploading a LiDAR dataset either in ' + String(13b) $
25 | + '.las or another text format (ASCII).', /ALIGN_LEFT, YSIZE=135, FONT='Arial*16')
26 |
27 | ;base widget for the file upload line
28 | fileLoadRowBase = WIDGET_BASE(dataInputBase, /ROW, /ALIGN_CENTER, XSIZE=width)
29 | fileLoadLabel = WIDGET_LABEL(fileLoadRowBase, UVALUE='fileLoadLabel', value='Input Dataset: ', /ALIGN_LEFT, FONT='Arial*15')
30 |
31 | fileLoadList = WIDGET_LIST(fileLoadRowBase, XSIZE=50, YSIZE=10, XOFFSET=10, UVALUE='fileList')
32 | fileList = ['']
33 | selected = -1
34 |
35 | btnsGroup = WIDGET_BASE(fileLoadRowBase, UVALUE='btnBase', XSIZE=125, /COLUMN)
36 |
37 | fileLoadBtn = WIDGET_BUTTON(btnsGroup, XSIZE=125, FONT='Arial*15', VALUE='Add File', UVALUE='FileBrowse', YSIZE=30)
38 | fileRemoveBtn = WIDGET_BUTTON(btnsGroup, XSIZE=125, FONT='Arial*15', VALUE='Remove Selected', UVALUE='fileRemove',YSIZE=30, YOFFSET=20)
39 |
40 |
41 |
42 | fileLoadStash = {fileLoadList:fileLoadList, selected:selected, fileList:fileList}
43 |
44 | WIDGET_CONTROL, WIDGET_INFO(dataInputBase, /CHILD), SET_UVALUE=fileLoadStash, /NO_COPY
45 |
46 | return, dataInputBase
47 | END
48 |
49 | ;function to get the file from the user and perform analysis
50 | function GetFiles
51 |
52 | inputFiles = ENVI_PICKFILE(TITLE='Select Input LiDAR Dataset', FILTER='*.las', /MULTIPLE_FILES)
53 | return, inputFiles
54 |
55 | end
56 |
57 | PRO WIZARD_DATA_INPUT_EV, ev
58 |
59 | ;This grabs the local stashed variable
60 | base = ev.handler
61 | stash = WIDGET_INFO(base, /CHILD)
62 | WIDGET_CONTROL, stash, GET_UVALUE=fileLoadStash, /NO_COPY
63 |
64 | ;get the button pressed
65 | WIDGET_CONTROL, ev.ID, GET_UVALUE=command
66 | CASE command OF
67 | 'FileBrowse': BEGIN
68 | ;get the file
69 | inputFiles = GetFiles()
70 | ;get the array
71 |
72 | ;list = WIDGET_INFO(fileLoadStash.fileLoadList)
73 | ;append to existing
74 | if fileLoadStash.fileList[0] EQ '' then begin
75 | files = inputFiles
76 | endif else begin
77 | files = [fileLoadStash.fileList, inputFiles]
78 | endelse
79 |
80 | ;set back to list
81 | WIDGET_CONTROL, fileLoadStash.fileLoadList, SET_VALUE=files
82 |
83 |
84 | ;now we want to try and make the top level next button visible
85 | WIDGET_CONTROL, ev.TOP, GET_UVALUE=MainStash
86 | Widget_Control, MainStash.nextBtn, Sensitive=1
87 |
88 | ;recreate the stash as we have a new array
89 | fileLoadStash ={fileLoadList:fileLoadStash.fileLoadList, selected:fileLoadStash.selected, fileList:files}
90 |
91 | END
92 | 'fileList': BEGIN
93 | ;set the currently selected item
94 | fileLoadStash.selected = ev.INDEX
95 |
96 | END
97 | 'fileRemove': BEGIN
98 | if fileLoadStash.selected NE -1 then begin
99 | index = fileLoadStash.selected
100 | array = fileLoadStash.fileList
101 | first = 0
102 | last = N_Elements(array)-1
103 | if last ne 0 then begin
104 | CASE index OF
105 | first: array = array[1:*]
106 | last: array = array[first:last-1]
107 | ELSE: array = [ array[first:index-1], array[index+1:last] ]
108 | ENDCASE
109 | endif else begin
110 | array = ['']
111 | endelse
112 | ;set back to list
113 | WIDGET_CONTROL, fileLoadStash.fileLoadList, SET_VALUE=array
114 | fileLoadStash ={fileLoadList:fileLoadStash.fileLoadList, selected:fileLoadStash.selected, fileList:array}
115 | endif
116 |
117 | END
118 | ENDCASE
119 | WIDGET_CONTROL, stash, SET_UVALUE=fileLoadStash, /NO_COPY
120 |
121 | END
--------------------------------------------------------------------------------
/src/deprecated/procedures/Wizard/Wizard_Generate_Data.pro:
--------------------------------------------------------------------------------
1 |
2 | function Wizard_Generate_Data, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
3 | genDataBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_CENTER, XSIZE=width, SPACE=20)
4 | titleText = WIDGET_LABEL(genDataBase, value='Generate Result Data', FONT='Arial*BOLD*UNDERLINE', $
5 | /ALIGN_CENTER)
6 | textWidget = WIDGET_TEXT(genDataBase, value="With Height Filtering complete, all that is left is" $
7 | + " to generate the rasters. Pressing the 'Finish' button will launch the Generate Rasters tool." $
8 | + " Once complete, the data will reside in a subdirectory off of the input file.", /WRAP, XSIZE=64, YSIZE=4)
9 |
10 |
11 | ;have to specify the event-handler manually when inside a function apparently
12 | ;XMANAGER, 'Wizard_Generate_Data', genDataBase, EVENT_HANDLER='Wizard_Generate_Data_ev'
13 | return, genDataBase
14 | END
--------------------------------------------------------------------------------
/src/deprecated/procedures/Wizard/Wizard_Height_Filtering.pro:
--------------------------------------------------------------------------------
1 | ; This file contains the ui for the height filtering
2 | ; We will include the ability to utilize a previously height filtered data set
3 |
4 | PRO Wizard_Height_Filtering_EV, event
5 | END
6 |
7 | FUNCTION Wizard_Height_Filtering, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode, XSIZE=width
8 |
9 | HeightFilterBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, Map=0, /BASE_ALIGN_LEFT, $
10 | XSIZE=width, SPACE=20, EVENT_PRO='Wizard_Height_Filtering_EV', FUNC_GET_VALUE='GetHeightFilteringSelection')
11 |
12 | titleText = WIDGET_LABEL(HeightFilterBase, value='Height Filtering', FONT='Arial*BOLD*UNDERLINE', $
13 | /ALIGN_CENTER)
14 |
15 | descriptionLabel = WIDGET_TEXT( HeightFilterBase, VALUE="Now that the data has been prepared, we need to perform height" + $
16 | " filtering. In some cases, height fltering may have already been performed either by BCAL tools, or" + $
17 | " other toolsets. If you don't know, just click the 'Next' button below.", /WRAP, XSIZE=64, YSIZE=6)
18 |
19 | RadioButtonBase = WIDGET_BASE(HeightFilterBase, SCR_XSIZE=500, /Exclusive)
20 |
21 | NotFilteredBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Not Height Filtered")
22 | FilteredBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Height Filtered Using External Tools")
23 | FilteredBCALBtn = WIDGET_BUTTON(RadioButtonBase, Value="Data Height Filtered using BCAL tools")
24 | ;set the default state to be not filtered
25 | Widget_Control, NotFilteredBtn, Set_Button=1
26 |
27 | heightFilterStash = {NotFiltered:NotFilteredBtn, Filtered:FilteredBtn, FilteredBCAL:FilteredBCALBtn}
28 | WIDGET_CONTROL, WIDGET_INFO(HeightFilterBase, /CHILD), SET_UVALUE=heightFilterStash, /NO_COPY
29 |
30 | return, HeightFilterBase
31 |
32 | END
33 |
34 | FUNCTION GetHeightFilteringSelection, id
35 | ; we are going to use return values of 0, 1, and 2 for not filtered, filtered using external tools
36 | ; and filtered using BCAL tools respectively
37 | stash = WIDGET_INFO(id, /CHILD)
38 | WIDGET_CONTROL, stash, GET_UVALUE=heightFilterStash, /NO_COPY
39 | ;grab the buttons
40 | notFiltered = WIDGET_INFO(heightFilterStash.NotFiltered, /BUTTON_SET)
41 | Filtered = WIDGET_INFO(heightFilterStash.Filtered, /BUTTON_SET)
42 | FilteredBCAL = WIDGET_INFO(heightFilterStash.FilteredBCAL, /BUTTON_SET)
43 |
44 | ;WIDGET_CONTROL, heightFilterStash.Filtered, GET_VALUE=FilteredBtn
45 | ;WIDGET_CONTROL, heightFilterStash.FilteredBCAL, GET_VALUE=FilteredBCALBtn
46 | if (notFiltered EQ 1) then return, 0
47 | if (Filtered EQ 1) then return, 1
48 | if (FilteredBCAL EQ 1) then return, 2
49 |
50 |
51 | END
--------------------------------------------------------------------------------
/src/deprecated/procedures/Wizard/Wizard_Intro.pro:
--------------------------------------------------------------------------------
1 | PRO Wizard_Intro_Event, ev
2 | base = ev.handler
3 | stash = WIDGET_INFO(base, /CHILD)
4 | WIDGET_CONTROL, stash, GET_UVALUE=introStash, /NO_COPY
5 |
6 | ;get the button pressed
7 | WIDGET_CONTROL, ev.ID, GET_UVALUE=command
8 | CASE command OF
9 | 'folderBrowse': BEGIN
10 | folder = ENVI_PICKFILE(TITLE='Choose an Output Folder', /DIRECTORY) + '\'
11 | ;folder = 'C:\proc' + '\'
12 | WIDGET_CONTROL, introStash.folderLoadText, SET_VALUE=folder
13 | WIDGET_CONTROL, ev.TOP, GET_UVALUE=MainStash
14 | Widget_Control, MainStash.nextBtn, Sensitive=1
15 |
16 | END
17 | END
18 |
19 | WIDGET_CONTROL, stash, SET_UVALUE=introStash, /NO_COPY
20 | END
21 |
22 |
23 | function Wizard_Intro, parent, UVALUE=uvalue, UNAME=uname, TAB_MODE=tab_mode
24 | ;COMPILE_OPT hidden
25 |
26 | introBase = WIDGET_BASE(parent, UVALUE=uvalue, /COLUMN, /BASE_ALIGN_TOP, XSIZE=450, YSIZE=550, FUNC_GET_VALUE='GetRootFolder', EVENT_PRO='Wizard_Intro_Event')
27 |
28 | titleText = WIDGET_LABEL(introBase, value='BCAL LiDAR Processing Wizard', FONT='Arial*BOLD*UNDERLINE', $
29 | /ALIGN_CENTER)
30 |
31 | descriptionText = WIDGET_LABEL(introBase, value= String(13B) $
32 | + 'Welcome to the BCAL LiDAR Processing Wizard. '$
33 | + String(13B) $
34 | + String(13B) $
35 | + 'This wizard will guide you through several processing steps '$
36 | + String(13B) $
37 | + 'typical for analysing LiDAR data with the BCAL tools. '$
38 | + String(13B) $
39 | + 'This tool will only include common workflows.' $
40 | + String(13B) $
41 | + 'More refined processing may require further investigation with ' $
42 | + String(13B) $
43 | + 'the other BCAL LiDAR tools.',$
44 | /ALIGN_CENTER, YSIZE=300, FONT='Arial*18')
45 |
46 | ;Directory chooser
47 | folderLoadRowBase = WIDGET_BASE(introBase, /ROW, /ALIGN_CENTER, XSIZE=width, YOFFSET=50)
48 | folderLoadLabel = WIDGET_LABEL(folderLoadRowBase, UVALUE='folderLoadLabel', value='Output Folder ', /ALIGN_LEFT, FONT='Arial*15')
49 | folderLoadText = WIDGET_TEXT(folderLoadRowBase, XSIZE=40, XOFFSET=10, UVALUE='folderName')
50 | folderLoadBtn = WIDGET_BUTTON(folderLoadRowBase, XSIZE=80, FONT='Arial*15', VALUE='Browse...', UVALUE='folderBrowse', YSIZE=30)
51 |
52 | ;save structure for events
53 | introStash = {folderLoadText:folderLoadText}
54 | WIDGET_CONTROL, WIDGET_INFO(introBase, /CHILD), SET_UVALUE=introStash, /NO_COPY
55 |
56 | return, introBase
57 | END
58 |
59 | function GetRootFolder, id
60 |
61 | stash = WIDGET_INFO(id, /CHILD)
62 | WIDGET_CONTROL, stash, GET_UVALUE=introStash, /NO_COPY
63 | WIDGET_CONTROL, introStash.folderLoadText, GET_VALUE=folder
64 |
65 | WIDGET_CONTROL, stash, SET_UVALUE=introStash, /NO_COPY
66 | return, folder
67 | end
--------------------------------------------------------------------------------
/src/deprecated/procedures/Wizard/Wizard_Utils.pro:
--------------------------------------------------------------------------------
1 | function DirectoryFromFile, fileName
2 | lastIndex = STRPOS(fileName, '/', /REVERSE_SEARCH)
3 |
4 | if (lastIndex EQ -1) THEN BEGIN
5 | ;search for windows style path
6 | lastIndex = STRPOS(filename, '\', /REVERSE_SEARCH)
7 | endif
8 |
9 | Directory = STRMID(fileName, 0, lastIndex+1)
10 | return, Directory
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/src/notes.txt:
--------------------------------------------------------------------------------
1 | BCAL Task: Update Lidar Opener to LAS 1.3 and 1.4.
2 |
3 | LidarTools_BCAL\src\lib\ReadCommonHeaderLAS.pro: Create a common header
4 | structure, which is the common part in the headers of all LAS versions.
5 |
6 | InitHeaderLAS_BCAL.pro changed with input keywords and header12, header13, and
7 | head14 definitions.
8 |
9 | LidarTools_BCAL\src\lib\ReadHeaderLAS_BCAL.pro: Changed to read the common
10 | header first. Then feed versionMajor and versionMinor to InitHeaderLAS_BCAL.
11 |
12 | LidarTools_BCAL\src\lib\ReadLAS_BCAL.pro: Changed to read the common header
13 | first. Then feed versionMajor and versionMinor to InitHeaderLAS_BCAL. Changed
14 | fixing dataOffset. Instead, fixing nPoints. Added point_lun, inputLun,
15 | header.headerSize right after reading header in order to read records
16 | correctly. Deleted uncessary records[a] = create_struct(tempRecord, 'data',
17 | ptr_new()) (put it back on 4/22/2016. Otherwise, exporting LAS to ASCII will
18 | fail.)
19 |
20 | LidarTools_BCAL\src\procedures\wizard\Wizard_Data_Preprocess.pro
21 | LidarTools_BCAL\src\procedures\AsciiToLAS_BCAL.pro
22 | LidarTools_BCAL\src\procedures\BufferLAS_BCAL.pro
23 | LidarTools_BCAL\src\procedures\DecimateLAS_BCAL.pro
24 | LidarTools_BCAL\src\procedures\FlightlineLAS_BCAL.pro
25 | LidarTools_BCAL\src\procedures\SubsetLAS_BCAL.pro
26 | LidarTools_BCAL\src\procedures\Visualize3D_BCAL.pro
27 |
28 | LidarTools_BCAL\src\lib\InitRecordLAS_BCAL.pro Add version keywords and
29 | initialize record for LAS 1.4 as well
30 |
31 | LidarTools_BCAL\src\lib\RecordsToProj_BCAL.pro Add version keywords to handle
32 | LAS 1.4 as well
33 |
34 | LidarTools_BCAL\src\lib\InitDataLAS_BCAL.pro Changed based on Tables from 4.7
35 | to 4.13
36 |
37 | BCAL Task: Implement z value reprojection from feet to meters and vice versa.
38 |
39 | LidarTools_BCAL\src\procedures\ChangeZUnitLAS_BCAL.pro Added support for
40 | changing Z unit. It checks if header.systemID has "Z unit: Feet". If so, the
41 | data Z is in feet.
42 |
43 | LidarTools_BCAL\src\LidarTools_BCAL.pro
44 | LidarTools_BCAL\src\LidarTools_BCAL_Envi4x.pro
45 | LidarTools_BCAL\src\LidarTools_BCAL_Envi5x.pro Added a widget of "Change Z Unit
46 | to LAS File(s)". Added a tool of "Assign Vegetation Height" right after
47 | "Create Bare-earth DEM". 4/21/2016
48 |
49 | LidarTools_BCAL\src\procedures\AssignVegHtLAS_BCAL.pro Implemented the
50 | capability of AssignVegHt_ui.pro in the ENVI Classic version. 4/21/2016
51 |
52 |
53 | 4/22/2016
54 |
55 | Restored records[a] = create_struct(tempRecord, 'data', ptr_new()) back in
56 | LidarTools_BCAL\src\lib\ReadLAS_BCAL.pro after customer reported failure of
57 | exporting LAS to ASCII.
58 |
59 | Fixed the bug in the output path in
60 | LidarTools_BCAL\src\procedures\AssignVegHtLAS_BCAL.pro.
61 |
62 | Also added envi_report_init, base=statBase, /finish to finish the progress bar.
63 |
64 | 4/25/2016
65 |
66 | ReadLAS_BCAL.pro: records = -1 changed to records = !NULL projection = -1
67 | changed to projection = !NULL
68 |
69 | RecordsToProj_BCAL.pro: return -1 changed to return !NULL
70 |
71 | ReadLAS_BCAL.pro: Added the versionMajor and versionMinor keywords to return
72 | the LAS version information
73 |
74 | procedures\AddProjectionLAS_BCAL.pro: procedures\AsciiToLAS_BCAL.pro:
75 | procedures\ChangeZUnitLAS_BCAL.pro: procedures\ReprojectLAS_BCAL.pro:
76 |
77 | in ChangeZUnitLAS_BCAL.pro and ReprojectLAS_BCAL.pro: Changed the logic of
78 | updating the array of records
79 |
80 | Removed IDLgrColorbar__define.pro and Trackball_define.pro from lib\fsc because
81 | both are available in IDL.
82 |
83 | Start adding versions onto .sav file per user request. First is
84 | lidartools_bcal_envi4001.sav. Basically, lidartools_bcal_envi4001.pro was
85 | copied from either lidartools_bcal.pro or lidartools_bcal_envi4x.pro. Then,
86 | edit lidartools_bcal_envi4001.pro to have consistent naming in main program
87 | LidarTools_BCAL_Envi4001 and LidarTools_BCAL_Envi4001_define_buttons Then, edit
88 | the project build property and make sure it is lidartools_bcal_envi4001.sav to
89 | be built.
90 |
91 | 4/29/2016: Added NormalizeElevLAS_BCAL.pro in procedure. Implemented the tool
92 | "Normalize Elevation" in lidartools_bcal_envi4002.sav.
93 |
94 | 5/2/2016: FileInfoLAS_BCAL.pro Added checking negative values and warning
95 | message box.
96 |
--------------------------------------------------------------------------------