eoxserver.contrib package

Submodules

eoxserver.contrib.gdal module

This module imports and initializes GDAL; i.e enables exceptions and registers all available drivers.

eoxserver.contrib.gdal.config_env(env, fail_on_override=False, reset_old=True)
eoxserver.contrib.gdal.get_extent(ds)

Gets the extent of the GDAL Dataset in the form (min-x, min-y, max-x, max-y).

eoxserver.contrib.gdal.open_with_env(path, env, shared=True)
eoxserver.contrib.gdal.set_env(env, fail_on_override=False, return_old=False)

eoxserver.contrib.gdal_array module

eoxserver.contrib.mapserver module

class eoxserver.contrib.mapserver.Class(name, mapobj=None)

Bases: classObj

class eoxserver.contrib.mapserver.Layer(name, metadata=None, type=0, mapobj=None)

Bases: MetadataMixIn, layerObj

class eoxserver.contrib.mapserver.Map(metadata=None)

Bases: MetadataMixIn, mapObj

dispatch(request)
exception eoxserver.contrib.mapserver.MapServerException(message, locator, code=None)

Bases: Exception

class eoxserver.contrib.mapserver.MetadataMixIn(metadata=None)

Bases: object

Mix-In for classes that wrap mapscript objects with associated metadata.

setMetaData(key_or_params, value=None, namespace=None)

Convenvience method to allow setting multiple metadata values with one call and optionally setting a ‘namespace’ for each entry.

class eoxserver.contrib.mapserver.Style(name, mapobj=None)

Bases: styleObj

class eoxserver.contrib.mapserver.classObj

Bases: object

class eoxserver.contrib.mapserver.colorObj

Bases: object

eoxserver.contrib.mapserver.config_env(map_obj, env, fail_on_override=False, reset_old=True)
eoxserver.contrib.mapserver.create_request(values, request_type=0)

Creates a mapserver request from

eoxserver.contrib.mapserver.dispatch(map_, request)

Wraps the OWSDispatch method. Perfoms all necessary steps for a further handling of the result.

eoxserver.contrib.mapserver.gdalconst_to_imagemode(const)

This function translates a GDAL data type constant as defined in the gdalconst module to a MapScript image mode constant.

eoxserver.contrib.mapserver.gdalconst_to_imagemode_string(const)

This function translates a GDAL data type constant as defined in the gdalconst module to a string as used in the MapServer map file to denote an image mode.

class eoxserver.contrib.mapserver.layerObj

Bases: object

class eoxserver.contrib.mapserver.mapObj

Bases: object

eoxserver.contrib.mapserver.setMetaData(obj, key_or_params, value=None, namespace=None)

Convenvience function to allow setting multiple metadata values with one call and optionally setting a ‘namespace’ for each entry.

eoxserver.contrib.mapserver.set_env(map_obj, env, fail_on_override=False, return_old=False)
eoxserver.contrib.mapserver.set_metadata(obj, key_or_params, value=None, namespace=None)

Convenvience function to allow setting multiple metadata values with one call and optionally setting a ‘namespace’ for each entry.

class eoxserver.contrib.mapserver.shapeObj

Bases: object

class eoxserver.contrib.mapserver.styleObj

Bases: object

eoxserver.contrib.ogr module

eoxserver.contrib.osr module

class eoxserver.contrib.osr.SpatialReference(raw=None, format=None)

Bases: object

Extension to the original SpatialReference class.

IsSame(other)
property proj
property srid

Convenience function that tries to get the SRID of the projection.

property swap_axes
property url
property wkt
property xml

eoxserver.contrib.vrt module

class eoxserver.contrib.vrt.VRTBuilder(size_x, size_y, num_bands=0, data_type=None, vrt_filename=None)

Bases: object

This class is a helper to easily create VRT datasets from various sources.

Parameters:
  • size_x – the pixel size of the X dimension

  • size_y – the pixel size of the Y dimension

  • num_bands – the initial number of bands; bands can be added afterwards

  • data_type – the GDT data type identifier

  • vrt_filename – a path the filename shall be stored at; if none is specified the dataset will only be kept in memory

add_band(data_type=None, options=None, nodata=None)

Add a band to the VRT Dataset.

Parameters:
  • data_type – the data type of the band to add. if omitted this is determined automatically by GDAL

  • options – a list of any string options to be supplied to the new band

add_simple_source(band_index, src, src_band, src_rect=None, dst_rect=None)

Add a new simple source to the VRT.

Parameters:
  • band_index – the band index the source shall contribute to

  • src – either a GDAL Dataset or a file path to the source dataset

  • src_band – specify which band of the source dataset shall contribute to the target VRT band

  • src_rect – a 4-tuple of integers in the form (offset-x, offset-y, size-x, size-y) or a Rect specifying the source area to contribute

  • dst_rect – a 4-tuple of integers in the form (offset-x, offset-y, size-x, size-y) or a Rect specifying the target area to contribute

copy_gcps(ds, offset=None)

Copy the GCPs from the given GDAL Dataset, optionally offsetting them

Parameters:
  • ds – a GDAL Dataset

  • offset – a 2-tuple of integers; the pixel offset to be applied to any GCP copied

copy_metadata(ds)

Copy the metadata fields and values from the given dataset.

Parameters:

