Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Some Python software I have written generates raster files via GDAL. I would like the software to create an XML metadata file for each raster so that I can include details about how the raster was made, who made it, and so-on.

I understand that ISO 19115 is the international geospatial metadata standard. I really have no idea where to start with generating a metadata file, though. Can GDAL do this from scratch? Or would it be better to work with a dedicated XML library in Python?

share|improve this question
4  
If you decide to go with a python library, I can definitely recommend lxml. I find it very easy to use and the Xpath functionality is great. lxml.de/tutorial.html –  s_a Mar 4 '13 at 23:58

1 Answer 1

THis post got me started to create a needed XML-file with Python: http://stackoverflow.com/questions/3605680/creating-a-simple-xml-file-using-python

in my case, this code:

##############################
#Create the necessary XML file
##############################
root = ET.Element("OGRVRTDataSource")
OGRVRTLayer  = ET.SubElement(root, "OGRVRTLayer")
OGRVRTLayer.set("name", AMSRcsv_shortname)

SrcDataSource = ET.SubElement(OGRVRTLayer, "SrcDataSource")
SrcDataSource.text = AMSRcsv

GeometryType = ET.SubElement(OGRVRTLayer, "GeometryType")
GeometryType.text = "wkbPoint"

GeometryField = ET.SubElement(OGRVRTLayer,"GeometryField")
GeometryField.set("encoding", "PointFromColumns")
GeometryField.set("x", "lon")
GeometryField.set("y", "lat")
GeometryField.set("z", "brightness")

tree = ET.ElementTree(root)
tree.write(AMSRcsv_vrt)

creates such files:

<OGRVRTDataSource>
   <OGRVRTLayer name="GW1AM2_201301010834_032D_L1SGRTBR_1110110_channel89H">
      <SrcDataSource>G:\AMSR\GW1AM2_201301010834_032D_L1SGRTBR_1110110_channel89H.csv</SrcDataSource>
      <GeometryType>wkbPoint</GeometryType>
      <GeometryField encoding="PointFromColumns" x="lon" y="lat" z="brightness" />
   </OGRVRTLayer>
</OGRVRTDataSource>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.