FLResponse = cboResponse.Value RLCovarTif = lboCovariate.List(0) fileExtract = tmpFolder & "\UseExtraction0.shp" gp.ExtractValuesToPoints_sa FLResponse, RLCovarTif, fileExtract, "NONE", "VALUE_ONLY" FLResponse = "UseExtraction0" gp.AddXY_management FLResponse
' Process: Extract Values to Points... If i = 0 Then gp.ExtractValuesToPoints_sa FLResponse, RLCovarTif, fileExtract, "NONE", "VALUE_ONLY" Else gp.ExtractValuesToPoints_sa pFClass2, RLCovarTif, fileExtract, "NONE", "VALUE_ONLY" End If FLResponse = "UseExtraction" & i 'NEW CODE If (i = (lboCovariate.ListCount - 1)) Then gp.AddXY_management FLResponse End If
For i = 0 To lboCovariate.ListCount - 1 fileExtract = tmpFolder & "\UseExtraction" & i & ".shp" RLCovarTif = lboCovariate.List(i) ' Process: Extract Values to Points... If i = 0 Then gp.ExtractValuesToPoints_sa FLResponse, RLCovarTif, fileExtract, "NONE", "VALUE_ONLY" Else gp.ExtractValuesToPoints_sa pFClass2, RLCovarTif, fileExtract, "NONE", "VALUE_ONLY" End If FLResponse = "UseExtraction" & i If (i = (lboCovariate.ListCount - 1)) Then 'Add X- and Y- coordinates gp.AddXY_management FLResponse End If 'Delete new layer from project For j = 0 To pMap.LayerCount - 1 If (pMap.Layer(j).Name) = (FLResponse) Then pMap.DeleteLayer pMap.Layer(j) pMxDoc.UpdateContents Exit For End If Next j 'Load most recent extraction point layer Set pFWkSpace2 = pWkFactory2.OpenFromFile(tmpFolder & "\", 0) Set pFClass2 = pFWkSpace2.OpenFeatureClass(FLResponse) 'Get all fields of extraction point layer Set pFields = pFClass2.Fields 'This checks if a field of proposed name already exists intRasField = pFields.FindField("RasVal" & i) If intRasField = -1 Then 'Proposed field name does NOT exist pFieldEdit.Name = ("RasVal" & i) pFClass2.AddField pFieldEdit 'Set index to position of the new field intRasField = pFields.FindField("RasVal" & i) End If 'Find position of original raster field intOrigRasVal = pFields.FindField("RASTERVALU") 'Set values of new field to RASTERVALU Set pFCursor = pFClass2.Update(Nothing, True) Set pFeature = pFCursor.NextFeature Do Until pFeature Is Nothing 'Copy value from RASTERVALU (it will only 1st be in memory) pFeature.Value(intRasField) = pFeature.Value(intOrigRasVal) 'Write it to the feature class pFCursor.UpdateFeature pFeature Set pFeature = pFCursor.NextFeature Loop Set pField = pFields.Field(pFields.FindField("RASTERVALU")) pFClass2.DeleteField pField 'If last covariate layer in list was processed, add response data If (i = (lboCovariate.ListCount - 1)) Then 'This checks if a field of proposed name already exists intResField = pFields.FindField("Response") If intResField = -1 Then 'Proposed field name does NOT exist pFClass2.AddField pFieldEdit2 'Set index to position of the new field intResField = pFields.FindField("Response") End If 'Set values of Response field to use = 1 Set pFCursor = pFClass2.Update(Nothing, True) Set pFeature = pFCursor.NextFeature Do Until pFeature Is Nothing pFeature.Value(intResField) = 1 'Write it to the feature class pFCursor.UpdateFeature pFeature Set pFeature = pFCursor.NextFeature Loop End If Next i
'Get all fields and change name of extracted raster field 'This is done so that another raster field can be added Set pFields = pFClass.Fields Set pField = pFields.Field(pFields.FindField("RASTERVALU")) Set pFieldEdit = pField pFieldEdit.Name = "RasVal" & i
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.