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
47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
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
134 135 136 137 | |
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
139 140 141 142 143 144 145 146 147 148 149 | |
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
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 274 275 276 277 278 279 280 281 282 | |
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
294 295 296 297 298 299 | |
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
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
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
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
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
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
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
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |