Install .apk on phone with mac

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)

InMemory shapefile or featureclass creation

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

IConversionOp RasterDataToLineFeatureData Example

  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)

 

http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoAnalyst/IConversionOp_RasterDataToLineFeatureData_Example.htm

Reclass by Remap

'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

IDensityOp PointDensity Example

http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esriSpatialAnalyst/IDensityOp_PointDensity_Example.htm

Reference: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/PointDensity_Method/00400000003r000000/

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)

Excel: Finding closest value

Question: How to find closest number in a list?

Answer:

Array formula in cell C2:

=INDEX(A2:A26,MATCH(MIN(ABS(A2:A26-C1)),ABS(A2:A26-C1),0))

How to create an array formula

  1. Copy (Ctrl + c) and paste (Ctrl + v) array formula into formula bar.
  2. Press and hold Ctrl + Shift.
  3. Press Enter once
  4. Release all keys

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)

How to find closest values

Array formula in cell C4:

=INDEX($A$2:$A$24, MATCH(SMALL(ABS($A$2:$A$24-$E$1), ROW(A1)), IF(COUNTIF($D$4:D4, $A$2:$A$24)<COUNTIF($A$2:$A$24, $A$2:$A$24), ABS($A$2:$A$24-$E$1), “A”), 0))

How to create an array formula

  1. Select cell C4
  2. Copy (Ctrl + c) and paste (Ctrl + v) array formula into formula bar.
  3. Press and hold Ctrl + Shift.
  4. Press Enter once
  5. Release all keys

How to copy array formula

  1. Select cell C4
  2. Copy cell c4 (Ctrl + c)
  3. Select cell range C4:C20
  4. Paste (Ctrl + v)

Download excel file

find-closest-values.xls

How to find closest values and return adjacent values

Array formula in cell D5:

=INDEX($A$2:$A$24, MATCH(SMALL(ABS($A$2:$A$24-$E$1), ROW(A1)), IF(COUNTIF($D$4:D4, $A$2:$A$24)<COUNTIF($A$2:$A$24, $A$2:$A$24), ABS($A$2:$A$24-$E$1), “A”), 0))

Array formula in cell E5:

=INDEX($B$2:$B$24, MIN(IF((D5=$A$2:$A$24)*(COUNTIFS($D$4:D4, $A$2:$A$24, $E$4:E4, $B$2:$B$24)<COUNTIFS($A$2:$A$24, $A$2:$A$24, $B$2:$B$24, $B$2:$B$24)), MATCH(ROW($A$2:$A$24), ROW($A$2:$A$24)), “A”)))

How to create an array formula

  1. Select cell D5
  2. Copy (Ctrl + c) and paste (Ctrl + v) array formula into formula bar.
  3. Press and hold Ctrl + Shift.
  4. Press Enter once
  5. Release all keys

How to copy array formula

  1. Select cell D5
  2. Copy (Ctrl + c)
  3. Select cell range D6:D28
  4. Paste (Ctrl + v)

Download excel example file

find-closest-values-return-adjacent-value.xlsx

Functions:

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 boolean

NSLog (@”Value of my BOOL = %@”, someBool ? @”YES” : @”NO”);

Excel Functions

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

zAware, add point to polyline, extend line, query filter, query nearest point

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

Output text files in Excel VBA

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