UrbanVCA-Python

概述(Overview)

本项目是UrbanVCA的Python版本。
This repository is the Python version of UrbanVCA.

UrbanVCA是一款基于真实地块和矢量元胞自动机(Vector-based CA)的城市土地利用变化模拟和预测系统。
UrbanVCA is a GeoAI-based software for the simulation and prediction of urban development and land-use change process by using vector-based cellular automata.

该系统同时支持城市内的土地利用相互转换和城市用地扩张过程。
UrbanVCA supports the simulation and prediction of both land use interchange and urban land use expansion processes within the city.

本项目实现了三个数据预处理功能(即土地利用重分类功能、矢量动态地块分类功能和土地利用数据匹配功能),总体发展概率计算功能和UrbanVCA模型模拟功能。
This repository implements three data preprocessing functions (including land use reclassification function, vector dynamic land use parcel splitting function and land use data matching function), overall development probability calculation function, and UrbanVCA model simulation function.

本项目基于OSGeo和GDAL。
This repository is based on OSGeo and GDAL.

[Github] whuyao/UrbanVCA_Python

运行流程(Operation Process)

程序运行顺序:
The order in which the program runs:

- preparation
    - reclassification
    - DLPS
    - match
    - zonal
- mining_Pg_RF
- simulation

模块说明(Module Description)

1.土地利用重分类(land use reclassification function)

利用preparation_reclassification.py程序进行土地利用重分类。
Utilize the preparation_reclassification.py program for land use reclassification.

该模块可以基于重分类字典, 将重分类字段的值转化为新值后写入新字段。
This module allows for the transformation of values in a reclassification field to new values based on a reclassification dictionary and writing them into a new field.

用户需要在主函数中设置各个参数。
Users are required to set various parameters in the main function.

参数input_file_nameoutput_file_name分别为土地利用类型文件(.shp)的地址和结果文件的输出地址;
The input_file_name and output_file_name parameters represent the file path of the land use type file (.shp) and the output path of the result file, respectively.

参数reclass_field_name为土地利用类型文件中代表土地利用类型的字段名;
The reclass_field_name parameter denotes the field name representing land use types in the land use type file.

参数new_field_name为进行重分类后,新的土地利用类型的字段名;
The new_field_name parameter specifies the field name for the new land use types after reclassification.

参数reclass_dict为重分类字典,字典的键代表重分类前的土地利用类型,字典的值代表重分类后的土地利用类型。
The reclass_dict parameter is a reclassification dictionary, where the keys represent the original land use types to be reclassified, and the values represent the new land use types after reclassification.

2.矢量动态地块分裂(vector dynamic land use parcel splitting function)

利用preparation_DLPS.py进行矢量动态地块分裂。
Utilize the preparation_DLPS.py program for vector dynamic parcel splitting.

该模块可以基于地块的凸包的MABR对地块进行分割。
This module allows for parcel segmentation based on the Minimum Area Bounding Rectangle (MABR) of the parcel's convex hull.

用户需要在主函数中设置各个参数。
Users are required to set various parameters in the main function.

参数input_file_nameoutput_file_name分别为进行土地利用重分类后的土地利用类型文件(.shp)的地址和结果文件的输出地址;
The input_file_name and output_file_name parameters represent the file path of the land use types file (.shp) after land use reclassification and the output path of the result file, respectively.

参数max_iteration为分割次数;
The max_iteration parameter specifies the number of segmentation iterations.

参数allowable_parameter为容许参数。
The allowable_parameter parameter represents the allowable parameter for the segmentation process.

3.土地利用数据匹配功能(land use data matching function)

利用preparation_match.py进行土地利用的数据匹配。
Utilize preparation_match.py program for land use data matching.

该模块可以在两个不同时期地块中,将距离最近的地块视为同一地块,匹配前期和后期的用地类型。
This module can identify the closest parcels between two different time periods and consider them as the same parcel, matching the land use types between the earlier and later periods.

用户需要在主函数中设置各个参数。
Users are required to set various parameters in the main function.

参数before_file_name为前期的进行矢量动态地块分裂后的土地利用类型文件的地址;
The before_file_name parameter represents the file path of the land use types file after vector dynamic parcel splitting for the earlier period.

参数before_landuse_field_name为前期土地利用类型中表示用地类型的字段名;
The before_landuse_field_name parameter denotes the field name in the earlier period land use types file that indicates the land use type.

参数after_file_name为后期的进行矢量动态地块分裂后的土地利用类型文件的地址;
The after_file_name parameter represents the file path of the land use types file after vector dynamic parcel splitting for the later period.

参数after_landuse_field_name为后期土地利用类型中表示用地类型的字段名;
The after_landuse_field_name parameter specifies the field name in the later period land use types file that represents the land use type.

参数output_file_name为结果文件的输出地址。
The output_file_name parameter denotes the output path for the result file.

4.总体发展概率计算功能(overall development probability calculation function)

利用preparation_zonal.pymining_Pg_RF.py实现总体发展概率计算功能。
Utilize preparation_zonal.py and mining_Pg_RF.py to implement the overall development probability calculation function.

preparation_zonal.py用于分区统计,计算地块覆盖到的像元的统计值(平均值、最大值、最小值)。
preparation_zonal.py is used for zonal statistics, calculating statistical values (mean, maximum, minimum) of the pixels covered by the parcels.

用户需要在主函数中设置各个参数。
Users are required to set various parameters in the main function.

参数polygon_file_name表示匹配好的土地利用类型shapefile文件地址。
The polygon_file_name parameter represents the address of the matched land use type shapefile.

