geosoft.gxpy.dap_client submodule

Geosoft dap server handling.

Classes:
DapClient Geosoft dap client
DataType data type
GridExtractFormat return format for extracting a grid
ExtractProgressStatus progress
DataExtract data extraction
BoundingBox bounding box
DataCard data information
SearchFilter search filter
ResultFilter result filter
SearchParameters search parameters

Regression tests provide usage examples: Tests

New in version 9.4.

class BoundingBox(minx=-180, miny=-90, minz=0, maxx=180, maxy=90, maxz=0, coordinate_system='WGS 84')

Bases: object

Bounding box instance.

Parameters:
  • minxMinX
  • minyMinY
  • minzMinZ
  • maxxMaxX
  • maxyMaxY
  • maxzMaxZ
  • coordinate_systemCoordinateSystem any supported coordinate system representation. Default is “WGS 84”.
  • cs_as_xml – True to force the coordinate_system to be xml.
class DapClient(url='http://dap.geosoft.com/', get_catalog=False)

Bases: collections.abc.Sequence

DapClient class to communicate with a Geosoft DAP server.

Parameters:
  • url – url of the server, default is ‘http://dap.geosoft.com/
  • get_catalogTrue to get the server catalog. If False (the default) call method catalog() to get the retrieve the catalog from the server. The catalog is cached as part of the instance.

New in version 9.4.

catalog(search_parameters=None, refresh=False)

Return a filtered catalog list.

Parameters:
  • search_parameters – search filter, instance of SearchParameters
  • refreshTrue to force a refresh, otherwise cached catalog is returned
Returns:

list of server catalog entries as DataCard instances

New in version 9.4.

configuration

Return service configuration info.

See http://dap.geosoft.com/REST/service/help/operations/GetConfiguration

New in version 9.4.

datacard_from_id(id)

Return the DataCard instance based on the dataset ID #

Parameters:id – dataset id
Returns:DataCard instance

New in version 9.4.

fetch_data(datacard, filename=None, extent=None, resolution=None, max_seconds=3600, progress=None, cadence=5)

Fetch data from the server.

Parameters:
  • datacardDataCard instance, or a dataset description (hierarchy, title) or just title.
  • filename – file name in which to plase data, default is a temporary geosoft gris file.
  • extentgeosoft.gxpy.geometry.Point2 instance, or a BoundingBox instance
  • resolution – data resolution in the length units of the extent coordinate system
  • max_seconds – maximum number of seconds to wait for the process to finish
  • progress – callback that can report progress, for example progress=print will print to the console
  • cadence – time in seconds between checking on server preparation status.
Returns:

data file name, which may be a temporry file. Temporary files will only persist during the live of the current context.

import geosoft.gxpy.gx as gx
import geosoft.gxpy.dap_client as gxdap:

gx.GXpy()

with gxdap.DapClient() as dap:

    # some point data
    dataset = dap['Kimberlite Indicator Mineral Grain Chemistry']
    extent = gxgeo.Point2(((-112, 65), (-111, 65.5)), coordinate_system='NAD83')
    data_file = dap.fetch_data(dataset, extent=extent, resolution=0, progress=print)

New in version 9.4.

fetch_image(datacard, extent=None, resolution=None)
get(what)

GET information from the server.

Parameters:what – string of what to get. for example “dataset/properties/265” retrieves the dataset properties for dataset 265. See http://dap.geosoft.com/REST/dataset/help for a list of the kinds of things you can get about a dataset.
Returns:requested info as a dict.
post(what)

POST information from the server.

Parameters:what – string of what to post.
Returns:returned info as a dict.
url

Server url.

exception DapClientException(message)

Bases: geosoft.GXRuntimeError

Exceptions from geosoft.gxpy.dap.

class DataCard(dap=None, id=None, title=None, type=0, hierarchy=None, stylesheet=None, extents=None, has_original=False)

Bases: geosoft.gxpy.geometry.Geometry

Single dataset information instance.

Parameters:
  • dapDapClient instance
  • idId unique dataset identifier property
  • titleTitle property
  • typeType dataset type, one of DataType values.
  • hierarchyHierarchy location in the catalog hierarchy
  • stylesheetStylesheet metadata style sheet
  • extentsExtents is a BoundingBox instance
  • has_originalHasOriginal True if the original data is available

