Re: [R-sig-Geo] Error in anyDuplicated.default(coords) message with trinb
Jeff, ?tri2nb suggests you to try tri2nb(coordinates(data.sp)) On 07/07/2011 03:52 PM, Stratford, Jeffrey wrote: > Hi everyone, > > > > I'm attempting to do some spatial analyses with a relatively simple data > set and I'm running into some issues. Here's my code: > > > > sosp09 <- read.csv("f:\\sosp\\2009\\sosp09.means.csv", header=T) > > sp.point <- cbind(sosp09$x, sosp09$y) > > colnames(sp.point) <- c("LONG","LAT") > > # Projection: UTM Zone 17 > > proj <- CRS("+proj=utm +zone=18 +datum=WGS84") > > # Create spatial object > > data.sp <- SpatialPointsDataFrame(coords=sp.point, data=sosp09, > proj4string=proj) > > ## Bounding box of data points > > bbox(data.sp) > > #build neighborhood > > sosp.neigh <- tri2nb(data.sp) > > > > And, with the last step, I get > > > > Error in anyDuplicated.default(coords) : > > anyDuplicated() applies only to vectors > > > > I went through and removed duplicated rows by averaging the responses > and I still get this message. I also removed via rm() all the objected > from the original analysis and I still get this message. Any ideas > what's going on? > > > > Thanks, > > > > Jeff > > > > The data: > > > > > > new("SpatialPointsDataFrame" > > , data = structure(list(band = c(6467L, 6483L, 6466L, 6465L, 6463L, > 6462L, > > 6498L, 6443L, 6496L, 6495L, 6459L, NA, 6458L, 6491L, 6446L, 6464L, > > NA, 6473L, 6444L, 6457L, 6468L, NA, 6485L, 6474L, 6445L, 6486L, > > 6488L, 6472L, 6493L, 6492L, 6471L, 6449L, 6453L, 6460L, 6482L > > ), site = structure(c(19L, 26L, 18L, 17L, 15L, 14L, 35L, 1L, > > 34L, 33L, 12L, 8L, 11L, 30L, 4L, 16L, 5L, 23L, 2L, 10L, 20L, > > 9L, 27L, 24L, 3L, 28L, 29L, 22L, 32L, 31L, 21L, 6L, 7L, 13L, > > 25L), .Label = c("SOSP0901", "SOSP0902", "SOSP0903", "SOSP0904", > > "SOSP0905", "SOSP0906", "SOSP0908", "SOSP0909", "SOSP0910", "sosp0911", > > "sosp0912", "sosp0913", "sosp0914", "SOSP0915", "SOSP0916", "SOSP0917", > > "SOSP0918", "SOSP0919", "SOSP0920", "SOSP0921", "SOSP0925", "SOSP0926", > > "SOSP0927", "SOSP0928", "Sosp0934", "Sosp0935", "Sosp0936", "Sosp0937", > > "Sosp0938", "Sosp0940", "Sosp0941", "Sosp0942", "Sosp0943", "Sosp0944", > > "Sosp0946"), class = "factor"), sex = structure(c(1L, 1L, 1L, > > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L > > ), .Label = "M", class = "factor"), age = structure(c(1L, 1L, > > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > > 1L), .Label = "AHY", class = "factor"), wing = c(66, 62, 66, > > 65, 65, 64.5, 66, 69, 64.5, 67.5, 66, 66.5, 68, 67, 66, 67, 64.5, > > 68, 65, 65, 66, 65.5, 65, 66, 64, 65, 65, 66, 66, 63, 67, 66, > > 66, 65, 64), tail = c(69, 67, 69, 66, 67, 65, 66, 68, 64, 67.5, > > 66, 66, 67, 67, 67, 70, 69, 64, 67, 69, 68, 65.5, 66, 67, 65, > > 66, 66, 68, 71, 55, 72, 62, 70, 70, 66), bill = c(9, 9.7, 9.6, > > 9.5, 9.6, 8.5, 9.2, 9.5, 8.4, 9.2, 9.9, 8.8, 8.8, 9.2, 8.6, 9.6, > > 9.15, 9.7, 9.7, 8.7, 8.9, 9.45, 8.8, 9.1, 9.2, 9.2, 9.1, 8.9, > > 9.6, 8.7, 9.2, 8.8, 9.2, 9, 9.3), tarsus = c(21.6, 20.6, 20.9, > > 21.8, 20.9, 19.6, 22, 21.5, 21.7, 21.3, 22.1, 21.15, 19.9, 22.4, > > 22, 20.1, 21.85, 21.6, 20.9, 21.5, 22.4, 21.5, 21.3, 21.2, 21.5, > > 20.6, 21.4, 21.4, 21.4, 21.7, 21.4, 21.1, 20.6, 20.1, 22.2), > > mass = c(20.8, 20.6, 21.1, 22.3, NA, 16.7, 23, 23.2, 20.7, > > 20.9, 27.3, 21.1, 21.4, 24.3, 23.2, 21.7, 22, 21, NA, 20.1, > > 20.5, 21.4, 20.5, 23.3, 21.5, 20.5, 20.8, 21, 21.3, 20.3, > > 20.4, 21, 22.9, 19.7, 21.5), x = c(1647222L, 1648242L, 1648272L, > > 1648422L, 1651242L, 1652472L, 1652472L, 1653042L, 1653282L, > > 1653372L, 1654092L, 1654212L, 1654362L, 1655082L, 1657032L, > > 1657212L, 1657272L, 1657932L, 1658292L, 1658412L, 1658772L, > > 1659072L, 1659192L, 1659342L, 1659702L, 1659762L, 1659912L, > > 1660692L, 1660872L, 1661022L, 1661082L, 1662042L, 1662192L, > > 1663362L, 1663512L), y = c(2207359L, 2206909L, 2207479L, > > 2202859L, 2203219L, 2204599L, 2198299L, 2194849L, 2202889L, > > 2208229L, 2199469L, 2199649L, 2199769L, 2202589L, 2198089L, > > 2201449L, 2198029L, 2201209L, 2202529L, 2201989L, 2203549L, > > 2202529L, 2203519L, 2201209L, 2202499L, 2204179L, 2203459L, > > 2200939L, 2208469L, 2208709L, 2201419L, 2204299L, 2204989L, > > 2206339L, 2202619L), urban1 = c(0.1724138, 0.2068966, 0.06896552, > > 0.2413793, 0.5172413, 0.34482762, 0.55172422, 0.138, 0.06896552, > > 0.03448276, 0.06896552, 1, 0.9655172, 0.4827586, 0.966, 0.8965516, > > 0.31, 1, 1, 0.9996, 0.79310346, 1, 1.0012, 0.9992, > > 1, 0.9998, 1, 0.999, 0.48275866, 1, 1.001, 1, > > 1, 1, 0.7241379), urban2 = c(0.2214765, 0.12751683, 0.18791945, > > 0.09395973, 0.24832219, 0.1946309, 0.32885906
[R-sig-Geo] Error in anyDuplicated.default(coords) message with trinb
Hi everyone, I'm attempting to do some spatial analyses with a relatively simple data set and I'm running into some issues. Here's my code: sosp09 <- read.csv("f:\\sosp\\2009\\sosp09.means.csv", header=T) sp.point <- cbind(sosp09$x, sosp09$y) colnames(sp.point) <- c("LONG","LAT") # Projection: UTM Zone 17 proj <- CRS("+proj=utm +zone=18 +datum=WGS84") # Create spatial object data.sp <- SpatialPointsDataFrame(coords=sp.point, data=sosp09, proj4string=proj) ## Bounding box of data points bbox(data.sp) #build neighborhood sosp.neigh <- tri2nb(data.sp) And, with the last step, I get Error in anyDuplicated.default(coords) : anyDuplicated() applies only to vectors I went through and removed duplicated rows by averaging the responses and I still get this message. I also removed via rm() all the objected from the original analysis and I still get this message. Any ideas what's going on? Thanks, Jeff The data: new("SpatialPointsDataFrame" , data = structure(list(band = c(6467L, 6483L, 6466L, 6465L, 6463L, 6462L, 6498L, 6443L, 6496L, 6495L, 6459L, NA, 6458L, 6491L, 6446L, 6464L, NA, 6473L, 6444L, 6457L, 6468L, NA, 6485L, 6474L, 6445L, 6486L, 6488L, 6472L, 6493L, 6492L, 6471L, 6449L, 6453L, 6460L, 6482L ), site = structure(c(19L, 26L, 18L, 17L, 15L, 14L, 35L, 1L, 34L, 33L, 12L, 8L, 11L, 30L, 4L, 16L, 5L, 23L, 2L, 10L, 20L, 9L, 27L, 24L, 3L, 28L, 29L, 22L, 32L, 31L, 21L, 6L, 7L, 13L, 25L), .Label = c("SOSP0901", "SOSP0902", "SOSP0903", "SOSP0904", "SOSP0905", "SOSP0906", "SOSP0908", "SOSP0909", "SOSP0910", "sosp0911", "sosp0912", "sosp0913", "sosp0914", "SOSP0915", "SOSP0916", "SOSP0917", "SOSP0918", "SOSP0919", "SOSP0920", "SOSP0921", "SOSP0925", "SOSP0926", "SOSP0927", "SOSP0928", "Sosp0934", "Sosp0935", "Sosp0936", "Sosp0937", "Sosp0938", "Sosp0940", "Sosp0941", "Sosp0942", "Sosp0943", "Sosp0944", "Sosp0946"), class = "factor"), sex = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = "M", class = "factor"), age = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "AHY", class = "factor"), wing = c(66, 62, 66, 65, 65, 64.5, 66, 69, 64.5, 67.5, 66, 66.5, 68, 67, 66, 67, 64.5, 68, 65, 65, 66, 65.5, 65, 66, 64, 65, 65, 66, 66, 63, 67, 66, 66, 65, 64), tail = c(69, 67, 69, 66, 67, 65, 66, 68, 64, 67.5, 66, 66, 67, 67, 67, 70, 69, 64, 67, 69, 68, 65.5, 66, 67, 65, 66, 66, 68, 71, 55, 72, 62, 70, 70, 66), bill = c(9, 9.7, 9.6, 9.5, 9.6, 8.5, 9.2, 9.5, 8.4, 9.2, 9.9, 8.8, 8.8, 9.2, 8.6, 9.6, 9.15, 9.7, 9.7, 8.7, 8.9, 9.45, 8.8, 9.1, 9.2, 9.2, 9.1, 8.9, 9.6, 8.7, 9.2, 8.8, 9.2, 9, 9.3), tarsus = c(21.6, 20.6, 20.9, 21.8, 20.9, 19.6, 22, 21.5, 21.7, 21.3, 22.1, 21.15, 19.9, 22.4, 22, 20.1, 21.85, 21.6, 20.9, 21.5, 22.4, 21.5, 21.3, 21.2, 21.5, 20.6, 21.4, 21.4, 21.4, 21.7, 21.4, 21.1, 20.6, 20.1, 22.2), mass = c(20.8, 20.6, 21.1, 22.3, NA, 16.7, 23, 23.2, 20.7, 20.9, 27.3, 21.1, 21.4, 24.3, 23.2, 21.7, 22, 21, NA, 20.1, 20.5, 21.4, 20.5, 23.3, 21.5, 20.5, 20.8, 21, 21.3, 20.3, 20.4, 21, 22.9, 19.7, 21.5), x = c(1647222L, 1648242L, 1648272L, 1648422L, 1651242L, 1652472L, 1652472L, 1653042L, 1653282L, 1653372L, 1654092L, 1654212L, 1654362L, 1655082L, 1657032L, 1657212L, 1657272L, 1657932L, 1658292L, 1658412L, 1658772L, 1659072L, 1659192L, 1659342L, 1659702L, 1659762L, 1659912L, 1660692L, 1660872L, 1661022L, 1661082L, 1662042L, 1662192L, 1663362L, 1663512L), y = c(2207359L, 2206909L, 2207479L, 2202859L, 2203219L, 2204599L, 2198299L, 2194849L, 2202889L, 2208229L, 2199469L, 2199649L, 2199769L, 2202589L, 2198089L, 2201449L, 2198029L, 2201209L, 2202529L, 2201989L, 2203549L, 2202529L, 2203519L, 2201209L, 2202499L, 2204179L, 2203459L, 2200939L, 2208469L, 2208709L, 2201419L, 2204299L, 2204989L, 2206339L, 2202619L), urban1 = c(0.1724138, 0.2068966, 0.06896552, 0.2413793, 0.5172413, 0.34482762, 0.55172422, 0.138, 0.06896552, 0.03448276, 0.06896552, 1, 0.9655172, 0.4827586, 0.966, 0.8965516, 0.31, 1, 1, 0.9996, 0.79310346, 1, 1.0012, 0.9992, 1, 0.9998, 1, 0.999, 0.48275866, 1, 1.001, 1, 1, 1, 0.7241379), urban2 = c(0.2214765, 0.12751683, 0.18791945, 0.09395973, 0.24832219, 0.1946309, 0.32885906, 0.315, 0.08724833, 0.05369128, 0.3959732, 0.583892609, 0.77181212, 0.42281877, 0.758, 0.6577181, 0.564, 1.0014, 0.993, 0.9997, 0.63758395, 0.7919463, 1.0003, 1, 1, 1.001, 0.73154363, 1.0004, 0.59731537, 0.8993289, 0.97315443, 1, 0.913, 1.0001, 0.75838925), urbank = c(0.0976826, 0.210325588, 0.360516315, 0.063361691, 0.060721623, 0.23995307, 0.18979175, 0.275, 0.065708423, 0.1589909, 0.33294