An arcpy-based regional-scale landscape ecological risk index data production method
By using ArcPy tools to convert raster grids into vector data and calculate ecological risk indices, the problems of high memory consumption and computational complexity in large-scale regions are solved, achieving efficient generation of ecological risk indices and supporting large-scale ecological and environmental risk assessment.
Patent Information
- Application Number
- CN202310977374.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-08-04
AI Technical Summary
Existing technologies face problems such as excessive memory consumption, high computational complexity, and large data processing workload when calculating ecological risk indices for large-scale regions, resulting in low efficiency in index generation and difficulty in meeting the needs of regional or continental-scale ecological and environmental risk assessment.
The ArcPy tool was used to convert raster data into vector data. The frequency of quadrats and the landscape ecological risk index were calculated by defining core functions. The functional modules of ArcPy were used for automated processing, including raster to vector conversion, quadrat data statistics and landscape ecological risk index calculation.
It significantly improves computational efficiency at the regional scale, reduces memory consumption, simplifies data processing complexity, and generates high-quality landscape ecological risk index data, which is convenient for further analysis and application.
Smart Images

Figure CN117009450B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of ecological environment data processing, and particularly relates to a regional scale landscape ecological risk index data production method based on ArcPy. BACKGROUND
[0002] Landscape ecological risk relies on ecological processes and spatial patterns in landscape ecology to analyze the spatio-temporal heterogeneity characteristics of the ecological risk of a study area. Carrying out landscape ecological risk assessment can reveal the impact of natural changes or human disturbances on the landscape composition and structure of a region, and further reveal the landscape ecological security status of the region. In order to quantify the degree of landscape ecological risk, researchers have proposed a landscape ecological risk index.
[0003] At present, the main method for calculating the ecological risk index is to use Fragstats software and Excel software. That is, first, use Fragstats software to calculate landscape pattern indexes such as landscape fragmentation, landscape separation and landscape dominance, and then import the landscape indexes into Excel software to calculate the ecological risk index manually. This method has the following problems: (1) Fragstats software can only process a small amount of raster data, that is, a small number of raster grids. When the amount of raster grid data increases, Fragstats software will have problems such as excessive memory consumption, program non-response and other problems, which will interrupt the processing task. (2) Manually calculating the landscape ecological risk index in Excel software will face problems such as complex calculation process, large data processing workload, and difficulty in ensuring the quality of the generated index.
[0004] At the regional scale or continental scale, raster grid data has more raster quantities and large data volumes. This poses a serious challenge to the existing calculation method, so that high-efficiency and high-quality index data cannot be produced, thereby making researchers face great difficulties in assessing the ecological environment risk of large-scale regions. There is an urgent need to propose a simple and efficient index data production method to solve the shortcomings of the existing method. SUMMARY
[0005] In view of the problems existing in the prior art, the present application provides a regional scale landscape ecological risk index data production method based on ArcPy, to improve the efficiency of automatically calculating the landscape ecological risk index at the regional scale or even the continental scale, and effectively solve the problems of excessive memory consumption, complex manual calculation process, and large data processing workload when using the existing method to process regional scale or continental scale data.
[0006] To achieve the above purpose, the technical scheme adopted by the present application is: a regional scale landscape ecological risk index data production method based on ArcPy, comprising the following steps:
[0007] Step 1: Convert the grid mesh to vector data;
[0008] Step 2: Calculate the sample data, which is used to count the frequency of a certain landscape type in the sample data in the patch;
[0009] Step 3: Define the core function of the landscape ecological risk index;
[0010] Step 4: Calculate the landscape ecological risk index.
[0011] Further, the step 1 specific steps are:
[0012] Step 11: Collect grid mesh data,
[0013] Collect the segmented regional scale land use / land cover grid mesh data set, ensure the spatial continuity of the grid mesh, and cover the entire study area; each grid mesh constitutes an ecological risk zone;
[0014] Step 12: Define the raster-to-vector function,
[0015] Define the raster-to-vector function raster_to_shp(), the input parameters include the raster input data raster_in before conversion and the vector output data shp_out after conversion; use try-except to capture exceptions; in the try block, use the arcpy.RasterToPolygon_conversion() function to convert the raster data to polygon vector data;
[0016] Step 13: Perform the conversion operation,
[0017] First, set the directory of the grid mesh data to be converted tif_dir, use the get_all_files() function to get all the subdirectories tif files in this directory; then use the for loop to traverse the tif files; in the for loop body, set the geographic database location to store the converted vector data, use the arcpy.Exists() function to judge whether the database exists, if not, use the arcpy.CreateFileGDB_management() to create the database; then use the raster_to_shp() function to convert the current raster data to vector data and save it to the geographic database.
[0018] Further, the step 2 specific steps are:
[0019] Step 21: Get the sample data geographic database,
[0020] Setting the sample plot geographic database directory gdb_dir, using the get_all_gdbs() function to obtain all geographic databases in the directory;
[0021] Step 22: traverse the elements in the geographic database,
[0022] Using a for loop to traverse all geographic databases, using arcpy.da.Walk() to read elements in the database, returning a walk containing database paths, directory names, and file names, etc.
[0023] Step 23: Calculate the frequency of each landscape type sample plot,
[0024] Using a for loop to traverse walk, using a for loop to traverse grid element files in the outer loop body, in the inner loop body, accumulating the total sample plot frequency, using the arcpy.da.SearchCursor() function to query the attribute table of the current element file, extracting the field values "GRIDCODE", "Shape_Area" and "Shape_Length" as a collection row returned, using the sample plot statistics function sample_stats() to obtain the sample plot frequency of each type in the current grid element, and accumulating and summing the sample plot type data;
[0025] Step 24: Summarize the sample plot frequency,
[0026] Summarize the sample plot frequency of each landscape type and the total sample plot frequency, convert it to a string, and store it in the pre-set sample plot result output directory through the write_txt() function.
[0027] Further, the step 3 is specifically:
[0028] Step 31: Define the patch statistics function,
[0029] Define the patch statistics function block_stats(), the input parameter is the patch data block, in the function body, first use the len() function to calculate the patch number NP, then use the transpose() function to transpose the input data, then use the sum() function to summarize the patch type area CA and patch type perimeter CP of the transposed data, then use the m2_to_ha() function to convert the unit of CA from square meters to hectares, and finally use the round() function to round CA and CP respectively;
[0030] Step 32: Define the function to calculate the number of patches of type area,
[0031] Defining the function calc_classArea_patchNum() to calculate the area of landscape types and the number of patches, with the input parameter being the attribute table of features data_in;
[0032] Step 33: Defining the function calc_eri() to calculate the landscape ecological risk index
[0033] Defining the function calc_eri() to calculate the landscape ecological risk index, with the input parameters including type data class_data, total landscape area A, total number of patches M, vulnerability index FI of each landscape type, sample data sampleQ, and disturbance component weight W;
[0034] Step 34: Defining the function output_eri() to output the landscape ecological risk index
[0035] Defining the function output_eri() to output the landscape ecological risk index, with the input parameter being the landscape ecological risk index dictionary eri. In the function body, first get the component index data according to the dictionary key "INDEX", then use the for loop to iterate through data, and in the loop body, update the output content content according to the component index iteration.
[0036] Further, the step 32 specifically comprises:
[0037] 1) Extracting landscape types, first converting the input data to a matrix using the np.array() function, then transposing the matrix using the transpose() function, and finally filtering the landscape types to generate cls using the set() function;
[0038] 2) Summarizing patch data, first defining the list block to store the area and perimeter of individual landscape types, and defining patch_content to store patch content; then using a for loop to iterate through the landscape types cls, and in the loop body, using for loop and conditional judgment to summarize the area and perimeter of individual landscape types by type to generate patch_content and block;
[0039] 3) Summarizing type data, first defining class_content to store type content and class_data to store type data list, and initializing total landscape area A and total number of patches M; using a for loop to iterate through block, and in the loop body, using the block_stats() function to calculate the number of patches NP, patch area CA, and patch perimeter CP of individual landscape types; updating the type number list class_data, and iteratively updating the type content class_content, the total landscape area A, and the total number of patches M.
[0040] Further, the step 33 specifically comprises the following steps:
[0041] 1) define the dictionary eri storing component index and landscape ecological risk index, and traverse the type data by for loop;
[0042] 2) in the loop body, check whether the current type area or perimeter is 0, if 0, skip the loop;
[0043] 3) in the loop body, calculate the landscape fragmentation CI, landscape separation SI, landscape dominance DI, landscape interference LDI, landscape fractal dimension FDI, landscape loss degree index RI and the landscape ecological risk index ERI of the current type according to the respective component index calculation formula; update the landscape ecological risk index TERI according to ERI iteration.
[0044] Further, the step 4 is specifically as follows:
[0045] Step 41: first set the landscape type geographic database path gdb dri, the output result storage path out path, and the sample frame statistical file path sample txt, then judge whether the sample txt exists, if not, set the sample frame data sampleQ as empty;
[0046] Step 42: use the get_all_gdbs() function to obtain all geographic databases saved as gdbs, set the landscape ecological risk index storage file res_save, and write the title information into the file;
[0047] Step 43: use for loop to traverse the geographic database gdbs, in the loop body, use the arcpy.da.Walk() function to read the polygon feature of the current geographic database, return the walk containing the data set of path, directory name and file name, and then use for loop to traverse the walk to obtain the feature file name file_names;
[0048] Step 44: use for loop to traverse file_names, in the current loop body, use the arcpy.da.SearchCursor() function to read the attribute table of the current feature and update it to data; check whether the current data is empty, if empty, skip the loop;
[0049] Step 45: then, use the calc_classArea_patchNum() function to generate type data and patch data, and write them into type file and patch file respectively;
[0050] Step 46: Next, use the calc_eri() function to calculate the landscape ecological risk index, use the eri_output() function to output each component index, and finally write the component index results to the component index file. Then, append the final landscape ecological risk index result to the res_save file.
[0051] Compared with some existing calculation methods, the beneficial effects of the present invention include the following points.
[0052] (1) This invention significantly improves the efficiency of calculating the landscape ecological risk index at the regional scale. It reduces the consumption of ordinary computer memory during data processing and avoids problems such as memory overflow or insufficient memory.
[0053] (2) The results generated by this invention not only include patch files, type files, and landscape ecological risk index files used for process calculations, but also the final landscape ecological risk index vector data with geographic coordinates. This greatly reduces the complexity of manual calculations and the workload of data processing in existing methods. This provides great convenience for researchers to conduct further data analysis and data application work. Attached Figure Description
[0054] Figure 1 This is a schematic diagram of the technical process of the present invention.
[0055] Figure 2 This is a diagram illustrating the effect of converting raster grid data to vector data in an embodiment of the present invention.
[0056] Figure 3 The images show the generated patch files, type files, and landscape ecological risk index files in this embodiment of the invention.
[0057] Figure 4 This is a spatial distribution diagram of the landscape ecological risk index generated in an embodiment of the present invention. Detailed Implementation
[0058] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. However, it should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of the invention.
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention.
[0060] Technical processes such as Figure 1 As shown, the specific steps include the following:
[0061] Step 1: Convert the raster grid to vector data
[0062] (1) Collect raster grid data
[0063] We collected segmented regional-scale land use / land cover raster datasets, ensuring that the raster grids were spatially continuous and covered the entire study area. Each raster grid constituted an ecological risk zone.
[0064] (2) Define the raster to vector function
[0065] Define a function `raster_to_shp()` to convert raster TIFF data to vector SHP data. The input parameters include the raster input data `raster_in` before conversion and the vector output data `shp_out` after conversion. Use a try-except block to catch exceptions. Within the try block, use the `arcpy.RasterToPolygon_conversion()` function to convert the raster data to polygon vector data. The relevant code for this step is as follows:
[0066]
[0067] (3) Perform the conversion operation
[0068] First, set the directory `tif_dir` for the raster data to be converted, and use the `get_all_files()` function to retrieve all subdirectories containing tif files within that directory. Then, use a `for` loop to iterate through the tif files. Within the `for` loop, set the location of the geodatabase to store the converted vector data, and use the `arcpy.Exists()` function to check if the database exists. If it doesn't exist, use `arcpy.CreateFileGDB_management()` to create the database. Next, use the `raster_to_shp()` function to convert the current raster data into vector data and save it to the geodatabase.
[0069] The relevant code for this step is:
[0070]
[0071]
[0072] The effect of converting the raster grid into vector data after the above steps is shown in the image below. Figure 2 As shown.
[0073] Step 2: Calculate quadrat data
[0074] Quadrat data is used to count the frequency of a specific landscape type within a patch. The implementation process is as follows:
[0075] (1) Obtaining sample plot data from a geographic database
[0076] Set the sample plot geodatabase directory gdb_dir, and use the get_all_gdbs() function to retrieve all geodatabases in this directory.
[0077] (2) Traverse the elements in the geographic database
[0078] Use a for loop to iterate through all geodatabases, and use arcpy.da.Walk() to read the features in the database, returning a walk that contains a collection of database paths, directory names, and file names.
[0079] (3) Calculate the frequency of quadrats for each landscape type.
[0080] The `walk` function is used to iterate through the grid feature file within the outer loop. In the inner loop, the total quadrat frequencies (`sample_cnt`) are accumulated. The `arcpy.da.SearchCursor()` function is then used to query the attribute table of the current feature file, extracting the values "GRIDCODE", "Shape_Area", and "Shape_Length" as a set `row`. Finally, the `sample_stats()` function is used to obtain the frequencies of each type of quadrat in the current grid feature, and the `sample_cls` data is summed.
[0081] (4) Summarize the frequency of sample plots
[0082] Summarize the frequency of quadrats for each landscape type and the total frequency of quadrats, convert them into the string "sample_content", and store the string in the pre-defined quadrat result output directory using the "write_txt()" function.
[0083] The relevant code for the above implementation process is as follows:
[0084]
[0085]
[0086]
[0087] Step 3: Define the core function of the landscape ecological risk index
[0088] (1) Define the patch statistics function
[0089] Define a patch statistics function `block_stats()`, taking patch data `block` as input. Within the function body, first, the `len()` function calculates the number of patches `NP`. Then, the `transpose()` function transposes the input data, and the `sum()` function summarizes the patch type area `CA` and patch type perimeter `CP` from the transposed data. Next, the `m2_to_ha()` function converts the unit of `CA` from square meters to hectares. Finally, the `round()` function rounds `CA` and `CP` to the nearest integer. The relevant code for this function is as follows:
[0090]
[0091]
[0092] (2) Define the function for calculating the number of patches of area.
[0093] Define a function `calc_classArea_patchNum()` to calculate the area and number of patches for each landscape type, taking the feature attribute table `data_in` as input. The implementation of this function is as follows:
[0094] 1) Extracting landscape types. First, use the np.array() function to convert the input data into a matrix, then use the transpose() function to transpose the matrix, and finally use the set() function to remove duplicates and filter the landscape types to generate cls.
[0095] 2) Summarize patch data. First, define a list `block` to store the area and perimeter of a single landscape type, and define a list `patch_content` to store the patch content. Then, use a for loop to iterate through the landscape types `cls`. Within the loop body, use the for loop and conditional statements to summarize the area and perimeter of a single landscape type, generating `patch_content` and `block`.
[0096] 3) Summarize type data. First, define `class_content` to store type content and `class_data` to store the list of type data, and initialize the total landscape area `A` and the total number of patches `M`. Use a `for` loop to iterate through the blocks. Within the loop, use the `block_stats()` function to count the number of patches `NP`, patch area `CA`, and patch perimeter `CP` for a single landscape type. Update the type list `class_data`, and iteratively update the type content `class_content`, the total landscape area `A`, and the total number of patches `M`.
[0097] The relevant code for the above implementation process is as follows:
[0098]
[0099]
[0100]
[0101] (3) Define the function for calculating the landscape ecological risk index.
[0102] Define a function `calc_eri()` to calculate the landscape ecological risk index. Input parameters include class data (`class_data`), total landscape area (`A`), total number of patches (`M`), vulnerability index (`FI`) for each landscape type, sample data (`sampleQ`), and disturbance component weights (`W`). The implementation process of this function is as follows:
[0103] 1) Define a dictionary eri for storing component indices and landscape ecological risk indices, and use a for loop to iterate through the data types.
[0104] 2) Within the loop, check if the area or perimeter of the current type is 0. If it is 0, skip the loop.
[0105] 3) Within the loop, calculate the landscape fragmentation index (CI), landscape separation index (SI), landscape dominance index (DI), landscape disturbance index (LDI), landscape fractal dimension index (FDI), landscape loss index (RI), and current-type landscape ecological risk index (ERI) according to the formulas for each component index. Iteratively update the landscape ecological risk index (TERI) based on the ERI.
[0106] The relevant code for the above implementation process is as follows:
[0107]
[0108]
[0109]
[0110] (4) Define the output function of the landscape ecological risk index
[0111] Define a function to output the landscape ecological risk index, taking the landscape ecological risk index dictionary `eri` as input. Within the function, first, the component indices `data` are obtained based on the dictionary key "INDEX". Then, a `for` loop iterates through `data`, updating the output content `content` iteratively based on the component indices within the loop. The relevant code for this function is as follows:
[0112]
[0113]
[0114] Step 4: Calculate the landscape ecological risk index
[0115] (1) First, set the landscape type geodatabase path gdb_dri, the output result storage path out_path, and the sample plot statistics file path sample_txt. Then, check if sample_txt exists. If it does not exist, set the sample plot data sampleQ to empty.
[0116] (2) Use the get_all_gdbs() function to get all geodatabases and save them as gdbs. Set the landscape ecological risk index storage file res_save and write the title information into the file.
[0117] (3) Use a for loop to iterate through the geodatabase gdbs. Within the loop body, use the arcpy.da.Walk() function to read the polygon features of the current geodatabase and return a walk containing a data set including paths, directory names, and file names. Then, use a for loop to iterate through the walk to obtain the feature file names file_names.
[0118] (4) Use a for loop to iterate through file_names. Within the current loop body, use the arcpy.da.SearchCursor() function to read the attribute table of the current feature and update it in data. Check if the current data is empty; if it is, skip the loop.
[0119] (5) Next, the calc_classArea_patchNum() function is used to generate type data and patch data, and then written to the type file and patch file respectively.
[0120] (6) Next, the landscape ecological risk index is calculated using the calc_eri() function, and each component index is output using the eri_output() function. Finally, the component index results are written to the component index file, and the final landscape ecological risk index results are appended to the res_save file.
[0121] The relevant code for implementing the above process is as follows:
[0122]
[0123]
[0124] After the above steps, this method can quickly calculate the landscape ecological risk index for regional-scale raster data. The generated patch files, type files, and landscape ecological risk index files are shown in the following figures. Figure 3 As shown in the figure, the spatial distribution effect of the generated landscape ecological risk index is as follows: Figure 4As shown, the generated landscape ecological risk index data is stored in vector data form, which can be further converted into raster data using methods such as vector-to-raster conversion or spatial interpolation in geographic information system software, so as to facilitate researchers in carrying out relevant data analysis and application work.
[0125] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions or improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for producing regional-scale landscape ecological risk index data based on ArcPy, characterized in that, Includes the following steps; Step 1: Convert the raster grid into vector data; Step 2: Calculate quadrat data. Quadrat data is used to count the frequency of a certain landscape type in the quadrat data within a patch. Step 3: Define the core function of the landscape ecological risk index; The specific steps of step 3 are as follows: Step 31: Define the patch statistics function. Define a patch statistics function block_stats(), with patch data block as input parameter. In the function body, first use len() function to calculate the number of patches NP, then use transpose() function to transpose the input data, then use sum() function to summarize the patch type area CA and patch type perimeter CP of the transposed data, then use m2_to_ha() function to convert the unit of CA from square meters to hectares, and finally use round() function to round CA and CP respectively. Step 32: Define a function to calculate the number of patches of a given area. Define a function calc_classArea_patchNum() to calculate the area and number of patches of a landscape type, with the feature attribute table data_in as the input parameter; Step 33: Define the function for calculating the landscape ecological risk index. Define a function calc_eri() to calculate the landscape ecological risk index. The input parameters include class data, total landscape area A, total number of patches M, vulnerability index FI for each landscape type, sample data sampleQ, and disturbance component weight W. Step 34: Define the output function of the landscape ecological risk index Define a landscape ecological risk index output function. The input parameter is the landscape ecological risk index dictionary eri. In the function body, first obtain the component index data according to the dictionary key "INDEX", then use a for loop to traverse data. In the loop body, update the output content content iteratively according to the component index. Step 4: Calculate the landscape ecological risk index; The specific steps of step 4 are as follows: Step 41: First, set the landscape type geodatabase path gdb_dri, the output result storage path out_path, and the sample statistics file path sample_txt. Then, check if sample_txt exists. If it does not exist, set the sample data sampleQ to empty. Step 42: Use the get_all_gdbs() function to retrieve all geodatabases and save them as gdbs. Set the landscape ecological risk index storage file res_save and write the title information into this file. Step 43: Use a for loop to traverse the geodatabase gdbs. In the loop body, use the arcpy.da.Walk() function to read the polygon features of the current geodatabase and return a walk containing a data set of paths, directory names, and file names. Then, use a for loop to traverse the walk to get the feature file names file_names. Step 44: Use a for loop to iterate through file_names. Within the current loop body, use the arcpy.da.SearchCursor() function to read the attribute table of the current feature and update it to data; check if the current data is empty. If it is empty, skip the loop. Step 45: Next, use the calc_classArea_patchNum() function to generate type data and patch data, and write them to the type file and patch file respectively; Step 46: Next, use the calc_eri() function to calculate the landscape ecological risk index, use the eri_output() function to output each component index, and finally write the component index results to the component index file. Then, append the final landscape ecological risk index result to the res_save file.
2. The method for producing regional-scale landscape ecological risk index data based on ArcPy according to claim 1, characterized in that, The specific steps of step 1 are as follows: Step 11: Collect raster grid data. We collected segmented regional-scale land use / land cover raster datasets to ensure that the raster grids were spatially continuous and covered the entire study area; each raster grid constituted an ecological risk zone. Step 12: Define the raster-to-vector function. Define a raster-to-vector function raster_to_shp(), with input parameters including raster input data before conversion and vector output data after conversion; within the function body, use try-except to catch exceptions; in the try block, use the arcpy.RasterToPolygon_conversion() function to convert the raster data into polygon vector data; Step 13: Perform the conversion operation. First, set the directory for the raster data to be converted as `tif_dir`, and use the `get_all_files()` function to retrieve all tif files in the `tif_dir` directory. Then, use a `for` loop to iterate through the tif files. Within the `for` loop, set the location of the geodatabase to store the converted vector data, and use the `arcpy.Exists()` function to check if the database exists. If it does not exist, use `arcpy.CreateFileGDB_management()` to create the database. Next, use the `raster_to_shp()` function to convert the current raster data into vector data and save it to the geodatabase.
3. The method for producing regional-scale landscape ecological risk index data based on ArcPy according to claim 1, characterized in that, The specific steps of step 2 are as follows: Step 21: Obtain the geodatabase of sample plot data. Set the sample plot geodatabase directory gdb_dir, and use the get_all_gdbs() function to retrieve all geodatabases in the gdb_dir directory; Step 22: Traverse the features in the geodatabase. Use a for loop to iterate through all geodatabases, use arcpy.da.Walk() to read the features in the database, and return a walk containing a set of database paths, directory names, and file names; Step 23: Calculate the frequency of quadrats for each landscape type. Use a for loop to iterate through the walk function. In the outer loop, use a for loop to iterate through the grid feature file. In the inner loop, accumulate the total quadrat frequencies. Use the arcpy.da.SearchCursor() function to query the attribute table of the current feature file, extract the field values "GRIDCODE", "Shape_Area", and "Shape_Length" as a set row and return it. Use the quadrat statistics function sample_stats() to get the frequency of each type of quadrat in the current grid feature, and sum the quadrat type data. Step 24: Summarize the frequency of quadrats. Summarize the frequency of quadrats for each landscape type and the total frequency of quadrats, convert them into strings, and store the strings in a pre-defined quadrat result output directory using the write_txt() function.
4. The method for producing regional-scale landscape ecological risk index data based on ArcPy according to claim 1, characterized in that, Step 32 specifically involves: 1) To extract landscape types, first use the np.array() function to convert the input data into a matrix, then use the transpose() function to transpose the matrix, and finally use the set() function to remove duplicates and filter landscape types to generate cls; 2) Summarize patch data. First, define a list block to store the area and perimeter of a single landscape type, and define patch_content to store the patch content. Then, use a for loop to traverse the landscape type cls. Within the loop body, use the for loop and conditional judgment to summarize the area and perimeter of a single landscape type by type, and generate patch_content and block. 3) Summarize the type data. First, define class_content to store the type content and class_data to store the type data list. At the same time, initialize the total landscape area A and the total number of patches M. Use a for loop to iterate through the blocks. Within the loop, use the block_stats() function to count the number of patches (NP), patch area (CA), and patch perimeter (CP) for a single landscape type. Update the list of types (class_data), and simultaneously iterate and update the type content (class_content), total landscape area (A), and total number of patches (M).
5. The method for producing regional-scale landscape ecological risk index data based on ArcPy according to claim 1, characterized in that, The specific steps of step 33 are as follows: 1) Define a dictionary eri for storing component indices and landscape ecological risk indices, and use a for loop to iterate through the data types; 2) Within the loop, check if the area or perimeter of the current type is 0; if it is 0, skip the loop. 3) Within the loop, calculate the landscape fragmentation index CI, landscape separation index SI, landscape dominance index DI, landscape disturbance index LDI, landscape fractal dimension index FDI, landscape loss index RI, and current type landscape ecological risk index ERI according to the calculation formulas of each component index; and iteratively update the landscape ecological risk index TERI based on ERI.
Citation Information
Patent Citations
Small watershed region-oriented landslide hazard risk division method based on mechanism analysis
CN103455711A