ds – a GDAL Dataset

property dataset

Returns a handle to the underlying VRT GDAL Dataset.

classmethod from_dataset(ds, vrt_filename=None)

A helper function to create a VRT dataset from a given template dataset.

Parameters:

ds – a GDAL Dataset

class eoxserver.contrib.vrt.VRTBuilder2(size_x, size_y, num_bands=0, data_type=None, vrt_filename=None)

Bases: object

add_band(data_type=None, options=None, nodata=None)
add_simple_source(band_index, src, src_band, src_rect=None, dst_rect=None)

Add a new simple source to the VRT.

Parameters:
  • band_index – the band index the source shall contribute to

  • src – either a GDAL Dataset or a file path to the source dataset

  • src_band – specify which band of the source dataset shall contribute to the target VRT band

  • src_rect – a 4-tuple of integers in the form (offset-x, offset-y, size-x, size-y) or a Rect specifying the source area to contribute

  • dst_rect – a 4-tuple of integers in the form (offset-x, offset-y, size-x, size-y) or a Rect specifying the target area to contribute

build()
build_sources(sources)
set_geotransform(geotransform)
warped_gcps(gcp_dsc, resample='NearestNeighbour', order=0)
eoxserver.contrib.vrt.gdalbuildvrt(filename, paths, separate=False, nodata=None)

Builds a VRT file from the passed files using the gdalbuildvrt command and stores the resulting file under the passed filename.

eoxserver.contrib.vrt.get_vrt_driver()

Convenience function to get the VRT driver.

eoxserver.contrib.vrt.mosaic(filenames, save=None)

Creates a mosaic VRT from the specified filenames. This function always uses the highest resolution available. The VRT is stored under the save filename, when passed

eoxserver.contrib.vrt.select_bands(filename, env, band_indices, save=None)
eoxserver.contrib.vrt.sign_abs(x)
eoxserver.contrib.vrt.stack_bands(filenames, env, save=None)
eoxserver.contrib.vrt.with_extent(filename, extent, save=None)

Create a VRT and override the underlying files geolocation

eoxserver.contrib.vsi module

This module provides Python file-object like access to VSI files.

class eoxserver.contrib.vsi.TemporaryVSIFile(filename, mode='r')

Bases: VSIFile

Subclass of VSIFile, that automatically deletes the physical file upon deletion.

close()

Close the file. This also deletes it.

classmethod from_buffer(buf, mode='wb', filename=None)

Creates a TemporaryVSIFile from a string.

Parameters:
  • buf – the supplied string

  • mode – the file opening mode

  • filename – the optional filename the file shall be stored under; by default this is an in-memory location

class eoxserver.contrib.vsi.VSIFile(filename, mode='r')

Bases: object

File-like object interface for VSI file API.

Parameters:
  • filename – the path to the file; this might also be any VSI special path like “/vsicurl/…” or “/vsizip/…”. See the GDAL documentation and manuals for reference.

  • mode – the file opening mode

close()

Close the file.

property closed

Return a boolean value to indicate whether or not the file is already closed.

flush()
isatty()

Never a TTY

property name

Returns the filename referenced by this file

next()

Satisfaction of the iterator protocol. Return the next line in the file or raise StopIteration.

read(size=4294967295)

Read from the file. If no size is specified, read until the end of the file.

Parameters:

size – the number of bytes to be read

Returns:

the bytes read as a string

readline(length=None, windowsize=1024)

Read a single line from the file and return it.

Parameters:
  • length – the maximum number of bytes to read to look for a whole line.

  • windowsize – the windowsize to search for a newline character.

readlines(sizehint=0)
Read the remainder of the file (or up to sizehint bytes) and return

the lines.

Parameters:

sizehint – the number of bytes to scan for lines.

Returns:

the lines

Return type:

list of strings

seek(offset, whence=0)

Set the new read/write offset in the file.

Parameters:
  • offset – the new offset

  • whence – how the offset shall be interpreted; possible options are os.SEEK_SET, os.SEEK_CUR and os.SEEK_END

property size

Return the size of the file in bytes

tell()

Return the current read/write offset of the file.

Returns:

an integer offset

truncate(size=None)
Truncates the file to the given size or to the size until the current

position.

Parameters:

size – the new size of the file.

write(data)

Write the buffer data to the file.

Parameters:

data – the string buffer to be written

class eoxserver.contrib.vsi.VSIFileResponse(*args, as_attachment=False, filename='', **kwargs)

Bases: StreamingHttpResponse

Subclass of StreamingHttpResponse, a replacement for Django’s FileResponse which does not work for VSIFiles in Django v3.2.15

block_size = 4096
set_headers(filelike)
eoxserver.contrib.vsi.join(first, *paths)

Joins the given VSI path specifiers. Similar to os.path.join() but takes care of the VSI-specific handles such as vsicurl, vsizip, etc.

eoxserver.contrib.vsi.open(filename, mode='r')

A function mimicking the builtin function open but returning a VSIFile instead.

Parameters:
  • filename

    the path to the file; this might also be any VSI special path like “/vsicurl/…” or “/vsizip/…”. See the GDAL documentation for reference.

  • mode – the file opening mode

Returns:

a VSIFile

Module contents

This package provides a common interface to contributing third party libraries that need some special care when importing or are provided with additional features.