New in version 9.4.

dap_client

DapClient instance for this dataset, may be None if card is not yet associated with a server.

New in version 9.4.

disclaimer

Disclaimer: http://dap.geosoft.com/REST/dataset/help/operations/GetDisclaimer

New in version 9.4.

document_properties

Properties of the dataset as a document.

http://dap.geosoft.com/REST/dataset/help/operations/GetDocumentProperties

New in version 9.4.

edition

Edition: http://dap.geosoft.com/REST/dataset/help/operations/GetEdition

New in version 9.4.

extent

Object extent as a Point2 instance.

grid_properties

Grid data properties, None if not a grid dataset.

http://dap.geosoft.com/REST/dataset/help/operations/GetGridProperties

New in version 9.4.

info

Dataset info: http://dap.geosoft.com/REST/dataset/help/operations/GetDatasetById

New in version 9.4.

map_properties

Map properties, None if not a map.

http://dap.geosoft.com/REST/dataset/help/operations/GetMapProperties

New in version 9.4.

metadata

Metadata: http://dap.geosoft.com/REST/dataset/help/operations/GetMetadata

New in version 9.4.

permission

Permission: http://dap.geosoft.com/REST/dataset/help/operations/GetPermission

New in version 9.4.

point_properties

Point properties, None if not a point (hxyz) dataset.

http://dap.geosoft.com/REST/dataset/help/operations/GetHXYZProperties

New in version 9.4.

spatial_properties

Spatial properties: http://dap.geosoft.com/REST/dataset/help/operations/GetProperties

New in version 9.4.

voxel_properties

Voxel properties, None if not a voxel.

http://dap.geosoft.com/REST/dataset/help/operations/GetVoxelProperties

New in version 9.4.

class DataExtract(filename, extents=None, resolution=0, format=0)

Bases: object

Data extraction instance.

Parameters:
  • filename – name of the data file
  • extents – data extent as a BoundingBox or geosoft.gxpy.geopmetry.Point2 instance
  • resolution – desired resolution in the distance units of the extents coordinate system
  • format – one of the extraction formats for the data type, default is the first format.

New in version 9.4.

class DataType

Bases: enum.Enum

Supported data types

ArcGIS = 9
Database = 4
Document = 5
Drillhole = 14
GMSYS2D = 22
GMSYS3D = 18
Generic = 7
GeosoftOffline = 24
Geostring = 17
Geosurface = 21
Grid = 1
GridSection = 12
ImageServer = 10
Map = 0
NoData = 15
PDF = 20
Picture = 2
PictureSection = 11
Point = 3
ProjectZip = 13
SPF = 6
ThreeDV = 16
VOXI = 19
VectorVoxel = 23
Voxel = 8
class ExtractProgressStatus

Bases: enum.Enum

An enumeration.

Cancelled = 4
Complete = 3
Compress = 2
Extract = 1
Failed = 5
Prepare = 0
class GridExtractFormat

Bases: enum.Enum

An enumeration.

BIL = 3
ERMapper = 13
ESRIBinaryRaster = 2
GXFCompressed = 6
GXFText = 5
Geopak = 4
GeosoftCompressed = 0
GeosoftUncompressed = 1
ODDFPC = 7
ODDFUnix = 8
SurferV6 = 9
SurferV7 = 10
USGSPC = 11
USGSUnix = 12
class ResultFilter(path=None, depth=2147483647, start_index=0, max_results=0, valid_path=False)

Bases: object

Results filter instance.

Parameters:
  • path – to this location in the hierarchy
  • depth – to this depth in the hierarchy, default no depth limit
  • start_index – start index in the list
  • max_results – maximum results to include

New in version 9.4.

class SearchFilter(free_text_query=None, structured_metadata_query=None, extents=None, entirely_within=False, version=1)

Bases: object

Search filter instance.

Parameters:
  • free_text_query – title/keyword search filter
  • structured_metadata_query
  • extentsBoundingBox instance
  • entirely_withinTrue for completely enclosed data, False for intersecting data.
  • version – minimum version, default is 1.

New in version 9.4.

class SearchParameters(search_filter=None, result_filter=None)

Bases: object

Search parameter instance, defined by a SearchFilter and a ResultFilter

Parameters:

New in version 9.4.