Layer Builder
ExtractFeatureInfo(layer_pattern, feature_type, filter='', formula='', default_value={})
¶
Dataclass that store features extraction informations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_pattern
|
str
|
Pattern to match a layer file. |
required |
filter
|
str
|
Filter expression to filter layer. It shall be in QgsExpression format. |
''
|
formula
|
str
|
Expression to compute buffer distance parameter. It shall be in QgsExpression format. |
''
|
feature_type
|
str
|
Type of feature that will be extracted. i.e 'building', 'road', etc. |
required |
default_value
|
typing.Dict[str, float]
|
Dict of str-values that map field used in formula with their default values if the feature got NULL. |
{}
|
Source code in niva/core/layer_builder/csv_parse.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
FeatureExtractor(extract_info, roi, **kwargs)
¶
Bases: niva.core.mixins.QgsLogicMixin
Manage extraction of features from a layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extract_info
|
niva.core.layer_builder.csv_parse.ExtractFeatureInfo
|
All information to filter & extract features. |
required |
roi
|
qgis.core.QgsVectorLayer
|
Region of interest. |
required |
Source code in niva/core/layer_builder/csv_parse.py
123 124 125 126 127 | |
fill_null(layer)
¶
Replace NULL values for field needed in buffer distance calculation by median of values for each combination of fields used in filter expression. If all values are NULL use extract informations default value for field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
qgis.core.QgsVectorLayer
|
Layer where to fill NULL values. |
required |
Source code in niva/core/layer_builder/csv_parse.py
129 130 131 132 133 134 135 136 137 138 139 | |
extract_data(path)
¶
Extract features from layer at path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path of layer to extract features from. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QgsVectorLayer |
qgis.core.QgsVectorLayer
|
|
Source code in niva/core/layer_builder/csv_parse.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
LayerBuilder(csv_path, roi, **kwargs)
¶
Bases: niva.core.mixins.QgsLogicMixin
Mange layer creation by extracting features from a csv that detail layers to parse and features transformations and a region of interest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
str
|
Path to CSV file. |
required |
roi
|
qgis.core.QgsVectorLayer
|
Region Of Interest. |
required |
Source code in niva/core/layer_builder/csv_parse.py
285 286 287 288 289 290 | |
parse_csv(csv)
¶
Parse a CSV file and build list of ExtractFeatureInfo at self.extract_infos.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv
|
str
|
Path to CSV file to parse. |
required |
Returns:
| Type | Description |
|---|---|
typing.List[niva.core.layer_builder.csv_parse.ExtractFeatureInfo]
|
List[ExtractFeatureInfo]: - List of ExtractFeatureInfo. |
Source code in niva/core/layer_builder/csv_parse.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
update(data, feature_type)
¶
Update self.layer with features in data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
qgis.core.QgsVectorLayer
|
Layer with extracted features. |
required |
feature_type
|
str
|
Feature type to write in self.layer. |
required |
Source code in niva/core/layer_builder/csv_parse.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
run_extraction(extrac_info, folder)
¶
Extract data from layers in folder using extrac_info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extrac_info
|
``ExtractFeatureInfo``
|
Informations of extraction. |
required |
folder
|
``str``
|
Folder to recursively match layers. |
required |
Source code in niva/core/layer_builder/csv_parse.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
build(folder)
¶
Launch all extractions to build layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
``str``
|
Folder to match layers |
required |
Source code in niva/core/layer_builder/csv_parse.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |