fiftyone.utils.geotiff#

GeoTIFF utilities.

Copyright 2017-2025, Voxel51, Inc.

Functions:

get_geolocation(image_path)

Retrieves the geolocation information from the given GeoTIFF image.

Classes:

GeoTIFFDatasetImporter([dataset_dir, ...])

Importer for a directory of GeoTIFF images with geolocation data.

fiftyone.utils.geotiff.get_geolocation(image_path)#

Retrieves the geolocation information from the given GeoTIFF image.

The returned fiftyone.core.labels.GeoLocation will contain the lon/lat coordinates of the center of the image in its point attribute and the coordinates of its corners (clockwise, starting from the top-left) in its polygon attribute.

Parameters:

image_path – the path to the GeoTIFF image

Returns:

a fiftyone.core.labels.GeoLocation

class fiftyone.utils.geotiff.GeoTIFFDatasetImporter(dataset_dir=None, image_path=None, recursive=True, compute_metadata=False, shuffle=False, seed=None, max_samples=None)#

Bases: LabeledImageDatasetImporter, ImportPathsMixin

Importer for a directory of GeoTIFF images with geolocation data.

See this page for format details.

Parameters:
  • dataset_dir (None) – the dataset directory. If omitted, image_path must be provided

  • image_path (None) –

    an optional parameter that enables explicit control over the location of the GeoTIFF images. Can be any of the following:

    • a list of paths to GeoTIFF images. In this case, dataset_dir has no effect

    • a glob pattern like "*.tif" specifying the location of the images in dataset_dir

    • an absolute glob pattern of GeoTIFF images. In this case, dataset_dir has no effect

  • recursive (True) – whether to recursively traverse subdirectories. Not applicable when image_path is provided

  • compute_metadata (False) – whether to produce fiftyone.core.metadata.ImageMetadata instances for each image when importing

  • shuffle (False) – whether to randomly shuffle the order in which the samples are imported

  • seed (None) – a random seed to use when shuffling

  • max_samples (None) – a maximum number of samples to import. By default, all samples are imported

Attributes:

has_image_metadata

Whether this importer produces fiftyone.core.metadata.ImageMetadata instances for each image.

has_dataset_info

Whether this importer produces a dataset info dictionary.

label_cls

The fiftyone.core.labels.Label class(es) returned by this importer.

Methods:

setup()

Performs any necessary setup before importing the first sample in the dataset.

close(*args)

Performs any necessary actions after the last sample has been imported.

get_dataset_info()

Returns the dataset info for the dataset.

property has_image_metadata#

Whether this importer produces fiftyone.core.metadata.ImageMetadata instances for each image.

property has_dataset_info#

Whether this importer produces a dataset info dictionary.

property label_cls#

The fiftyone.core.labels.Label class(es) returned by this importer.

This can be any of the following:

  • a fiftyone.core.labels.Label class. In this case, the importer is guaranteed to return labels of this type

  • a list or tuple of fiftyone.core.labels.Label classes. In this case, the importer can produce a single label field of any of these types

  • a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the importer will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labels

  • None. In this case, the importer makes no guarantees about the labels that it may return

setup()#

Performs any necessary setup before importing the first sample in the dataset.

This method is called when the importer’s context manager interface is entered, DatasetImporter.__enter__().

close(*args)#

Performs any necessary actions after the last sample has been imported.

This method is called when the importer’s context manager interface is exited, DatasetImporter.__exit__().

Parameters:

*args – the arguments to DatasetImporter.__exit__()

get_dataset_info()#

Returns the dataset info for the dataset.

By convention, this method should be called after all samples in the dataset have been imported.

Returns:

a dict of dataset info