Skip to content

Instantly share code, notes, and snippets.

@tomkralidis
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save tomkralidis/be69d2e24ac64619e726 to your computer and use it in GitHub Desktop.

Select an option

Save tomkralidis/be69d2e24ac64619e726 to your computer and use it in GitHub Desktop.
Download CSW metadata
import sys
from owslib.csw import CatalogueServiceWeb
if len(sys.argv) < 3:
print 'Usage: %s <csw-endpoint> <max-records>'
sys.exit(1)
URL = sys.argv[1]
MAXRECORDS = sys.argv[2] or 10
CSW = CatalogueServiceWeb(URL)
CSW.getrecords2(maxrecords=MAXRECORDS, outputschema='http://www.isotc211.org/2005/gmd', esn='full')
for key, value in CSW.records.iteritems():
filename = 'xml/%s.xml' % key
with open(filename, 'w') as ff:
ff.write(value.xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment