source: TI02-CSML/trunk/newparser/ioDemo.py @ 835

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/newparser/ioDemo.py@835
Revision 835, 1.3 KB checked in by domlowe, 14 years ago (diff)

Added getDatasetObj to return direct reference to parser obj

Line 
1#!/usr/bin/env python
2
3#ioDemo.py
4#This document contains example calls to Parser csml io interface
5#Dominic Lowe 25th April 2006
6
7#import csml io module:
8from csmlio import *
9
10#instantiate CSMLinterface object:
11csml =CSMLinterface()
12
13#parse in CSML document:
14csml.parse('example.xml')
15
16#return CSML document as string:
17strCSML=csml.getCSMLasString()
18#print strCSML
19
20#get list of features by name (gml:id):
21featureList = csml.getFeatureList()
22print featureList
23
24#get type of feature (supply feature name)
25
26
27#get types of all features
28for i in range(0, len(featureList)):
29    featureType = csml.getFeatureType(featureList[i])
30    print featureType
31
32#get type of single feature
33#eg featureType=csml.getFeatureType('feat04')
34
35
36#get gml description (long name) of feature
37fdesc= csml.getFeatureDescription('feat04')
38print fdesc
39
40#get list of file extracts by gml:id
41fileExtractList=csml.getFileExtractList()
42print fileExtractList
43
44
45
46#get data from file extract (supply name):
47#currently returns a list, but may need to consider masked arrays
48#dataArray = csml.getData(fileExtractID)
49dataArray = csml.getData('feat04times')
50print dataArray
51
52
53#Alternatively you can call getDatasetObj and then directly
54#interrogate the Parser.Dataset object returned thus bypassing the csmlio wrapper functions
55dataset = csml.getDatasetObj()
56print dir(dataset)
57
Note: See TracBrowser for help on using the repository browser.