An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130913/dfa89ab4/attachment.pl>
KernelUD calculation - coordinates type / transformation from lat/long
3 messages · Ben, zuzana zajkova
3 days later
Hi Zuzana,
try this:
read in your data as 'dat'
Karea_xyUTM<- kernel.area(dat, id=rep('1', nrow(dat)))
20 0.001132550
25 0.001470329
30 0.001847845
35 0.002265101
40 0.002722095
45 0.003238697
50 0.003834776
55 0.004510333
60 0.005285235
65 0.006139616
70 0.007073473
75 0.008146416
80 0.009358443
85 0.010769164
90 0.012656748
95 0.015617275
# then
npoints = nrow(dat)
# convert to SpatialPoints
dat = SpatialPoints(dat, proj4string=CRS("+proj=longlat +datum=WGS84"))
#convert to UTM, be sure to include the zone. very important. This may
be worng for several of your points since the area is so large.
datUTM<- spTransform(dat, CRS("+proj=utm +zone=24 +ellps=WGS84
+datum=WGS84 +units=m +no_defs"))
# do the area calculation using the new coordinates only. Be sure to
include names as a character. Leave out the 'h=' argument. That is where
your error was occurring.
Karea_xyUTM<- kernel.area(as.data.frame(datUTM), id=rep('1', npoints),
grid=500, unin ="m", unout = "km2")
20 135351.2
25 175756.6
30 219788.8
35 268222.6
40 322081.0
45 382727.9
50 452100.7
55 532989.0
60 625501.5
65 727065.3
70 840175.7
75 967684.5
80 1111777.1
85 1282512.1
90 1506315.1
95 1861067.6
This website is helpful
http://r.789695.n4.nabble.com/Converiting-longitude-latitude-to-utm-td4632377.html
Cheers,
Ben
On 9/13/2013 10:58 AM, zuzana zajkova wrote:
Hi, I would like to calculate kernel areas using kernel.area function from adehabitat package. My original coordintes are in latidude/longitude. I suppose that as an input for the function the coordinates should be in other fomat - I assume it is UTM coordinates (seeing the example in help, I haven't found more information about it...). Therefore I converted the lat/long coordinates and calculated the area for various kernels. The problem is that it gives me the same area for all levels... ## sample of my data
dput(xy)structure(list(long = c(-32.73, -32.12, -31.39, -31.02, -32.16,
-32.17, -32.06, -32.32, -32.58, -33.22, -32.85, -33.36, -33.37,
-33.5, -34.76, -35.51, -34.39, -33.27, -32.65, -32.66, -34.41,
-35.79, -34.29, -35.04, -34.67, -33.92, -34.54, -35.79, -34.66,
-34.66, -35.91, -35.78, -38.15, -38.15, -36.89, -35.76, -35.75,
-35.75, -35.62, -37.73, -36.72, -35.84, -36.71, -37.82, -37.06,
-36.05, -36.91, -37.65, -37.51, -37.87, -37.36, -36.97, -38.08,
-38.07, -37.05, -35.91, -35.14, -36.5, -36.48, -36.59, -36.82,
-37.55, -36.16, -36.39, -37.49, -35.35, -35.83, -36.93, -36.66,
-36.64, -36.49, -36.47, -36.45, -36.42, -36.27, -34.75, -34.85,
-35.08, -33.8, -35.28, -35.25, -33.73, -33.7, -34.93, -35.28,
-34, -33.6, -33.57, -33.55, -35.89, -35.99, -36.09, -36.56, -36.54,
-37.13, -38.11, -39.2, -38.93, -38.53, -37.62, -37.35, -37.07,
-36.54, -36.89, -36.74, -37.43, -37.78, -36, -36.1, -35.7, -35.93,
-37.9, -37.5, -35.85, -37.07, -38.8, -38.77, -38.62, -37.72,
-38.82, -38.67, -36.65, -36.37, -35.6, -35.7, -35.43, -35.66,
-36.38, -36.86, -36.84, -34.95, -34.92, -36.65, -36.63, -36.24,
-36.34, -34.95, -35.06, -36.16, -36.52, -36.01, -35.86, -35.47,
-35.21, -34.94, -35.8, -34.54, -34.78, -36.26, -35, -34.74, -35.1,
-34.72, -35.33, -35.32, -35.44, -35.05, -34.67, -35.16, -35.03,
-32.77, -33.02, -31.76, -32.01, -34.38, -34.5, -33.25, -32.37,
-31.37, -31.24, -32.12, -33.12, -33.12, -33.12, -33.62, -32.13,
-31.5, -31.88, -31.01, -30.89, -30.4, -30.53, -31.54, -28.66,
-29.01, -28.87, -29.35, -29.33, -29.31, -30.16, -30.64, -29.74,
-29.47, -29.95, -29.92, -29.53, -29.88, -30.98, -30.58, -31.18
), complat = c(23.04, 20.44, 20.95, 21.12, 18.51, 16.92, 17.13,
16.98, 16.83, 17.73, 18.6, 19.77, 20.26, 20.43, 18.35, 17.56,
20.29, 20.45, 19.38, 19.86, 17.24, 16.8, 20.36, 22.54, 23.78,
23.64, 21.56, 21.99, 24.82, 25.71, 24.02, 22.57, 19.42, 17.01,
18.64, 18.82, 17.01, 16.92, 17.11, 18.97, 22.57, 22.72, 20.29,
20.46, 22.91, 22.31, 19.92, 19.84, 21.03, 21.19, 22.1, 22.26,
20.44, 19.35, 20.29, 20.46, 19.89, 21.54, 22.89, 23.05, 22.51,
22.9, 25.31, 26.11, 25.39, 22.87, 19.99, 20.18, 22, 21.95, 22.13,
22.07, 22.02, 21.98, 22.16, 21.2, 19.04, 19.01, 20.85, 23.06,
24.33, 23.43, 21.62, 22.48, 23.55, 22.21, 21.06, 21.48, 21.46,
22.99, 25.3, 25.48, 25.05, 24.62, 23.98, 24.39, 24.16, 23.31,
23.08, 22.86, 22.42, 22.42, 22.42, 23.08, 23.72, 17.87, 16.19,
18.6, 20.23, 20.48, 20.94, 19.12, 17.47, 18.68, 21.02, 20.59,
19.22, 19.48, 18.8, 16.65, 15.43, 17.92, 19.39, 19.89, 20.63,
21.13, 21.17, 20.75, 20.79, 21.3, 19.7, 17.8, 19.32, 21.27, 21.09,
20.43, 19.28, 17.59, 18.4, 19.7, 18.77, 18.58, 18.38, 18.45,
18.51, 16.76, 15.22, 13.08, 14.8, 18.08, 19.19, 18.49, 17.77,
16.5, 16.02, 15.82, 15.61, 15.41, 16.61, 17.52, 15.35, 11.89,
10.73, 8.28, 11.17, 13.99, 12.85, 12, 12.07, 11.2, 12.23, 12.31,
11.1, 11.18, 11.91, 14.56, 15.61, 14.76, 13.24, 12.34, 11.75,
10.81, 12.28, 13, 13.23, 13.99, 14.48, 14.96, 14.91, 13.55, 13.51,
14.79, 15.78, 14.71, 14.16, 14.38, 15.12, 14.32, 12.99, 11.64
)), .Names = c("long", "complat"), row.names = c("48", "49",
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60",
"61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71",
"72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82",
"83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93",
"94", "95", "96", "97", "98", "99", "100", "101", "102", "103",
"104", "105", "106", "107", "108", "109", "110", "111", "112",
"113", "114", "115", "116", "117", "118", "119", "120", "121",
"122", "123", "124", "125", "126", "127", "128", "129", "130",
"131", "132", "133", "134", "135", "136", "137", "138", "139",
"140", "141", "142", "143", "144", "145", "146", "147", "148",
"149", "150", "151", "152", "153", "154", "155", "156", "157",
"158", "159", "160", "161", "162", "163", "164", "165", "166",
"167", "168", "169", "170", "171", "172", "173", "174", "175",
"176", "177", "178", "179", "180", "181", "182", "183", "184",
"185", "186", "187", "188", "189", "190", "191", "192", "193",
"194", "195", "196", "197", "198", "199", "200", "201", "202",
"203", "204", "205", "206", "207", "208", "209", "210", "211",
"212", "213", "214", "215", "216", "217", "218", "219", "220",
"221", "222", "223", "224", "225", "226", "227", "228", "229",
"230", "11310", "11410", "1154", "1161", "1171", "1181", "1191",
"1201", "1211", "1221", "1231", "1241", "1251", "1261", "1271",
"1281", "1291"), class = "data.frame")
head(xy) long complat
48 -32.73 23.04
49 -32.12 20.44
50 -31.39 20.95
51 -31.02 21.12
52 -32.16 18.51
53 -32.17 16.92
## create a matrix
xy<- cbind(xy$long, xy$complat)
## convert to UTM coordinates
## my data are widely spread over the central Atlantic
## Ocean, so I think it is not possible to define the "zone"
## needs to be as dataframe for kernelarea
xyUTM<-as.data.frame(project(xy, "+proj=utm ellps=WGS84"))
## calculate kernelarea
kernLevels <- seq(5,95, by = 5)
Karea_xyUTM<- kernel.area(xyUTM,id=NULL, h=1.8, grid=500,
levels = kernLevels,
unin ="m",
unout = "km2")
## the results...
Karea_xyUTM 1
5 4990969904
10 4990969904
15 4990969904
20 4990969904
25 4990969904
30 4990969904
35 4990969904
40 4990969904
45 4990969904
50 4990969904
55 4990969904
60 4990969904
65 4990969904
70 4990969904
75 4990969904
80 4990969904
85 4990969904
90 4990969904
95 4990969904
I wuld appreciate a lot if anyone could check where the error is coming
from.
Thank you,
Zuzana
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
================================================== Benjamin Galuardi - PhD Student NMFS-Seagrant Population Dynamics Fellow SMAST, UMass Dartmouth - T: 978 283 0368
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130917/f24c069f/attachment.pl>