本文整理汇总了Python中SSUtilities.isShapeFile方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.isShapeFile方法的具体用法?Python SSUtilities.isShapeFile怎么用?Python SSUtilities.isShapeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSUtilities
的用法示例。
在下文中一共展示了SSUtilities.isShapeFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import isShapeFile [as 别名]
def __init__(self, ssdo, varName, outputFC, wType,
weightsFile = None, concept = "EUCLIDEAN",
rowStandard = True, threshold = None,
exponent = 1.0, permutations = None,
applyFDR = False):
#### Set Initial Attributes ####
UTILS.assignClassAttr(self, locals())
#### Assess Whether SWM File Being Used ####
self.swmFileBool = False
if weightsFile:
weightSuffix = weightsFile.split(".")[-1].lower()
self.swmFileBool = (weightSuffix == "swm")
#### Warn Inverse Distance if Geographic Coord System ####
#if wType in [0, 7]:
# WU.checkGeographicCoord(self.ssdo.spatialRefType,
# WU.wTypeDispatch[wType])
#### Create Shape File Boolean for NULL Values ####
self.outShapeFileBool = UTILS.isShapeFile(outputFC)
#### Initialize Data ####
self.initialize()
#### Construct Based on SWM File or On The Fly ####
self.construct()
示例2: createOutput
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import isShapeFile [as 别名]
def createOutput(self, outputFC):
"""Creates an Output Feature Class with the Median Centers.
INPUTS:
outputFC (str): path to the output feature class
"""
#### Validate Output Workspace ####
ERROR.checkOutputPath(outputFC)
#### Shorthand Attributes ####
ssdo = self.ssdo
caseField = self.caseField
attFields = self.attFields
#### Create Output Feature Class ####
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
outPath, outName = OS.path.split(outputFC)
try:
DM.CreateFeatureclass(outPath, outName, "POINT", "", ssdo.mFlag,
ssdo.zFlag, ssdo.spatialRefString)
except:
ARCPY.AddIDMessage("ERROR", 210, outputFC)
raise SystemExit()
#### Add Field Names ####
dataFieldNames = UTILS.getFieldNames(mdcFieldNames, outPath)
shapeFieldNames = ["[email protected]"]
for fieldName in dataFieldNames:
UTILS.addEmptyField(outputFC, fieldName, "DOUBLE")
caseIsDate = False
if caseField:
fcCaseField = ssdo.allFields[caseField]
validCaseName = UTILS.validQFieldName(fcCaseField, outPath)
caseType = UTILS.convertType[fcCaseField.type]
UTILS.addEmptyField(outputFC, validCaseName, caseType)
dataFieldNames.append(validCaseName)
if caseType.upper() == "DATE":
caseIsDate = True
if attFields:
for attField in attFields:
fcAttField = ssdo.allFields[attField]
validAttName = UTILS.validQFieldName(fcAttField, outPath)
if caseField:
if validCaseName == validAttName:
validAttName = ARCPY.GetIDMessage(84195)
UTILS.addEmptyField(outputFC, validAttName, "DOUBLE")
dataFieldNames.append(validAttName)
outShapeFileBool = UTILS.isShapeFile(outputFC)
#### Add Median X, Y, Dim ####
allFieldNames = shapeFieldNames + dataFieldNames
rows = DA.InsertCursor(outputFC, allFieldNames)
for case in self.caseKeys:
#### Median Centers ####
medX, medY = self.medianCenter[case]
pnt = (medX, medY, ssdo.defaultZ)
rowResult = [pnt, medX, medY]
#### Set Attribute Fields ####
if caseField:
caseValue = case.item()
if caseIsDate:
caseValue = TUTILS.iso2DateTime(caseValue)
rowResult.append(caseValue)
#### Set Attribute Fields ####
if attFields:
for attInd, attField in enumerate(self.attFields):
medAtt = self.attCenter[case][attInd]
rowResult.append(medAtt)
rows.insertRow(rowResult)
#### Clean Up ####
del rows
#### Set Attribute ####
self.outputFC = outputFC
示例3: output2NewFC
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import isShapeFile [as 别名]
def output2NewFC(self, outputFC, candidateFields, appendFields = [],
fieldOrder = []):
"""Creates a new feature class with the same shape charcteristics as
the source input feature class and appends data to it.
INPUTS:
outputFC (str): catalogue path to output feature class
candidateFields (dict): fieldName = instance of CandidateField
appendFields {list, []}: field names in the order you want appended
fieldOrder {list, []}: the order with which to write fields
"""
#### Initial Progressor Bar ####
ARCPY.overwriteOutput = True
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84006))
#### Validate Output Workspace ####
ERROR.checkOutputPath(outputFC)
#### Create Path for Output FC ####
outPath, outName = OS.path.split(outputFC)
#### Get Output Name for SDE if Necessary ####
baseType = UTILS.getBaseWorkspaceType(outPath)
if baseType.upper() == 'REMOTEDATABASE':
outName = outName.split(".")[-1]
self.outputFC = OS.path.join(outPath, outName)
#### Assess Whether to Honor Original Field Nullable Flag ####
setNullable = UTILS.setToNullable(self.catPath, self.outputFC)
#### Add Null Value Flag ####
outIsShapeFile = UTILS.isShapeFile(self.outputFC)
#### Create Output Field Names to be Appended From Input ####
inputFieldNames = ["[email protected]", self.masterField]
appendFieldNames = []
masterIsOID = self.masterField == self.oidName
if masterIsOID:
appendFieldNames.append("SOURCE_ID")
else:
master = self.allFields[self.masterField.upper()]
returnName = UTILS.returnOutputFieldName(master)
appendFieldNames.append(returnName)
for fieldName in appendFields:
field = self.allFields[fieldName.upper()]
returnName = UTILS.returnOutputFieldName(field)
inputFieldNames.append(fieldName)
appendFieldNames.append(returnName)
appendFieldNames = UTILS.createAppendFieldNames(appendFieldNames,
outPath)
masterOutName = appendFieldNames[0]
#### Create Field Mappings for Visible Fields ####
outputFieldMaps = ARCPY.FieldMappings()
#### Add Input Fields to Output ####
for ind, fieldName in enumerate(appendFieldNames):
if ind == 0:
#### Master Field ####
sourceFieldName = self.masterField
if masterIsOID:
fieldType = "LONG"
alias = fieldName
setOutNullable = False
fieldLength = None
fieldPrecision = None
else:
masterOutField = self.allFields[self.masterField.upper()]
fieldType = masterOutField.type
alias = masterOutField.baseName
setOutNullable = setNullable
fieldLength = masterOutField.length
fieldPrecision = masterOutField.precision
else:
#### Append Fields ####
sourceFieldName = appendFields[ind-1]
outField = self.allFields[sourceFieldName]
fieldType = outField.type
alias = outField.baseName
setOutNullable = setNullable
fieldLength = outField.length
fieldPrecision = outField.precision
#### Create Candidate Field ####
outCandidate = CandidateField(fieldName, fieldType, None,
alias = alias,
precision = fieldPrecision,
length = fieldLength)
#### Create Output Field Map ####
outFieldMap = UTILS.createOutputFieldMap(self.inputFC,
sourceFieldName,
outFieldCandidate = outCandidate,
setNullable = setOutNullable)
#### Add Output Field Map to New Field Mapping ####
outputFieldMaps.addFieldMap(outFieldMap)
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import isShapeFile [as 别名]
def __init__(self, inputFC, templateFC = None, explicitSpatialRef = None,
silentWarnings = False, useChordal = True):
#### Validate Input Feature Class ####
ERROR.checkFC(inputFC)
try:
self.inPath, self.inName = OS.path.split(inputFC)
except:
self.inPath = None
self.inName = inputFC
#### Validate Template FC ####
if templateFC != None:
if ARCPY.Exists(templateFC) == False:
templateFC = None
#### ShapeFile Boolean ####
self.shapeFileBool = False
if self.inPath:
self.shapeFileBool = UTILS.isShapeFile(inputFC)
#### Create Feature Layer if LYR File ####
path, ext = OS.path.splitext(inputFC)
if ext.upper() == ".LYR":
tempFC = "SSDO_FeatureLayer"
DM.MakeFeatureLayer(inputFC, tempFC)
inputFC = tempFC
#### Describe Input ####
self.info = ARCPY.Describe(inputFC)
#### Assure Input are Features with OIDs ####
if not self.info.hasOID:
ARCPY.AddIDMessage("ERROR", 339, self.inName)
raise SystemExit()
#### Assign Describe Objects to Class Attributes ####
self.inputFC = inputFC
self.catPath = self.info.CatalogPath
self.shapeType = self.info.ShapeType
self.oidName = self.info.oidFieldName
self.dataType = self.info.DataType
self.shapeField = self.info.ShapeFieldName
self.templateFC = templateFC
self.hasM = self.info.HasM
self.hasZ = self.info.HasZ
self.silentWarnings = silentWarnings
#### Set Initial Extent Depending on DataType ####
if self.dataType in ["FeatureLayer", "Layer"]:
try:
tempInfo = ARCPY.Describe(self.catPath)
extent = tempInfo.extent
except:
#### in_memory, SDE, NetCDF etc... ####
extent = self.info.extent
self.fidSet = self.info.FIDSet
if self.fidSet == "":
self.selectionSet = False
else:
self.selectionSet = True
else:
extent = self.info.extent
self.fidSet = ""
self.selectionSet = False
self.extent = extent
#### Set Spatial Reference ####
inputSpatRef = self.info.SpatialReference
inputSpatRefName = inputSpatRef.name
if explicitSpatialRef:
#### Explicitely Override Spatial Reference ####
self.templateFC = None
self.spatialRef = explicitSpatialRef
else:
#### 1. Feature Dataset, 2. Env Setting, 3. Input Hierarchy ####
self.spatialRef = UTILS.returnOutputSpatialRef(inputSpatRef,
outputFC = templateFC)
self.spatialRefString = UTILS.returnOutputSpatialString(self.spatialRef)
self.spatialRefName = self.spatialRef.name
self.spatialRefType = self.spatialRef.type
#### Warn if Spatial Reference Changed ####
if not silentWarnings:
UTILS.compareSpatialRefNames(inputSpatRefName, self.spatialRefName)
#### Check for Projection ####
if self.spatialRefType.upper() != "PROJECTED":
if self.spatialRefType.upper() == "GEOGRAPHIC":
self.useChordal = useChordal
if not explicitSpatialRef:
if self.useChordal:
ARCPY.AddIDMessage("WARNING", 1605)
else:
ARCPY.AddIDMessage("WARNING", 916)
else:
self.useChordal = False
if not explicitSpatialRef:
ARCPY.AddIDMessage("WARNING", 916)
else:
self.useChordal = False
#.........这里部分代码省略.........
示例5: createOutputShapes
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import isShapeFile [as 别名]
def createOutputShapes(self, outputFC):
#### Shorthand Attributes ####
ssdoBase = self.ssdoBase
ssdoCand = self.ssdoCand
#### Validate Output Workspace ####
ARCPY.overwriteOutput = True
ERROR.checkOutputPath(outputFC)
#### Create Output Feature Class ####
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
outPath, outName = OS.path.split(outputFC)
tempFC = UTILS.returnScratchName("TempSS_FC", fileType = "FEATURECLASS",
scratchWS = outPath)
outTempPath, outTempName = OS.path.split(tempFC)
try:
DM.CreateFeatureclass(outTempPath, outTempName, ssdoBase.shapeType,
"", ssdoBase.mFlag,
ssdoBase.zFlag, ssdoBase.spatialRefString)
except:
ARCPY.AddIDMessage("ERROR", 210, outputFC)
raise SystemExit()
#### Add Null Value Flag ####
outIsShapeFile = UTILS.isShapeFile(outputFC)
setNullable = outIsShapeFile == False
#### Make Feature Layer and Select Result OIDs/Shapes ####
featureCount = ssdoBase.numObs + ssdoCand.numObs
ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84003), 0,
featureCount, 1)
#### Add Shape/ID Field Names ####
matchID, candID = outputIDFieldNames
outFieldNames = ["[email protected]"] + outputIDFieldNames
inFieldNames = ["[email protected]", "[email protected]"]
UTILS.addEmptyField(tempFC, matchID, "LONG", nullable = True)
UTILS.addEmptyField(tempFC, candID, "LONG", nullable = True)
#### Add Append Fields ####
lenAppend = len(self.appendFields)
appendIsDate = []
in2OutFieldNames = {}
if lenAppend:
for fieldName in self.appendFields:
fcField = ssdoCand.allFields[fieldName]
fieldType = UTILS.convertType[fcField.type]
fieldOutName = UTILS.validQFieldName(fcField, outPath)
in2OutFieldNames[fieldName] = fieldOutName
if fieldType == "DATE":
appendIsDate.append(fieldName)
UTILS.addEmptyField(tempFC, fieldOutName, fieldType,
alias = fcField.alias)
outFieldNames.append(fieldOutName)
#### Add Analysis Fields ####
for fieldName in self.fieldNames:
fcField = ssdoBase.allFields[fieldName]
fieldType = UTILS.convertType[fcField.type]
fieldOutName = UTILS.validQFieldName(fcField, outPath)
in2OutFieldNames[fieldName] = fieldOutName
UTILS.addEmptyField(tempFC, fieldOutName, fieldType,
alias = fcField.alias)
outFieldNames.append(fieldOutName)
dataFieldNames = matchFieldInfo[self.similarType]
dataFieldInfo = outputFieldInfo[self.matchMethod]
baseValues = []
for fieldName in dataFieldNames:
outAlias, outType, baseValue = dataFieldInfo[fieldName]
UTILS.addEmptyField(tempFC, fieldName, outType,
alias = outAlias,
nullable = setNullable)
outFieldNames.append(fieldName)
baseValues.append(baseValue)
#### Get Insert Cursor ####
baseRows = DA.SearchCursor(ssdoBase.inputFC, inFieldNames)
candRows = DA.SearchCursor(ssdoCand.inputFC, inFieldNames)
rows = DA.InsertCursor(tempFC, outFieldNames)
#### Set Base Data ####
useShapeNull = outIsShapeFile
if useShapeNull:
nullIntValue = UTILS.shpFileNull['LONG']
else:
nullIntValue = None
#### Set Base Null For Append ####
appendNull = {}
for fieldName in self.appendFields:
if fieldName not in ssdoBase.fields:
if useShapeNull:
outType = ssdoCand.fields[fieldName].type
outNullValue = UTILS.shpFileNull[outType]
else:
outNullValue = None
appendNull[fieldName] = outNullValue
#.........这里部分代码省略.........
示例6: createOutput
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import isShapeFile [as 别名]
def createOutput(self, outputFC):
#### Shorthand Attributes ####
ssdoBase = self.ssdoBase
ssdoCand = self.ssdoCand
#### Validate Output Workspace ####
ARCPY.overwriteOutput = True
ERROR.checkOutputPath(outputFC)
#### Create Output Feature Class ####
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
outPath, outName = OS.path.split(outputFC)
try:
DM.CreateFeatureclass(outPath, outName, "POINT", "", ssdoBase.mFlag,
ssdoBase.zFlag, ssdoBase.spatialRefString)
except:
ARCPY.AddIDMessage("ERROR", 210, outputFC)
raise SystemExit()
#### Add Null Value Flag ####
outIsShapeFile = UTILS.isShapeFile(outputFC)
setNullable = outIsShapeFile == False
#### Add Shape/ID Field Names ####
matchID, candID = outputIDFieldNames
outFieldNames = ["[email protected]"] + outputIDFieldNames
UTILS.addEmptyField(outputFC, matchID, "LONG", nullable = True)
UTILS.addEmptyField(outputFC, candID, "LONG", nullable = True)
#### Add Append Fields ####
lenAppend = len(self.appendFields)
appendIsDate = []
in2OutFieldNames = {}
if lenAppend:
for fieldName in self.appendFields:
fcField = ssdoCand.allFields[fieldName]
fieldType = UTILS.convertType[fcField.type]
fieldOutName = UTILS.validQFieldName(fcField, outPath)
in2OutFieldNames[fieldName] = fieldOutName
if fieldType == "DATE":
appendIsDate.append(fieldName)
UTILS.addEmptyField(outputFC, fieldOutName, fieldType,
alias = fcField.alias)
outFieldNames.append(fieldOutName)
#### Add Analysis Fields ####
for fieldName in self.fieldNames:
fcField = ssdoBase.allFields[fieldName]
fieldType = UTILS.convertType[fcField.type]
fieldOutName = UTILS.validQFieldName(fcField, outPath)
in2OutFieldNames[fieldName] = fieldOutName
UTILS.addEmptyField(outputFC, fieldOutName, fieldType,
alias = fcField.alias)
outFieldNames.append(fieldOutName)
dataFieldNames = matchFieldInfo[self.similarType]
dataFieldInfo = outputFieldInfo[self.matchMethod]
baseValues = []
for fieldName in dataFieldNames:
outAlias, outType, baseValue = dataFieldInfo[fieldName]
UTILS.addEmptyField(outputFC, fieldName, outType,
alias = outAlias,
nullable = setNullable)
outFieldNames.append(fieldName)
baseValues.append(baseValue)
#### Step Progress ####
featureCount = ssdoBase.numObs + self.numResults
if self.similarType == "BOTH":
featureCount += self.numResults
ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84003), 0,
featureCount, 1)
#### Get Insert Cursor ####
rows = DA.InsertCursor(outputFC, outFieldNames)
#### Set Base Data ####
useShapeNull = outIsShapeFile
if useShapeNull:
nullIntValue = UTILS.shpFileNull['LONG']
else:
nullIntValue = None
#### Set Base Null For Append ####
appendNull = {}
for fieldName in self.appendFields:
if fieldName not in ssdoBase.fields:
if useShapeNull:
outType = ssdoCand.fields[fieldName].type
outNullValue = UTILS.shpFileNull[outType]
else:
outNullValue = None
appendNull[fieldName] = outNullValue
#### Add Base Data ####
for orderID in xrange(ssdoBase.numObs):
x,y = ssdoBase.xyCoords[orderID]
pnt = (x, y, ssdoBase.defaultZ)
#### Insert Shape, Match_ID and NULL (Cand_ID) ####
#.........这里部分代码省略.........