Beispiel #1
0
def make_siteXYDict(siteList,siteFC,srCode,gp):
    siteCol = utils.sitePtIDCol #"NAME"  # Field that contains the site ID
    sitesXY = {}
    # temp directory to create dummy shapefile for Spatial Reference
    tmpDir = os.path.dirname(siteFC)
    spatRef = utils.make_spatRef(gp,tmpDir,srCode)
    # Create Search Cursor on site point feature class
    # With Geographic spatial reference for lat/long coords
    allpts = gp.SearchCursor(siteFC,'',spatRef)
    pt = allpts.Next()
    while pt:
        # site id
        siteID = pt.GetValue(siteCol)
        # Coordinates
        X = pt.shape.GetPart().x
        Y = pt.shape.GetPart().y
        sitesXY[siteID] = [X,Y]
        pt = allpts.Next()

    del allpts   # remove the cursor    
    return sitesXY   
Beispiel #2
0
        missingOutDir = [d for d in siteList if d not in outSubDirList]  
        errtext = ""
        if missingInDir or missingOutDir or missingTransFile:
            if missingInDir:
                errtext += "INPUT directory(ies) not found:\n%s\n%s\n" % ('/'.join((inParentDir,"*")),'\n'.join(missingInDir)) 
            if missingOutDir:
                errtext += "OUTPUT directory(ies) not found:\n%s\n%s\n" % ('/'.join((outParentDir,"*",utils.ptShpSubDir)),'\n'.join(missingOutDir))
            if missingTransFile:
                errtext += "TRANSECT file(s) not found:\n%s" % '\n'.join(missingTransFile)
            e.call(errtext)
        #--- END CHECK FOR PRESENCE OF INPUT/OUTPUT DIRECTORIES AND FILES ------
        #-----------------------------------------------------------------------
            
        # Create input Spatial Reference for use in Cursor
        msg('Fetching Spatial Reference')
        inSpatialRef = utils.make_spatRef(gp,outParentDir,inCoordSys)
        
        msg("Processing %s site(s) requested in '%s'" % (len(siteList),siteFile))
        # Now loop through and process sites
        for path in sites_to_process:
            fullTransFile,outDir,outFC,site  = path[0],path[1],path[2],path[3]
            msg("-------- SITE ID: %s --------" % site)
            outFCFull = os.path.join(outDir,outFC)
            
            if os.path.exists(fullTransFile):
                # Test opening with lightwight validation
                test_csv(fullTransFile)
                msg("CSV file, '%s', found and opened successfully" % os.path.basename(fullTransFile))
            else:
                e.call("CSV file '%s' cannot be found" % fullTransFile)