import_data package¶
handle_irrigation module¶
-
class
geodatafarm.import_data.handle_irrigation.
IrrigationHandler
(parent_widget)¶ Bases:
object
A widget that enables the possibility to insert data from a text file into a shapefile
-
create_grid_year
()¶ Creates a 2x2 grid over all fields
-
get_grid_data
()¶ Function that loops though all irrigation operations during the selected year. It adds the precipitation amount to each 2x2 cell that the operation “covers”.
-
run
()¶
-
handle_text_data module¶
-
class
geodatafarm.import_data.handle_text_data.
InputTextHandler
(parent_widget, data_type, columns=None)¶ Bases:
object
A widget that enables the possibility to insert data from a text file into a postgres database. :param parent_widget: :type parent_widget: GeoDataFarm :param data_type: the name of the schema to add the data to :type data_type: str :param columns: list of str (the name) which columns to create a special
request for the user to specify data/columns
-
add_to_param_list
()¶ Adds the selected columns to the list of fields that should be treated as “special” in the database both to work as a parameter that could be evaluated and as a layer that is added to the canvas
-
change_col_type
()¶ Updates the values (in self.col_types) of the data types for each column in the data set
-
change_sep
()¶ Change the separator and reload the column list
-
close
()¶ Disconnects buttons and closes the widget
-
define_separator
()¶ Define the file encoding and the separator of the file
-
determine_column_type
()¶ A function that retrieves the types of the columns from the .csv file and sets col_types as a list where with 0=int, 1=float, 2=char
-
finish
(result, values)¶ Checks that all data is uploaded to the postgres database and adds the data to the canvas and closes the widget
- Parameters
result (object) – The result object
values (list) – list with [bool, bool, int]
-
open_input_file
()¶ Open the file dialog and let the user choose which file that should be inserted. In the end of this function the function define_separator, set_sep_radio_but and set_column_list are being called.
-
prepare_last_choices
()¶ A function that prepares the last parts of the widget with the data to be inserted into the database
-
remove_from_param_list
()¶ Removes the selected columns from the list of fields that should be treated as “special” in the database
-
run
()¶ Presents the sub widget ImportTextDialog and connects the different buttons to their function
-
set_column_list
()¶ A function that retrieves the name of the columns from the text file and fills the TWColumnName list with the name, first value and data type
-
set_sep_radio_but
()¶ Sets the radioButton indicating the separator of the file
-
show_abbreviations
()¶ Shows a messageBox with the time abbreviations
-
trigger_insection
()¶ Preparing the data, by setting the correct type (including the date and time format), creating a shp file and finally ensure that the coordinates is in EPSG:4326
-
-
geodatafarm.import_data.handle_text_data.
insert_data_to_database
(task, db, params)¶ Walks though the text files and adds data to the database :param task: :type task: QgsTask :param db: :type db: object :param params: :type params: dict
- Returns
if no error: [bool, bool, int, str] else: [False, e, traceback.format_exc()]
- Return type
list
handle_input_shp_data module¶
-
class
geodatafarm.import_data.handle_input_shp_data.
InputShpHandler
(parent_widget, schema, spec_columns)¶ Bases:
object
A widget that enables the possibility to insert data from a text file into a shapefile
-
add_to_param_list
()¶ Adds the selected columns to the list of fields that should be treated as “special” in the database both to work as a parameter that could be evaluated and as a layer that is added to the canvas
-
create_tbl
(date_dict)¶ Creates a “temp” table in the database
- Returns
If works – [True]
else – return [False, e, traceback.format_exc()]
-
get_columns_names
()¶ A function that retrieves the name of the columns from the .csv file and returns a list with name
-
get_shp_data
()¶ Read data from the shp file
- Returns
if works – [True, shapes, fields, data_as_points]
else – [False, e, traceback.format_exc()]
-
import_data
(task, date_dict)¶
-
open_input_file
()¶ Open the file dialog and let the user choose which file that should be inserted. In the end of this function the function define_separator, set_sep_radio_but and set_column_list are being called.
-
prepare_data_to_be_inserted
()¶ A function that prepares the last parts of the widget with the data to be inserted into the shapefile, determining date and time columns
-
prepare_shp_file
()¶ Preparing the data before adding it to a QgsTask. and ensure that the coordinates is in EPSG:4326 :return:
-
remove_from_param_list
()¶ Removes the selected columns from the list of fields that should be treated as “special” in the database
-
reset_input_handler_widget
()¶ Resets the input handler widget :return:
-
run
()¶ Presents the sub widget HandleInput and connects the different buttons to their function
-
show_data
(result, values)¶ Checks that all data is uploaded to the postgres database and adds the data to the canvas and closes the widget
- Parameters
result (object) – The result object
values (list) – list with [bool, bool, int]
-
-
geodatafarm.import_data.handle_input_shp_data.
q_info
()¶ information(QWidget, str, str, buttons: Union[QMessageBox.StandardButtons, QMessageBox.StandardButton] = QMessageBox.Ok, defaultButton: QMessageBox.StandardButton = QMessageBox.NoButton) -> QMessageBox.StandardButton
handle_raster module¶
-
class
geodatafarm.import_data.handle_raster.
ImportRaster
(parent, date_dialog, field_dialog, schema)¶ Bases:
object
With this module the user can add Raster data
- Parameters
parent (GeoDataFarm) –
-
check_date
()¶ Checks that the user have filled in a manual date
- Returns
- Return type
bool
-
check_file
()¶ Tries to open the file
- Returns
- Return type
bool
-
import_to_db
(task)¶ Imports the shapefile with a ogr2ogr command in a shell script
- Parameters
task (QgsTask) –
- Returns
- Return type
bool
-
open_input_file
()¶ Open the file dialog and let the user choose which file that should be inserted. In the end of this function the function define_separator, set_sep_radio_but and set_column_list are being called.
-
run
()¶ Check that a date is filled in, open the file explorer, preforms some tests that the data is ok, import it to the database, renames and runs some sql commands
-
run_import_command
()¶ Adds the polygonize script to a QgsTask
-
run_sql_commands
(result, values)¶ Changes the names of some columns and change the srid to 4326, adds the column pos as the centroid of the polygon
-
task_finished
(context, successful, results)¶ Function that is called after polygonize is complete, starts the next task with importing the data to the database,
- Parameters
context (QgsProcessingContext) –
successful (bool) –
results (Unused) –
save_fertilizing_data module¶
-
class
geodatafarm.import_data.save_fertilizing_data.
SaveFertilizing
(parent)¶ Bases:
object
A class for storing plant data :param parent: :type parent: GeoDataFarm
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
run_file_import
()¶ The function loads the correct import dialog for files
-
save_manual_data
()¶ Saves the manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the planting tab
-
save_harrowing_data module¶
-
class
geodatafarm.import_data.save_harrowing_data.
SaveHarrowing
(parent)¶ Bases:
object
A class for storing harrowing data
- Parameters
parent (GeoDataFarm) –
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
save_manual_data
()¶ Saves the manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the harrowing tab
save_harvest_data module¶
-
class
geodatafarm.import_data.save_harvest_data.
SaveHarvesting
(parent)¶ Bases:
object
A class for storing harvesting data :param parent: :type parent: GeoDataFarm
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
run_file_import
()¶ The function loads the correct import dialog for files
-
save_manual_data
()¶ Saves the manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the planting tab
-
save_other_data module¶
-
class
geodatafarm.import_data.save_other_data.
SaveOther
(parent)¶ Bases:
object
A class for storing other data
- Parameters
parent (GeoDataFarm) –
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
save_manual_data
()¶ Saves manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the planting tab
save_planting_data module¶
-
class
geodatafarm.import_data.save_planting_data.
SavePlanting
(parent)¶ Bases:
object
A class for storing plant data
- Parameters
parent (GeoDataFarm) –
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
run_file_import
()¶ The function loads the correct import dialog for files
-
save_manual_data
()¶ Saves the manual data
-
set_widget_connections
()¶ A simple function that sets the buttons on the planting tab
save_plowing_data module¶
-
class
geodatafarm.import_data.save_plowing_data.
SavePlowing
(parent)¶ Bases:
object
A class for storing plowing data
- Parameters
parent (GeoDataFarm) –
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
save_manual_data
()¶ Saves manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the plowing tab
save_soil_data module¶
-
class
geodatafarm.import_data.save_soil_data.
SaveSoil
(parent)¶ Bases:
object
A class for storing spraying data
- Parameters
parent (GeoDataFarm) –
-
check_input
()¶ Some simple checks that ensure that the basic data is filled in.
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
run_file_import
()¶ The function loads the correct import dialog for files
-
save_manual_data
()¶ Saves the manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the planting tab
save_spraying_data module¶
-
class
geodatafarm.import_data.save_spraying_data.
SaveSpraying
(parent)¶ Bases:
object
A class for storing spraying data
- Parameters
parent (GeoDataFarm) –
-
check_input
(variety_check=True)¶ Some simple checks that ensure that the basic data is filled in.
- Parameters
variety_check (bool) –
- Returns
- Return type
bool
-
reset_widget
()¶ Resets the widget to the default values
-
run_file_import
()¶ The function loads the correct import dialog for files
-
save_manual_data
()¶ Saves the manual data.
-
set_widget_connections
()¶ A simple function that sets the buttons on the planting tab