- 简体中文: 此页面未翻译为简体中文。
rasterconvert module¶
The RasterConverter module provides a set of functions for efficient data conversion and manipulation of raster datasets.
multiRaster_listDict(folder_path, index_list)
¶
Reads multiple raster data (.tif) from a folder and stores it in a dictionary based on specific index values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_path
|
str
|
The path to the folder containing raster data (.tif). |
required |
index_list
|
list
|
A list of indices corresponding to the raster files. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary with a specific index value as the key and a list of stored raster pixel values as the value. |
Source code in geoca/rasterconvert.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
process_raster_data(input_raster_path, output_raster_path, new_data, nodata_value)
¶
Create a single-band raster template based on the input raster, process the raster data by replacing pixel values with the new data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_raster_path
|
str
|
Path to the original raster file. |
required |
output_raster_path
|
str
|
Path to save the output raster file. |
required |
new_data
|
list
|
New data in the form of a 2D list. |
required |
nodata_value
|
num
|
NoData value in new_data. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in geoca/rasterconvert.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
raster_list(file_path)
¶
Read raster data from a file, convert NoData values to None, and convert the data into a Python list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the raster file. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
Raster data as a Python list with NoData values converted to None. |
Source code in geoca/rasterconvert.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
reorganize_multiRaster_listDict(data_dict, index_list)
¶
Reorganizes data from a list dictionary representing multiple raster data on the basis of the multiRaster_listDict function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict
|
dict
|
Resulting dictionary file generated by multiRaster_listDict function. |
required |
index_list
|
list
|
A list of indexes corresponding to the list of keys of the dictionary file in a defined order, the same as the index_list parameter of the multiRaster_listDict function. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
The first parameter is a two-dimensional indexed list with the same number of rows and columns as the original raster data, and the list element values are tuples of horizontal and vertical coordinates. The second parameter is a data dictionary with the key being the coordinate tuple (index list element value) and the value being a list of all raster image element values corresponding to the coordinates (in index_list order). |
Source code in geoca/rasterconvert.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|