import arcpy as ARCPY
import numpy as NUM
import SSDataObject as SSDO
ssdo.oidName
as your Unique ID FieldinputFC = r'../data/CA_Polygons.shp'
ssdo = SSDO.SSDataObject(inputFC)
ssdo.obtainData("MYID", ['GROWTH', 'LOGPCR69', 'PERCNOHS', 'POP1969'])
df = ssdo.getDataFrame()
print(df.head())
GROWTH LOGPCR69 PERCNOHS POP1969 158 0.011426 0.176233 37.0 1060099 159 -0.137376 0.214186 38.3 398 160 -0.188417 0.067722 41.4 11240 161 -0.085070 -0.118248 42.9 101057 162 -0.049022 -0.081377 48.1 13328
.data
to get the native data typereturnDouble()
function to cast explicitly to floatpop69 = ssdo.fields['POP1969']
nativePop69 = pop69.data
floatPop69 = pop69.returnDouble()
print(floatPop69[0:5])
[ 1.06009900e+06 3.98000000e+02 1.12400000e+04 1.01057000e+05 1.33280000e+04]
df = ssdo.getDataFrame()
print(df.head())
GROWTH LOGPCR69 PERCNOHS POP1969 158 0.011426 0.176233 37.0 1060099 159 -0.137376 0.214186 38.3 398 160 -0.188417 0.067722 41.4 11240 161 -0.085070 -0.118248 42.9 101057 162 -0.049022 -0.081377 48.1 13328
df['XCoords'] = ssdo.xyCoords[:,0]
df['YCoords'] = ssdo.xyCoords[:,1]
print(df.head())
GROWTH LOGPCR69 PERCNOHS POP1969 XCoords YCoords 158 0.011426 0.176233 37.0 1060099 -1.356736e+07 4.503012e+06 159 -0.137376 0.214186 38.3 398 -1.333797e+07 4.637142e+06 160 -0.188417 0.067722 41.4 11240 -1.343007e+07 4.615529e+06 161 -0.085070 -0.118248 42.9 101057 -1.353566e+07 4.789809e+06 162 -0.049022 -0.081377 48.1 13328 -1.341895e+07 4.581597e+06
requireGeometry = True
ssdo = SSDO.SSDataObject(inputFC)
ssdo.obtainData("MYID", ['GROWTH', 'LOGPCR69', 'PERCNOHS', 'POP1969'],
requireGeometry = True)
df = ssdo.getDataFrame()
shapes = NUM.array(ssdo.shapes, dtype = object)
df['shapes'] = shapes
print(df.head())
GROWTH LOGPCR69 PERCNOHS POP1969 \ 158 0.011426 0.176233 37.0 1060099 159 -0.137376 0.214186 38.3 398 160 -0.188417 0.067722 41.4 11240 161 -0.085070 -0.118248 42.9 101057 162 -0.049022 -0.081377 48.1 13328 shapes 158 (<geoprocessing array object object at 0x00000... 159 (<geoprocessing array object object at 0x00000... 160 (<geoprocessing array object object at 0x00000... 161 (<geoprocessing array object object at 0x00000... 162 (<geoprocessing array object object at 0x00000...
appendFields
can be used to copy over any fields from the input whether you read them into the SSDataObject or not.import numpy.random as RAND
import os as OS
ARCPY.env.overwriteOutput = True
outArray = RAND.normal(0,1, (ssdo.numObs,))
outDict = {}
outField = SSDO.CandidateField('STDNORM', 'DOUBLE', outArray, alias = 'Standard Normal')
outDict[outField.name] = outField
outputFC = OS.path.abspath(r'../data/testMyOutput.shp')
ssdo.output2NewFC(outputFC, outDict, appendFields = ['GROWTH', 'PERCNOHS', 'NEW_NAME'])