Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created June 1, 2016 15:32
Show Gist options
  • Save lukecampbell/b97f1731ae05b1514fc36e830988036f to your computer and use it in GitHub Desktop.
Save lukecampbell/b97f1731ae05b1514fc36e830988036f to your computer and use it in GitHub Desktop.
ISO Xpaths
class ISOPaths(object):
identifier = "./gmd:fileIdentifier/gco:CharacterString/text()[1]"
title = "./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString/text()[1]"
abstract = "./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString/text()[1]"
thesaurus_name = "./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString/text()"
# A lot of gmd:MD_DataIdentification here. Consider traversing from this element
# Temporal Extents
start_time = "./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition/text()"
end_time = "./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition/text()"
geo_extents = "./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:%s/gco:Decimal/text()[1]"
# Geospatial Bounding Box
west_longitude = geo_extents % "westBoundLongitude"
south_latitude = geo_extents % "southBoundLatitude"
east_longitude = geo_extents % "eastBoundLongitude"
north_latitude = geo_extents % "northBoundLatitude"
# GLOS Specific
glos_categories = './gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords[gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString="GLOS Categories"]/gmd:keyword/gco:CharacterString/text()'
# keywords
kw_xpath = './gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords[gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString!="GLOS Categories"]/gmd:keyword/gco:CharacterString/text()'
# BWA: there are many different ways the online resources can be represented
online_resources = "./gmd:distributionInfo/gmd:MD_Distribution//gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource"
thumbnail = '/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:graphicOverview/gmd:MD_BrowseGraphic[gmd:fileDescription/gco:CharacterString="thumbnail"]/gmd:fileName/gco:CharacterString/text()'
# parameters
parameters = './gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords[gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString="Variables"]/gmd:keyword/gco:CharacterString/text()'
# protocols
geojson_url = './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:protocol/gco:CharacterString="GeoJSON"]/gmd:linkage/gmd:URL/text()'
service_wms_url = "./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:containsOperations/srv:SV_OperationMetadata[srv:operationName/gco:CharacterString='GetCapabilities']/srv:connectPoint/gmd:CI_OnlineResource/gmd:linkage/gmd:URL/text()"
online_resource_wms = "./gmd:distributionInfo/gmd:MD_Distribution/gmd:distributor/gmd:MD_Distributor/gmd:distributorTransferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:protocol/gco:CharacterString='OGC:WMS-1.3.0-http-get-capabilities']/gmd:linkage/gmd:URL/text()"
info_url = './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:name/gco:CharacterString="Info URL"]/gmd:linkage/gmd:URL/text()'
links = './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:protocol/gco:CharacterString="WWW:LINK-1.0-http--link"]'
pdfs = './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:protocol/gco:CharacterString="application/pdf"]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment