c_data_type_handler
¶
Classes:
-
CIntegerDataTypeInfo–Class to hold information about C integer data types.
-
MinimumCDataTypeHandler–
CIntegerDataTypeInfo
dataclass
¶
CIntegerDataTypeInfo(
gdal_data_type_string: str,
numpy_data_type_string: str,
bits: int,
signed: bool,
)
Class to hold information about C integer data types.
MinimumCDataTypeHandler
¶
Methods:
-
check_if_user_requested_data_type_deviates–Checks if the user defined minimum gdal data type deviates from the automatically determined minimum gdal data type. Raises a warning if the two data types differ.
-
get_gdal_constant_from_string–This function converts a gdal data type string to the corresponding gdal constant that represents the data type.
-
get_valid_gdal_data_type_as_constant–This Function determines the minimum required data type to store all numbers provided list_of_numbers in the same data type.
-
get_valid_gdal_data_type_as_string–This Function determines the minimum required data type to store all numbers provided list_of_numbers in the same data type.
check_if_user_requested_data_type_deviates
classmethod
¶
check_if_user_requested_data_type_deviates(
user_defined_minimum_gdal_type: geokit_c_data_types_literal
| None,
automatically_determined_minimum_gdal_type: gdal_c_raster_data_types_literal,
)
Checks if the user defined minimum gdal data type deviates from the automatically determined minimum gdal data type. Raises a warning if the two data types differ.
Parameters:
-
(user_defined_minimum_gdal_type¶geokit_c_data_types_literal | None) –The user defined minimum gdal data type.
-
(automatically_determined_minimum_gdal_type¶gdal_c_raster_data_types_literal) –The automatically determined minimum gdal data type.
Source code in geokit/c_data_type_handler.py
get_gdal_constant_from_string
staticmethod
¶
get_gdal_constant_from_string(input_string: str) -> int
This function converts a gdal data type string to the corresponding gdal constant that represents the data type.
Parameters:
-
(input_string¶str) –String that should be converted to gdal constant.
Returns:
-
int–Integer representing the gdal data type. This can be passed to gdal functions that require a data type constant.
Source code in geokit/c_data_type_handler.py
get_valid_gdal_data_type_as_constant
classmethod
¶
get_valid_gdal_data_type_as_constant(
list_of_numbers: list[
float
| int
| integer
| floating
| complexfloating
| bool
| bool_
],
minimum_gdal_type_list: list[
geokit_c_data_types_literal
]
| None = None,
user_defined_minimum_gdal_type: geokit_c_data_types_literal
| None = None,
) -> int
This Function determines the minimum required data type to store all numbers provided list_of_numbers in the same data type.
Additionally the user can provide a list of minimum required data types that need to be considered as well as a user defined minimum data type. The data types in the gdal_type_list can be provided to get at least the data type provided in the list or a bigger one if needed. The user defined minimum data type is only used to warn the user if the automatically determined data type differs from the user defined one. This is useful identify a potential misconfiguration.
Parameters:
-
(list_of_numbers¶list[float | int | integer | floating | complexfloating | bool | bool_]) –A list of numbers for which the minimum required gdal data type should be determined.
-
(minimum_gdal_type_list¶list[geokit_c_data_types_literal] | None, default:None) –This is a list of the minimum required GDAL data types that need to be considered. If a larger data type is required, the input is ignored. If no data types are provided, they are automatically determined from the list of numbers. by default None
-
(user_defined_minimum_gdal_type¶geokit_c_data_types_literal | None, default:None) –The data type that the user expects. If a different data type is determined automatically a warning is raised. If set to None no warning is raised., by default None
Returns:
-
int–An integer that represents represents a C datatype that must be passed to certain GDAL functions. To convert it to a human readable string use the function get_gdal_constant_from_string or use the get_valid_gdal_data_type_as_string instead of this function.
Source code in geokit/c_data_type_handler.py
get_valid_gdal_data_type_as_string
classmethod
¶
get_valid_gdal_data_type_as_string(
list_of_numbers: list[
float
| int
| integer
| floating
| complexfloating
| bool
| bool_
],
minimum_gdal_type_list: list[
geokit_c_data_types_literal
]
| None = None,
user_defined_minimum_gdal_type: geokit_c_data_types_literal
| None = None,
) -> str
This Function determines the minimum required data type to store all numbers provided list_of_numbers in the same data type.
Additionally the user can provide a list of minimum required data types that need to be considered as well as a user defined minimum data type. The data types in the gdal_type_list can be provided to get at least the data type provided in the list or a bigger one if needed. The user defined minimum data type is only used to warn the user if the automatically determined data type differs from the user defined one. This is useful identify a potential misconfiguration.
Parameters:
-
(list_of_numbers¶list[float | int | integer | floating | complexfloating | bool | bool_]) –A list of numbers for which the minimum required gdal data type should be determined.
-
(minimum_gdal_type_list¶list[geokit_c_data_types_literal] | None, default:None) –This is a list of the minimum required GDAL data types that need to be considered. If a larger data type is required, the input is ignored. If no data types are provided, they are automatically determined from the list of numbers. by default None
-
(user_defined_minimum_gdal_type¶geokit_c_data_types_literal | None, default:None) –The data type that the user expects. If a different data type is determined automatically a warning is raised. If set to None no warning is raised., by default None
Returns:
-
str–A a string of the number data type that can be used in gdal to store all numbers provided in list_of_numbers.
Source code in geokit/c_data_type_handler.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |