Start Terminal
cd Downloads
cd android-sdk-macos
cd platform-tools
./adb devices
./adb install NameItAll.apk
On Phone
>Allow USB Debugging (Settings > Developers Settings)
>Allow unknown Sources (Settings > Security)
Start Terminal
cd Downloads
cd android-sdk-macos
cd platform-tools
./adb devices
./adb install NameItAll.apk
On Phone
>Allow USB Debugging (Settings > Developers Settings)
>Allow unknown Sources (Settings > Security)
http://forums.esri.com/Thread.asp?c=93&f=993&t=210767&mc=12#652601
Option Explicit
Sub TestInMemory()
Dim pFC As IFeatureClass
Set pFC = OpenFC(“C:\Projects\SAWS\water3.gdb”, _
“Mains”)
Dim pFLayer As IFeatureLayer
Set pFLayer = New FeatureLayer
pFLayer.Name = pFC.AliasName
Set pFLayer.FeatureClass = CacheToMemory(pFC, “Shape_Length 0 Then
Set pQF = New QueryFilter
pQF.WhereClause = sWhere
End If
Dim pInFCur As IFeatureCursor
Set pInFCur = pFC.Search(pQF, False)
Dim pFeat As IFeature
Set pFeat = pInFCur.NextFeature
Do Until pFeat Is Nothing
Dim pOutFeat As IFeature
Set pOutFeat = pInMemFC.CreateFeature
Dim l As Long
For l = 0 To pOutFeat.Fields.FieldCount – 1
‘ todo maybe search by field alias to find match
If pOutFeat.Fields.Field(l).Editable Then
pOutFeat.Value(l) = pFeat.Value(l)
End If
Next l
pOutFeat.Store
Set pFeat = pInFCur.NextFeature
Loop
End Sub
Function Clone(pClone As IClone) As IClone
Set Clone = pClone.Clone
End Function
Function OpenFC(sPath As String, sName As String) As IFeatureClass
Dim pWSF As IWorkspaceFactory
Set pWSF = New FileGDBWorkspaceFactory
Dim pFWS As IFeatureWorkspace
Set pFWS = pWSF.OpenFromFile(sPath, 0)
Set OpenFC = pFWS.OpenFeatureClass(sName)
End Function
Dim pConversionOp As IConversionOp
Set pConversionOp = New RasterConversionOp
‘Get the raster
Dim pRas01 As IRaster
Set pRas01 = getRasterFromFileFunction(“c:\data\myRaster”)
Dim pFClassOut As IGeoDataset
Dim pWSF As IWorkspaceFactory
Set pWSF = New ShapefileWorkspaceFactory
Dim pWS As IWorkspace
Set pWS = pWSF.OpenFromFile(“c:\data”, 0)
Dim sOutFCname As String
sOutFCname = “myShapeFile.shp”
Set pFClassOut = pConversionOp.RasterDataToLineFeatureData(pRas01, pWS, sOutFCname, False, False, 1.0)
'Reclassifies (or changes) the values of the input cells of a raster by ' using a remap that is built programmatically. ' 'Function ReclassByRemap(ByVal GeoDataset As esriGeoDatabase.IGeoDataset, _ ' ByVal Remap As IRemap, ByVal retainMissingValues As Boolean) _ ' As esriGeoDatabase.IGeoDataset ' 'Member of esriGeoAnalyst.IReclassOp Dim pReclassOp As IReclassOp Set pReclassOp = New RasterReclassOp ' Get raster dataset Dim pRas01 As IRaster Set pRas01 = readRasterFromDisk("c:\data\myRaster") ' Set the Remap Dim pRemap As IRemap Dim pSRemap As INumberRemap Set pSRemap = New NumberRemap pSRemap.MapRange -3, 0, 0 pSRemap.MapRange 0, 2, 20 pSRemap.MapRange 2, 3, 60 Set pRemap = pSRemap ' Create output raster dataset Dim pRasOut As IRaster Set pRasOut = pReclassOp.ReclassByRemap(pRas01, pRemap, True)
http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/spatial_analyst_tools/reclassbyremap.htm
Dim pDensityOp As IDensityOp
Set pDensityOp = New RasterDensityOp
‘Create Raster Analysis Environment and set output cell size
Dim pEnv As IRasterAnalysisEnvironment
Set pEnv = pDensityOp
pEnv.SetCellSize esriRasterEnvValue, 50
Dim pFClass01 As IFeatureClass
Set pFClass01 = FunctionToOpenPointFeatureClass(“C:\data\point01.shp”)
‘ Create Neighborhood using map unit
Dim pNbr As IRasterNeighborhood
Set pNbr = New RasterNeighborhood
pNbr.SetCircle 4, esriUnitsMap
‘ Call the Point Density method using featureclass as input
Dim pRasOut As IRaster
Set pRasOut = pDensityOp.PointDensity(pFClass01, pNbr)
‘ OR
‘ Create FeatureClassDescriptor to specify a field or keyword NONE
Dim pFDescr As IFeatureClassDescriptor
Set pFDescr = New FeatureClassDescriptor
pFDescr.Create pFClass01, Nothing, “Field1”
‘ Call the Point Density method using FeatureClassDescriptor
Dim pRasOut2 As IRaster
Set pRasOut2 = pDensityOp.PointDensity(pFDescr, pNbr)
Question: How to find closest number in a list?
Answer:
Array formula in cell C2:
How to create an array formula
Explaining array formula
INDEX(A2:A26,MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0))
Step 1 – Return absolute values of numbers in an array, numbers without its sign
INDEX(A2:A26,MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0))
ABS(number) returns the absolute value of a number, a number without its sign.
ABS(A2:A26-C1)
becomes
ABS({3, 77, 7, 62, 66, 48, 83, 57, 69, 10, 86, 42, 71, 90, 34, 17, 73, 77, 20, 37, 59, 50, 99} – 43)
becomes
ABS{-40, 34, -36, 19, 23, 5, 40, 14, 26, -33, 43, -1, 28, 47, -9, -26, 30, 34, -23, -6, 16, 7, 56})
and returns
{40, 34, 36, 19, 23, 5, 40, 14, 26, 33, 43, 1, 28, 47, 9, 26, 30, 34, 23, 6, 16, 7, 56}
Step 2 – Return the smallest number
INDEX(A2:A26,MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0))
MIN(number1,[number2]) returns the smallest number in a set of values. Ignores logical values and text
MIN(ABS(A2:A26-C1))
MIN({40, 34, 36, 19, 23, 5, 40, 14, 26, 33, 43, 1, 28, 47, 9, 26, 30, 34, 23, 6, 16, 7, 56}
returns 1.
Step 3 – Return the relative position of an item in an array
INDEX(A2:A26,MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0))
MATCH(lookup_value;lookup_array; [match_type]) returns the relative position of an item in an array that matches a specified value
MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0)
becomes
MATCH(1, {40, 34, 36, 19, 23, 5, 40, 14, 26, 33, 43, 1, 28, 47, 9, 26, 30, 34, 23, 6, 16, 7, 56}, 0)
returns 12.
Step 4 – Return a value or reference of the cell at the intersection of a particular row and column
INDEX(array,row_num,[column_num]) returns a value or reference of the cell at the intersection of a particular row and column, in a given range
INDEX(A2:A26,MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0))
becomes
INDEX(A2:A26,12)
and returns 42.
EDIT: Added excel workbook to this blog post
Download excel example file
find-closest-value.xls
(Excel 97-2003 Workbook *.xls)
Array formula in cell C4:
How to create an array formula
How to copy array formula
Download excel file
Array formula in cell D5:
Array formula in cell E5:
How to create an array formula
How to copy array formula
Download excel example file
find-closest-values-return-adjacent-value.xlsx
INDEX(array,row_num,[column_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range
ABS(number)
Returns the absolute value of a number, a number without its sign.
MATCH(lookup_value;lookup_array; [match_type])
Returns the relative position of an item in an array that matches a specified value
MIN(number1,[number2])
Returns the smallest number in a set of values. Ignores logical values and text
NSLog (@”Value of my BOOL = %@”, someBool ? @”YES” : @”NO”);
auto fill with column names
=INDEX(Sheet1!$1:$1, ROW())
multiple condition lookup
=SUMIFS($I$46:$I$119,$G$46:$G$119,B1,$H$46:$H$119,B2)
http://chandoo.org/wp/2010/11/02/multi-condition-lookup/
CountIf for AND criterias
=SUM((A2:A10=”Cars”)*(B2:B10=”Black”))
http://www.officearticles.com/excel/count_using_multiple_criteria_in_microsoft_excel.htm
Do While Not pFeature Is Nothing
Dim pEndPt As IPoint
Dim pLine As IPolyline
pLine = pFeature.Shape
pEndPt = pLine.ToPoint
Dim pProxOpLine As IProximityOperator
Dim pFromPt As New Point
Dim pQueryFilter As IQueryFilter
pQueryFilter = New QueryFilter
‘pQFilt.WhereClause =
pQueryFilter.WhereClause = cboRefID.Text & ” = ‘” & pFeature.Value(pFeature.Fields.FindField(cboRefField.Text)) & “‘”
‘ MsgBox(pQueryFilter.WhereClause)
Dim kFeatureLayer As IFeatureLayer
kFeatureLayer = pMxDoc2.FocusMap.Layer(GetLayerIndex(.cboRefLayer.Text))
Dim kFeatureClass As IFeatureClass = kFeatureLayer.FeatureClass
Dim kFeatureCursor As IFeatureCursor = kFeatureClass.Search(pQueryFilter, False)
If kFeatureClass.FeatureCount(pQueryFilter) > 0 Then
Dim kFeature As IFeature = kFeatureCursor.NextFeature
If Not kFeature Is Nothing Then
pProxOpLine = kFeature.Shape
pProxOpLine.QueryNearestPoint(pEndPt, esriSegmentExtension.esriNoExtension, pFromPt)
‘Dim pPolyline As New Polyline
‘ pPolyline.AddPoint(pFromPt)
Dim pPointsF As IPointCollection = pLine
Dim zAware As IZAware = CType(pFromPt, IZAware)
zAware.ZAware = True
pFromPt.Z = pEndPt.Z
pPointsF.AddPoint(pFromPt)
Dim Dist As Double = txtDist.Text
If Not Dist = 0 Then
Dim x As Double
Dim y As Double
If pEndPt.X = pFromPt.X Then
x = pFromPt.X
If pFromPt.Y > pEndPt.Y Then
y = pFromPt.Y + Dist
Else
y = pFromPt.Y – Dist
End If
Else
Dim m As Double
m = (pEndPt.Y – pFromPt.Y) / (pEndPt.X – pFromPt.X)
x = Math.Sqrt(Dist * Dist / (1 + m * m))
If pFromPt.X < pEndPt.X Then
x = pFromPt.X – x
Else
x = pFromPt.X + x
End If
y = m * (x – pFromPt.X) + pFromPt.Y
End If
Dim PtAdd As New Point
PtAdd.X = x
PtAdd.Y = y
Dim zAware2 As IZAware = CType(PtAdd, IZAware)
zAware2.ZAware = True
PtAdd.Z = pEndPt.Z
pPointsF.AddPoint(PtAdd)
End If
pFeature.Shape = pLine
pFeature.Store()
'If Not pFromPt Is Nothing Then
' pProxOpLine.AddPoint(pFromPt)
' End If
'pPolyline.AddPoint(pFromPt)
' pPolyline.AddPoint(pEndPt)
End If
End If
pFeature = pFeatureCursor.NextFeature
Loop
Sub LogInformation()
Const LogFileName As String = “D:\TEXTFILE.TXT”
Dim LogMessage As String
LogMessage = “123”
Dim FileNum As Integer
FileNum = FreeFile ‘ next file number
Open LogFileName For Output As #FileNum ‘ creates the file if it doesn’t exist
Print #FileNum, LogMessage ‘ write information at the end of the text file
Close #FileNum ‘ close the file
End Sub