Skip to content

DJI

Module for reading and managing DJI images. It allows for reading .mrk file containing RTK GPS information and extracting relevant information from it to be used in Agisoft Metashape processing.

dji2csv(data_dict, foutname, flag_utm=False, utm_zone='32N', flag_useImageCoord=False, flag_qual=[50, 16, 1], scale_factors=[1, 1, 1])

Convert DJI metadata dictionary to CSV file.

Parameters:

Name Type Description Default
data_dict Dict

Dictionary containing DJI metadata.

required
foutname str

Output CSV file name.

required
flag_utm bool

Flag to indicate UTM projection. Defaults to False.

False
utm_zone str

UTM zone. Defaults to "32N".

'32N'
flag_useImageCoord bool

Flag to use image coordinates. Defaults to False.

False
flag_qual List

Quality flags. Defaults to [50, 16, 1].

[50, 16, 1]
scale_factors List

Scale factors. Defaults to [1, 1, 1].

[1, 1, 1]

Returns:

Name Type Description
bool bool

True if the file is created successfully, False otherwise.

dji2xlsx(data_dict, foutname, flag_utm=0, utm_zone='32N', flag_qual=[50, 16, 1], scale_factors=[1, 1, 1])

Create an Excel file with both camera and log file original metadata, as well as a join file according to user choices.

Parameters:

Name Type Description Default
data_dict dict

Dictionary of the join jpg-log metadata.

required
foutname str

Output file to be created.

required
flag_utm int

Use UTM coordinates instead of log file ones. Defaults to 0.

0
utm_zone str

UTM zone. Defaults to "32N".

'32N'
flag_qual list

Flag quality. Defaults to [50, 16, 1].

[50, 16, 1]
scale_factors list

Scale factors. Defaults to [1, 1, 1].

[1, 1, 1]

Returns:

Name Type Description
bool bool

True if the file is created successfully, False otherwise.

get_dji_id_from_name(fname)

Extracts the DJI image progressive ID from the given image filename.

Parameters:

Name Type Description Default
fname str

The image filename from which to extract the DJI image ID.

required

Returns:

Name Type Description
int int

The extracted DJI image ID.

get_images(folder, image_ext)

Read image files and extract EXIF data from them.

Parameters:

Name Type Description Default
folder Union[str, Path]

Path to the folder containing the images.

required
image_ext str

Extension of the image files to read.

required

Returns:

Name Type Description
dict dict

Dictionary containing the EXIF data extracted from the images. The dictionary keys are the

dict

point IDs and the values are instances of the ExifData class.

merge_mrk_exif_data(mrk_dict, exif_dict)

Merge MRK and EXIF data dictionaries.

This function takes two dictionaries, mrk_dict and exif_dict, and returns a new dictionary with merged data. The keys of both dictionaries must match, and the output dictionary will have the same keys as the input dictionaries.

Parameters:

Name Type Description Default
mrk_dict dict

A dictionary containing MRK data.

required
exif_dict dict

A dictionary containing EXIF data.

required

Returns:

Name Type Description
dict dict

A dictionary containing merged MRK and EXIF data.

mrkread(fname)

Parse a .mrk file and return a dictionary with the data.

Parameters:

Name Type Description Default
fname Union[Path, str]

Path to the .mrk file.

required

Returns:

Name Type Description
dict dict

Dictionary containing the data parsed from the .mrk file. The dictionary keys are the

dict

point IDs and the values are instances of the MrkData class.

Raises:

Type Description
AssertionError

If the file does not exist or is not a .mrk file.

project_to_utm(epsg_from, epsg_to, data_dict, fields=['lat', 'lon'], suffix='', in_place=False)

Converts geographic coordinates (latitude, longitude) to projected UTM coordinates using the pyproj library.

Parameters:

Name Type Description Default
epsg_from int

EPSG code of the initial coordinate reference system (pyproj.CRS).

required
epsg_to int

EPSG code of the destination pyproj.CRS.

required
data_dict dict

Dictionary containing the data to be projected.

required
fields List[str]

List of two fields specifying the names of the latitude and longitude fields in the data dictionary, respectively. Default is ["lat", "lon"].

['lat', 'lon']
suffix str

Suffix to be appended to the new fields in the data dictionary. Default is "".

''
in_place bool

If True, the projection is applied in-place to the data_dict. If False, a new dictionary with the projected coordinates is returned. Default is False.

False

Returns:

Type Description
Union[dict, None]

dict or None: A new dictionary with the projected coordinates or None if in_place is True.

Raises:

Type Description
AssertionError

If epsg_from is equal to epsg_to, if fields has a length other than 3, or if any element in fields is not a string.