1

I am trying to use python to parse the .pvl metadata file from some GeoEye imagery. I would like to write a script that locates the productCloudCover and countryCode tags found within the .pvl. Does anyone know where I could find information on how to do this?

The structure of the file is as follows.

copyright = "######"
companyAddress = "########"
BEGIN_GROUP = "product order info"
     projectName = "#######"
     BEGIN_GROUP = "#####"   
         productCloudCover = "0.2"
     END_GROUP
END_GROUP = "product order inf"

Thanks

  • What is a PVL file? Doing a cursory internet search, it appears PVL is an extension used for cell phone backups and for some sort of installation information. – Jason Scheirer May 2 '14 at 14:53
  • .pvl is also used in GeoEye imagery metadata. I am trying to get the cloude cover data for a series of images. – user29829 May 2 '14 at 15:02
2

I see the release notes for GDAL 1.10 talk about having added the ability to read .pvl metadata. You might just skip python altogether and use .


This could be a straight python text parsing question, not specifically GIS. A simplistic implementation might look like this:

sample.pvl:

copyright = "(c) 2014 XYZ corp"
companyAddress = "123 Park Lane"
BEGIN_GROUP = "product order info"
    projectName = "Ramadian Parkland"
    BEGIN_GROUP = "this is a group"   
         productCloudCover = "0.2"
    END_GROUP
END_GROUP = "product order info"

parse-pvl.py:

fname = "sample.pvl"

pvl_dict = {}
for line in open(fname):
    line = line.strip() # strip leading and trailing whitespace
    if not "GROUP" in line: # skip lines containing "GROUP"
        key,value = str.split(line, ' = ')
        pvl_dict[key] = value

print "Project:\t", pvl_dict['projectName']
print "Clouds:\t\t", pvl_dict['productCloudCover']

Results in:

Project:    "Ramadian Parkland"
Clouds:     "0.2"

Not addressed are things like dealing with quotes, or extra = characters. For more help on dealing with those ask on Stack Overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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