Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vectorize distance to ice #91

Open
mdsumner opened this issue Mar 12, 2019 · 4 comments
Open

vectorize distance to ice #91

mdsumner opened this issue Mar 12, 2019 · 4 comments

Comments

@mdsumner
Copy link
Member

Currently need to map over date:

brick(lapply(date, distance_to_ice_edge))

Also, would be good to extend to the equator ....

@ryanreisinger
Copy link

Would be great to extend to the equator!

@mdsumner
Copy link
Member Author

Can you give me a basic example to use?

@ryanreisinger
Copy link

Sure! This is the problem I have now: whales travelling south into the sea-ice zone.


xyt <- structure(list(
  lon = c(99.3166171432089, 98.9006788711366, 98.7734342687725, 
          98.5970674843324, 98.0611574257167, 97.5117793862567, 97.115718253683, 
          96.8045440765447, 96.3291281514872, 96.2452682329799, 96.192473088445, 
          95.9444400080036, 95.9792294071869, 95.5750888267137, 95.1552567210235, 
          94.802504087086, 94.4382210609254, 94.2946549732581, 94.0310140180168, 
          93.8302652886002, 93.1431956129429, 92.8570175475369, 92.6004124761808, 
          92.4737661919271, 91.9333055412449, 91.380075537651, 90.8595125602654, 
          89.8475906812392, 89.4786800255101, 89.7352972914864, 89.2970148907053, 
          88.9202492256703, 88.6684050579553, 88.5433885451453, 88.538937437444, 
          88.2412764688179, 87.8588650301417, 87.2707169400553, 86.7904657553943, 
          86.7531289199787, 86.5850736385147, 86.3741940505228, 86.3616841053408, 
          86.3073447323376, 86.056875858379, 85.6768340446887, 85.1656622131945, 
          84.8776414671666, 84.6148595298974, 84.0283874823069, 83.7328846473903, 
          83.5652520423449, 83.326401431793, 83.1172340345894, 82.5949124606782, 
          82.3060334807344, 82.1577114799507, 82.028819088581, 81.9254172841018, 
          81.7972072969593, 81.615574993369, 81.5765657345558, 81.6939418315358, 
          81.837126155696, 82.3576707843761, 82.6213020720442, 83.1219999309709, 
          83.3178183002322, 83.0157792544415, 82.5269906507323, 82.3897212544151, 
          82.0469782830114, 82.381988446536, 82.5337629530099, 82.4178803784107, 
          82.2221107929756, 82.1361794637854, 82.2985366712074, 82.5976994556258, 
          82.896342449068, 83.0195578153646, 83.1135674130003, 83.0457669137371, 
          82.8555345484884, 82.8677056963473, 82.841094614562, 82.8602448766026, 
          82.8982345780602, 82.9095255705501, 82.9618254881071, 83.0290558923207, 
          83.0075409380562, 83.0817158453829, 83.3168643933649, 83.3904487592127, 
          83.3735778851732, 83.48579063609, 83.5480156468833, 83.2490573562483, 
          83.3754240520699, 83.5975199781284, 83.0211214822505, 82.6640142297198, 
          82.7090987129266, 82.6882996335524, 82.5315218639909, 82.4886911715342, 
          82.7003084263923, 82.8208818404541, 82.4553712128668, 82.3570924451051, 
          82.055405960495, 81.94143034139, 82.1030943132353, 82.1022876444205, 
          81.9924358507366, 82.0414650975907, 81.9989352637006, 81.8865020825421, 
          81.805377308342, 81.8204150492594, 81.684670236859, 81.6351479658266, 
          81.5234793767464, 81.4788099383543, 81.4432504629339, 81.4452291377257, 
          81.4648109480265, 81.7003636890028, 81.7516607328081, 81.8432286142596, 
          82.0075625954745, 81.9622006983861, 81.9812009748188, 82.0585073185508, 
          82.0422397776864, 82.0401795235236, 82.0770103574498, 82.0643303689982, 
          82.0236325563822, 82.0611212215941, 82.3252993944852, 82.5975131948805, 
          82.2927482945762, 82.3185060459756, 82.4193343460334, 82.4303372062605, 
          82.4432974234011, 82.4961590395219, 82.4549947419492, 82.4616237140269, 
          82.5007521130228, 82.4848186136296, 82.1975499294718, 82.8565662114299, 
          83.1234131960996, 83.6220336426475, 84.189662354525, 83.9958777901836, 
          84.3005926010832, 84.3759715043574, 84.6806160847945, 84.7600898831291, 
          84.6733675704018, 84.5043071519713, 84.3270750663569, 84.2476447298694, 
          84.487560564602, 84.7324971283954, 84.9466236479681, 84.6824133249194, 
          84.7610260449235, 84.8111286452008, 84.8163518447433, 84.8386607487194),
  lat = c(-40.1643462881434, -40.5767765659038, -40.8887510507311, 
          -41.2429691260829, -41.530603422949, -41.7753285532371, -42.0415656243962, 
          -42.3989746852235, -42.7774683740758, -43.2555032284037, -43.7465275829557, 
          -44.2086425236062, -44.4408818043398, -44.853416673673, -45.1707509165582, 
          -45.4561119575987, -45.779270728594, -46.2027656886226, -46.5364299392321, 
          -46.8490044194933, -47.2603442565509, -47.7436305872154, -47.8415481112155, 
          -47.9277664167923, -48.0203159871438, -48.2508322330121, -48.5927180270493, 
          -49.0833855470376, -49.522155416504, -49.5742069478342, -49.9914484324109, 
          -50.4024625558176, -50.6334774131974, -50.8194306485765, -51.1418217147798, 
          -51.5363782162045, -51.8721757662291, -51.9798480800698, -52.095590819332, 
          -52.2600422919658, -52.4343824491742, -52.7003730400711, -52.9108702413557, 
          -53.061321219851, -53.312051619655, -53.588773654696, -53.8961132209695, 
          -54.4664413139291, -54.9650973122119, -55.4020404725729, -56.0606385825529, 
          -56.5561674920957, -57.0484076963751, -57.089060657796, -57.2012516500853, 
          -57.266203022012, -57.2654177020559, -57.3516402579212, -57.3517759997819, 
          -57.3215965991677, -57.2633015340204, -57.3683712581671, -57.4863490447301, 
          -57.5303647289997, -57.6400300013451, -57.6482305974866, -57.7028450748786, 
          -57.68787024465, -57.5735784451545, -57.5970746481903, -57.6574080344242, 
          -57.5450807589245, -57.5068766286443, -57.4822933392013, -57.4608256170587, 
          -57.4980679895923, -57.4470517265805, -57.3586514049966, -57.3250676562442, 
          -57.2883409327194, -57.2724329870987, -57.3731770928456, -57.5968345675968, 
          -57.7137908374794, -57.7013975963986, -57.6422001564433, -57.6250455553337, 
          -57.5808376763157, -57.5829239624905, -57.6030085676552, -57.6146876774689, 
          -57.6925418207769, -57.7096101117051, -57.8150488864088, -57.8507876123508, 
          -57.9246539479913, -57.9568780885839, -57.9769691064554, -57.9368607338014, 
          -57.8765015656012, -57.9037402883617, -57.9574580074166, -58.0439908839924, 
          -57.9317482761217, -57.9645603326633, -57.9640127850538, -57.9915963491445, 
          -58.1323587014958, -58.0940213066166, -58.0043713183522, -57.9273027975307, 
          -57.8874041021304, -57.8568209108724, -57.7772041014742, -57.761358630179, 
          -57.7049157288061, -57.7601297146184, -57.7620180619629, -57.7440104992019, 
          -57.7509925146755, -57.7140608262591, -57.7109507299254, -57.7060056570482, 
          -57.7072714391195, -57.7110455055468, -57.7243988690385, -57.7725672241605, 
          -57.8259401067343, -57.8931518752876, -57.862492479695, -57.9919512497794, 
          -58.2422504541101, -58.5112887060364, -58.6668394879133, -58.9163760291794, 
          -59.0745353577245, -59.0633279316381, -59.1212373332875, -59.1001850878302, 
          -59.119072063167, -59.117285967248, -59.3469117599329, -59.6244478914297, 
          -59.8967022909758, -60.0416210987414, -60.1308724434433, -60.2098376720799, 
          -60.3637669553169, -60.4158095293324, -60.4793139962445, -60.5995304537219, 
          -60.6868317903838, -60.9032107308552, -61.1096073542978, -61.4206063202297, 
          -61.6460222698432, -61.9457479783173, -61.9780268319033, -62.0261273400929, 
          -62.2891759300446, -62.5049222606857, -62.6556565961293, -62.757136952988, 
          -62.8039083002729, -62.708124312593, -62.651801188437, -62.6147026661011, 
          -62.8518808251185, -62.9783247397751, -63.1861285528147, -63.3011336260239, 
          -63.297398453374, -63.2690100364021, -63.2031913725283, -63.2180615352877),
  date = structure(c(1477062000, 1477105200, 1477148400, 1477191600, 
                     1477234800, 1477278000, 1477321200, 1477364400, 1477407600, 1477450800, 
                     1477494000, 1477537200, 1477580400, 1477623600, 1477666800, 1477710000, 
                     1477753200, 1477796400, 1477839600, 1477882800, 1477926000, 1477969200, 
                     1478012400, 1478055600, 1478098800, 1478142000, 1478185200, 1478228400, 
                     1478271600, 1478314800, 1478358000, 1478401200, 1478444400, 1478487600, 
                     1478530800, 1478574000, 1478617200, 1478660400, 1478703600, 1478746800, 
                     1478790000, 1478833200, 1478876400, 1478919600, 1478962800, 1479006000, 
                     1479049200, 1479092400, 1479135600, 1479178800, 1479222000, 1479265200, 
                     1479308400, 1479351600, 1479394800, 1479438000, 1479481200, 1479524400, 
                     1479567600, 1479610800, 1479654000, 1479697200, 1479740400, 1479783600, 
                     1479826800, 1479870000, 1479913200, 1479956400, 1479999600, 1480042800, 
                     1480086000, 1480129200, 1480172400, 1480215600, 1480258800, 1480302000, 
                     1480345200, 1480388400, 1480431600, 1480474800, 1480518000, 1480561200, 
                     1480604400, 1480647600, 1480690800, 1480734000, 1480777200, 1480820400, 
                     1480863600, 1480906800, 1480950000, 1480993200, 1481036400, 1481079600, 
                     1481122800, 1481166000, 1481209200, 1481252400, 1481295600, 1481338800, 
                     1481382000, 1481425200, 1481468400, 1481511600, 1481554800, 1481598000, 
                     1481641200, 1481684400, 1481727600, 1481770800, 1481814000, 1481857200, 
                     1481900400, 1481943600, 1481986800, 1482030000, 1482073200, 1482116400, 
                     1482159600, 1482202800, 1482246000, 1482289200, 1482332400, 1482375600, 
                     1482418800, 1482462000, 1482505200, 1482548400, 1482591600, 1482634800, 
                     1482678000, 1482721200, 1482764400, 1482807600, 1482850800, 1482894000, 
                     1482937200, 1482980400, 1483023600, 1483066800, 1483110000, 1483153200, 
                     1483196400, 1483239600, 1483282800, 1483326000, 1483369200, 1483412400, 
                     1483455600, 1483498800, 1483542000, 1483585200, 1483628400, 1483671600, 
                     1483714800, 1483758000, 1483801200, 1483844400, 1483887600, 1483930800, 
                     1483974000, 1484017200, 1484060400, 1484103600, 1484146800, 1484190000, 
                     1484233200, 1484276400, 1484319600, 1484362800, 1484406000, 1484449200, 
                     1484492400, 1484535600, 1484578800),
                   class = c("POSIXct", "POSIXt"), tzone = "GMT")),
  row.names = 1:175, class = "data.frame")

# Extract distance to ice edge
xyt$ice <- raadtools::extract(x = distance_to_ice_edge,
                              y = xyt)

# Map the locations on the sea-ice raster (both in WGS84)
ice <- distance_to_ice_edge("2015-01-10")
ice84 <- projectRaster(ice, crs = "+proj=longlat +datum=WGS84 +no_defs")
plot(ice84)
points(xyt$lon, xyt$lat)

@mdsumner
Copy link
Member Author

relate to #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants