immediately get value of a record added with insertCursor

Discussion created by speedell on Jun 30, 2010
Latest reply on Jul 2, 2010 by speedell
I have a filesystem full of data that I want to create metadata for. In addition, I want to make a map of the extents of each dataset. The aim of this exercise is to build a simple catalogue which has, as a minimum, the ability to search by area and keyword.

I am writing a script which will crawl a filesystem, find any geodatasets, generate an extent polygon for each dataset, write this to a feature class in a file geodb, check if there is an xml metadata file, write an ISO19139 stub xml file if none exists with automatically generated metadata elements.

This requires me to do the following :

Loop through all files listed by :

allFiles = os.walk(gp.workspace)

and at each level which is a directory (workspace), get the ArcGIS recognised datasets :

datasets = gp.listdatasets()

for each of these, do a describe :

desc = gp.Describe(os.path.join(dirname, subdirname, dataset))

create an extent polygon and write it using an insertCursor to the "footprint" feature class
open up a template xml file, create a DOM object from it and modify the values.

so far, so good. However, many of the datasets I am dealing with are in different spatial reference systems (SRS). I use an InsertCursor so that each dataset extent polygon is reprojected to WGS84 upon insertion into a new row of the footprint feature class. For my xml metadata, I now need these WGS84 corner points, so I need to access the geometry object of the newly inserted row. But, getValue throws an exception if used on the new row immediately. All the other metadata I need to grab can come from the original describe operation and the path, so it is just the reprojected geometry I need to access.

Does anyone have any tips on how I can either successfully getvalue on the new row, or reproject the geometry in code, the same way that insertcursor magically does for me in the featureclass?

Thanks a million - zipped python code attached