参数raster_file_config_list为多个tiff影像配置的列表。在每个影像中,第一项为影像地址,第二项为空间变量的字段名,第三项为像元的统计方式。
The raster_file_config_list parameter is a list of configurations for multiple TIFF images. For each image, the first item is the image address, the second item is the field name of the spatial variable, and the third item is the method of pixel statistics.

参数output_csvfile_name为csv结果文件的地址。
The output_csvfile_name parameter denotes the address of the CSV result file.

参数output_shapefile_name为shapefile结果文件的输出地址。
The output_shapefile_name parameter represents the output address of the shapefile result file.

mining_Pg_RF.py可以利用随机森林算法,以地块为样本,地块在各空间变量上的的分区统计值为特征,后期土地利用类型为标签,挖掘总体发展概率。
mining_Pg_RF.py can utilize the Random Forest algorithm to calculate the overall development probability by using parcels as samples, the zonal statistical values of parcels on various spatial variables as features, and the later land use types as labels.

用户需要在主函数中设置各个参数。
Users are required to set various parameters in the main function.

参数input_file_name为分区统计后的shapefile文件地址。
The input_file_name parameter represents the address of the zonal statistics shapefile.

参数output_shapefile_name为shapefile结果文件的输出地址。
The output_shapefile_name parameter denotes the output address of the shapefile result file.

参数output_csvfile_name为csv结果文件的输出地址。
The output_csvfile_name parameter represents the output address of the CSV result file.

参数label_field_name为后期土地利用类型的字段名。
The label_field_name parameter is the field name of the later land use types.

参数spatial_variable_field_name_list为各空间变量的字段名的列表。
The spatial_variable_field_name_list is a list of field names for various spatial variables.

参数tree_count为随机森林中决策树数量。
The tree_count parameter specifies the number of decision trees in the Random Forest.

5.UrbanVCA模型模拟功能(UrbanVCA model simulation function)

利用simulation .py实现土地利用模拟功能。
Utilize simulation .py program to implement land use simulation functionality.

该模快利用UrbanVCA模型,对前期的土地利用类型进行模拟,并结合后期真实的土地利用类型数据,对模拟精度进行评价。
This module utilizes the UrbanVCA model to simulate the land use types from the earlier period and evaluates the simulation accuracy (Figures of Merit (FoM), User's Accuracy (UA), and Producer's Accuracy (PA))by comparing with the actual land use types from the later period.

用户需要在主函数中设置各个参数。
Users are required to set various parameters in the main function.

参数input_file_name为进行总体发展概率计算后的土地利用类型shapefile文件地址。
The input_file_name parameter represents the address of the land use types shapefile after overall development probability calculation.

参数restricted_area_file_name为限制区域shapefile文件地址。
The restricted_area_file_name parameter denotes the address of the restricted area shapefile.

参数output_file_name为结果文件的输出地址。
The output_file_name parameter represents the output address of the result file.

参数before_landuse_field_name为前期土地利用类型的字段名。
The before_landuse_field_name parameter is the field name of the land use types from the earlier period.

参数after_landuse_field_name为后期土地利用类型的字段名。
The after_landuse_field_name parameter is the field name of the land use types from the later period.

参数RA_alpha为随机因子计算参数。
The RA_alpha parameter is used for calculating the random factor.

参数buffer_range为邻域范围。
The buffer_range parameter specifies the neighborhood range.

参数iteration为迭代次数。
The iteration parameter indicates the number of iterations.

参数change为转换矩阵,用户可以手动设置土地之间的转换关系。若矩阵第n行第m列的值为1则代表类型n可以转换为类型m;若为0则不能转换。
The change parameter is the conversion matrix, where users can manually set the conversion relationships between land use types.
If the value in the n row and m column of the matrix is 1, it means type n can be converted to type m; if it is 0, then it cannot be converted.

6.其他模块(Other modules)

assessment_FoM.py用于精度评价,可以计算出结果的FoM,UA和PA。
assessment_FoM.py is used for accuracy assessment and can calculate the Figures of Merit (FoM), User's Accuracy (UA), and Producer's Accuracy (PA).

utils .py用于存放常用的函数。
utils .py is used to store commonly used functions.

依赖库(Dependency libraries)

  • Python-3.8
  • gdal-3.4.3
  • numpy-1.24.3
  • sklearn-0.0.post10

数据规范(Data specification)

在数据文件夹中:
In the data folder: 

2015.shp和2018.shp是两个不同年份的土地利用类型试验数据;
2015.shp and 2018.shp are land use type test data for two different years; 

restrictedArea.shp是在最终模拟步骤中限制开发的区域;
restrictedArea.shp is the area where development is restricted in the final simulation step;

其他Tiff文件是用于计算总体发展概率的空间辅助变量。
Other Tiff files are spatial auxiliary variables used in calculating the overall development probability.

参考文献(Reference)

[1] Yao, Y., Liu, X., Li, X., Liu, P., Hong, Y., Zhang, Y., & Mai, K. (2017). Simulating urban land-use changes at a large scale by integrating dynamic land parcel subdivision and vector-based cellular automata. International Journal of Geographical Information Science, 31(12), 2452-2479.

[2] Zhai, Y., Yao, Y., Guan, Q., Liang, X., Li, X., Pan, Y., … & Zhou, J. (2020). Simulating urban land use change by integrating a convolutional neural network with vector-based cellular automata. International Journal of Geographical Information Science, 34(7), 1475-1499.

[3] Yao, Y., Li, L., Liang, Z., Cheng, T., Sun, Z., Luo, P., … & Ye, X. (2021). UrbanVCA: a vector-based cellular automata framework to simulate the urban land-use change at the land-parcel level. arXiv preprint arXiv:2103.08538.

Q.E.D.