Skip to content

Instantly share code, notes, and snippets.

@lessermatter
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lessermatter/0284be117a19620750aa to your computer and use it in GitHub Desktop.
Save lessermatter/0284be117a19620750aa to your computer and use it in GitHub Desktop.
Replicable example
library(geospacom)
library(spacom)
distmatrix <- structure(c(0, 7664044.15560822, 2719219.40604131, 5263154.940185,
4837835.25317203, 5918398.77060375, 6675657.66195553, 4423088.65850676,
7664044.15560822, 0, 7246904.19057272, 2402628.84742028, 2889488.01888745,
8503188.42404701, 9161236.201234, 7742639.45159703, 2719219.40604131,
7246904.19057272, 0, 5035601.93502931, 4449036.45396936, 3221266.92021088,
4002513.07765417, 1715949.37532841, 5263154.940185, 2402628.84742028,
5035601.93502931, 0, 601850.696980749, 6864453.11774937, 7613731.5320775,
5832429.39513412, 4837835.25317203, 2889488.01888745, 4449036.45396936,
601850.696980749, 0, 6281935.94216, 7038666.11590439, 5232188.90549292,
5918398.77060375, 8503188.42404701, 3221266.92021088, 6864453.11774937,
6281935.94216, 0, 815946.488987536, 1506170.61748608, 6675657.66195553,
9161236.201234, 4002513.07765417, 7613731.5320775, 7038666.11590439,
815946.488987536, 0, 2297930.89100467, 4423088.65850676, 7742639.45159703,
1715949.37532841, 5832429.39513412, 5232188.90549292, 1506170.61748608,
2297930.89100467, 0), .Dim = c(8L, 8L), .Dimnames = list(c("Arcisate",
"Alagna", "Alserio", "Abbiategrasso", "Albairate", "AlmŠ", "Alzano Lombardo",
"Airuno"), c("Arcisate", "Alagna", "Alserio", "Abbiategrasso",
"Albairate", "AlmŠ", "Alzano Lombardo", "Airuno")))
weights <- WeightMatrix(distmatrix, 5000000)
is.numeric(distmatrix)
# TRUE
is.numeric(weights)
# FALSE
head(weights)
# 6 x 8 sparse Matrix of class "dgCMatrix"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment