{"id":3426,"date":"2021-10-28T12:29:51","date_gmt":"2021-10-27T23:29:51","guid":{"rendered":"http:\/\/blogs.lincoln.ac.nz\/gis\/?p=3426"},"modified":"2023-05-07T02:49:37","modified_gmt":"2023-05-07T02:49:37","slug":"near-and-deer","status":"publish","type":"post","link":"https:\/\/blogs.lincoln.ac.nz\/gis\/near-and-deer\/","title":{"rendered":"Near and Deer Ones"},"content":{"rendered":"<p><em>In this post we look at addressing a spatial problem, coming up with an approach and implementing the solution.\u00a0 (Spoiler alert &#8211; it worked, but not as it was supposed to.)\u00a0<\/em><\/p>\n<p>We often get emails here at GIS Central asking for a bit of assistance with things spatial.\u00a0 One never knows what will come through the Inbox and I&#8217;m almost always up for a challenge.\u00a0 Why, just the other day we got this:<\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: terminal, monaco, monospace;font-size: 12pt\">&#8220;Hi Crile,<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: terminal, monaco, monospace;font-size: 12pt\">I am looking for assistance with ArcGIS and was wondering if you may know a thing or two which could help me.&#8221;<\/span><\/p>\n<p><em>(Ed. They always start off so nice&#8230;)<\/em><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: terminal, monaco, monospace;font-size: 12pt\">&#8220;I have 10 individuals with 50 days\u2019 worth of hourly locations (some data points will be missing.)<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: terminal, monaco, monospace;font-size: 12pt\">I want to split the data for each individual into 2 day sliding windows, e.g day 1&amp;2, 2&amp;3, 3&amp;4 \u2026 etc.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: terminal, monaco, monospace;font-size: 12pt\">For each two day window, I want to calculate the distance between each location and the first location recorded in that window.<\/span><\/p>\n<p style=\"padding-left: 30px\"><span style=\"font-family: terminal, monaco, monospace;font-size: 12pt\">Do you know of possible steps in ArcGIS I might undertake to achieve this?&#8221;<\/span><\/p>\n<p>We always aim to please and on the face of it, this certainly sounded feasible (these individuals are deer, by the way).\u00a0 With the idea of &#8220;<a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/the-best-laid-plans\/\" target=\"_blank\" rel=\"noopener noreferrer\">beginning with the end in mind<\/a>&#8220;, I began formulating an approach.\u00a0 At this point I think the main output will be a table (CSV or Excel) with a column of distances away from one point, broken down into these sliding time windows.\u00a0 We&#8217;re talking about distances between dear locations so the <a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/latest\/tool-reference\/analysis\/near.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Near<\/a> tool comes to mind immediately &#8211; that&#8217;s exactly what it&#8217;s designed to do.\u00a0 I&#8217;m also anticipating that I\u00a0may have to think about how to structure the data to do this most efficiently.\u00a0 With 10 animals and 50 days worth of data I&#8217;m already beginning to wonder if this is a manual job or if I&#8217;ll need\/want to automate it somehow (either with <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/flow-diagrams-that-work\/\" target=\"_blank\" rel=\"noopener noreferrer\">ModelBuilder<\/a> or <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/sticking-to-the-python-script\/\" target=\"_blank\" rel=\"noopener noreferrer\">Python<\/a>).<\/p>\n<p>With a very rough plan in mind, the next thing might be to have a look at the data &#8211; so I asked for something to work with and was sent a CSV file of the data:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/SS.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3430\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/SS.jpg\" alt=\"\" width=\"555\" height=\"426\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/SS.jpg 555w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/SS-300x230.jpg 300w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/a><\/p>\n<p>A few things to notice about these data:<\/p>\n<ul>\n<li>1,035 points in all covering 50 days worth of data collection &#8211; time readings are not regular<\/li>\n<li>The Latitude and Longitude columns are critical &#8211; they will allow us to map the points<\/li>\n<li>BUT &#8211; being latitude and longitude, distances measured from these data will be in degrees of arc &#8211; very small numbers at this scale and not easy to work with as &#8220;on the ground&#8221; distances.\u00a0 I&#8217;ll need to project these data to NZTM to get some decent distances in metres<\/li>\n<li>Dates and Times are present BUT they are in <a href=\"https:\/\/www.timeanddate.com\/time\/aboututc.html\" target=\"_blank\" rel=\"noopener noreferrer\">UTC<\/a> (the successor to Greenwich Mean Time) &#8211; does that matter?\u00a0 I&#8217;ll need to ask.\u00a0 Depending on the time of year, NZ is either 12 or 13 hours ahead of UTC<\/li>\n<\/ul>\n<p>So let&#8217;s get these points on the map using Display X Y Data (data shown have already been projected to NZTM):<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3431\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap.jpg\" alt=\"\" width=\"1624\" height=\"879\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap.jpg 1624w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap-300x162.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap-1024x554.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap-768x416.jpg 768w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PointsOnMap-1536x831.jpg 1536w\" sizes=\"auto, (max-width: 1624px) 100vw, 1624px\" \/><\/a><\/p>\n<p>As a first note, this deer (henceforth known as DeerA to protect the innocent) was released at Glenorchy at the top of Lake Wakatipu and very quick hightailed it (as deer do) up into the Beans Burn river valley, covering around 35 k in five hours!<\/p>\n<p>Next we&#8217;ve got to come up with a workflow that works &#8211; manually first to make sure it works and then we can think about automating it.\u00a0 I know that Near is the likely tool, so let&#8217;s look at how to set that one up:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Near.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3432\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Near.jpg\" alt=\"\" width=\"293\" height=\"428\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Near.jpg 293w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Near-205x300.jpg 205w\" sizes=\"auto, (max-width: 293px) 100vw, 293px\" \/><\/a><\/p>\n<p>This tool needs some Input Features (what we&#8217;re finding the distance <em>from<\/em>) and Near Features (what we&#8217;re finding the distance <em>to &#8211;\u00a0<\/em>though it is the same in both directions).\u00a0 I can limit the search radius, request the Location (x and y coordinates of the near feature), the angle to it, and either use planar (flat) or geodesic (along the earth&#8217;s curved surface at great distances).\u00a0 Really important thing to know about this tool is that it doesn&#8217;t create a new output layer.\u00a0 Instead, it adds two new fields to the Input Features layer &#8211; one for the ID of the nearest feature (NEAR_ID) and another for the straight-line distance to that feature (NEAR_DIST).\u00a0 These are the default values &#8211; I can give them new names in the Field Name window if I like.<\/p>\n<p>We can control what features get used for Near by selecting features &#8211; this is useful as I need to find the distance from a single point for a collection of points in one of the sliding windows.\u00a0 In other words, I might select one point as the start of a 2-day window and then all the points that occur within that 2-day window.\u00a0 Another thing &#8211; do the Input and Near Feature layers need to be different?\u00a0 i.e. can I use the same layer for both?\u00a0 Happily, the answer is yes.\u00a0 I&#8217;ll play a little trick on Pro by having two copies of the same layer on my\u00a0 map:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/TMTry.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3433\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/TMTry.jpg\" alt=\"\" width=\"1428\" height=\"674\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/TMTry.jpg 1428w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/TMTry-300x142.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/TMTry-1024x483.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/TMTry-768x362.jpg 768w\" sizes=\"auto, (max-width: 1428px) 100vw, 1428px\" \/><\/a><\/p>\n<p>I&#8217;ve labelled one copy as &#8220;DeerA_TM_Input Feature&#8221; and the other as &#8220;DeerA_TM_Near Feature&#8221;.\u00a0 Then I manually selected the first record in the Near Feature layer and all the points within the 2-day window starting then in the Input Features layer.\u00a0 I&#8217;m anticipating this will add the NEAR_ID and NEAR_DIST fields to both layer and then I&#8217;ll check and see if it worked.\u00a0 It did!<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Distances.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3434\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Distances.jpg\" alt=\"\" width=\"962\" height=\"570\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Distances.jpg 962w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Distances-300x178.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Distances-768x455.jpg 768w\" sizes=\"auto, (max-width: 962px) 100vw, 962px\" \/><\/a><\/p>\n<p>The -1 value occurs because it&#8217;s the same feature.\u00a0 Using the Measure tool, I confirmed that the correct distances are being calculated so I&#8217;ve got a viable workflow.<\/p>\n<p>So.\u00a0 Next decision is do I do this manually or should I automate it?\u00a0 I&#8217;ve potentially got 10 animals each with around 50 days worth of data.\u00a0 With 2-day sliding windows let&#8217;s call that 25 windows per animal, so 250 iterations all up.\u00a0 If this was just one animal, I might be tempted to do it manually, but with 10, I think I&#8217;m going to have to automate it.\u00a0 Should I use ModelBuilder or Python?\u00a0 I&#8217;ll check out ModelBuilder first &#8211; I know\u00a0it&#8217;s got\u00a0<a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/latest\/tool-reference\/modelbuilder-toolbox\/examples-of-using-iterators-in-modelbuilder.htm\" target=\"_blank\" rel=\"noopener noreferrer\">iterators <\/a>built in so it might work.\u00a0 Before I do that, though, I want to think about if I can structure my data to make life easier.<\/p>\n<p>In the bit above, I manually selected the records.\u00a0 This was easy enough to do; find the first record and then go forward two days.\u00a0 If my records were at regularly sampled times, I might be able to use Select by Attribute to make this work, but given the irregular sampling, I think that&#8217;s going to be a nightmare.\u00a0 At this point I&#8217;m willing to do the work of manually grouping the 2-day windows by adding a new attribute.\u00a0 This new attribute is called &#8220;Window&#8221;, starts at 1 and changes to 2 two days after the start time.\u00a0 Below you can see where the records transition from window 1 to window 2:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Table.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3435\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Table.jpg\" alt=\"\" width=\"817\" height=\"437\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Table.jpg 817w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Table-300x160.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Table-768x411.jpg 768w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/a><\/p>\n<p>To further make life easier when I come to automate this, I decided to extract out the first day points into a new layer.\u00a0 This layer is called DeerAFirst (on the right below):<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3436\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst.jpg\" alt=\"\" width=\"1621\" height=\"881\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst.jpg 1621w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst-300x163.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst-1024x557.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst-768x417.jpg 768w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DeerAFirst-1536x835.jpg 1536w\" sizes=\"auto, (max-width: 1621px) 100vw, 1621px\" \/><\/a><\/p>\n<p>To do this manually I&#8217;ve got to do two Select by Attributes &#8211; one for the first day of a window and the second\u00a0for all the points within that window.\u00a0 Let&#8217;s see if I can do that in ModelBuilder.<\/p>\n<p>I started by dragging my two input layers on to the canvas and the Near tool.\u00a0 From the Iterators menu I picked &#8220;Iterate by Feature Class&#8221; which should allow me to work through each record one at a time:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/MB.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3438\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/MB.jpg\" alt=\"\" width=\"1011\" height=\"567\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/MB.jpg 1011w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/MB-300x168.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/MB-768x431.jpg 768w\" sizes=\"auto, (max-width: 1011px) 100vw, 1011px\" \/><\/a><\/p>\n<p>So far, so good &#8211; until I tried to add a second iterator&#8230;they&#8217;re all greyed out when I try and chose another one:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Grey.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3439\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Grey.jpg\" alt=\"\" width=\"716\" height=\"577\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Grey.jpg 716w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Grey-300x242.jpg 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><\/p>\n<p>This is a MAJOR limitation of ModelBuilder: I can only use one iterator per model.\u00a0 It&#8217;s going to have to be Python.<\/p>\n<p>I won&#8217;t got into all the gory details (and there are plenty) but the script ended up being pretty simple really.\u00a0 The biggest problem I ran into was that whenever Near runs, it works on the selected records as expected, but it also resets <em>all<\/em> the non-selected records to -1, meaning each time it runs I loose all the previously calculated distances.\u00a0 My solution?\u00a0 Create a new layer with all the same attributes but no features (records) and at the end of each iteration, export the selected records\u00a0 to it.\u00a0 For this I used the <a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/latest\/tool-reference\/data-management\/append.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Append <\/a>tool.\u00a0 Here&#8217;s the script for those of you having trouble sleeping (assuming you&#8217;re <em>still<\/em> awake):<\/p>\n<pre style=\"padding-left: 30px\"><span style=\"font-size: 12pt\">import arcpy<\/span>\n\n<span style=\"font-size: 12pt\"># Some script removed to protect the\u00a0guilty<\/span><\/pre>\n<pre style=\"padding-left: 30px\"><span style=\"font-size: 12pt\"># variable for the Input, near and output feature classes<\/span>\n <span style=\"font-size: 12pt\">inputFC = \"DeerA\"<\/span>\n <span style=\"font-size: 12pt\">nearFC = \"DeerAFirst\"<\/span>\n <span style=\"font-size: 12pt\">outputFC = \"DeerAOut\"<\/span>\n\n<span style=\"font-size: 12pt\"># iterator to move through each window<\/span>\n <span style=\"font-size: 12pt\">count = 1<\/span>\n\n<span style=\"font-size: 12pt\"># while loop to iterate through Window attribute and run Near. There are 25 windows so this forces it to stop after the 25th<\/span>\n <span style=\"font-size: 12pt\">while count &lt; 26:<\/span>\n\n<span style=\"font-size: 12pt\"># where clause<\/span>\n <span style=\"font-size: 12pt\"> whereClause = \"\"\"Window = {}\"\"\".format(count)<\/span>\n <span style=\"font-size: 12pt\"> print(whereClause)<\/span>\n\n<span style=\"font-size: 12pt\"> arcpy.SelectLayerByAttribute_management(inputFC, \"NEW_SELECTION\", whereClause)<\/span>\n\n<span style=\"font-size: 12pt\"> arcpy.Near_analysis(inputFC, nearFC)<\/span>\n\n<span style=\"font-size: 12pt\"> # Near overwrites all unselected records so use Append to add new records to OutputFC<\/span>\n <span style=\"font-size: 12pt\"> arcpy.Append_management(inputFC, outputFC)\n <\/span>\n <span style=\"font-size: 12pt\"> # add one to the count for the next iteration<\/span>\n <span style=\"font-size: 12pt\"> count = count + 1<\/span>\n\n<span style=\"font-size: 12pt\"> print(count)<\/span>\n\n<span style=\"font-size: 12pt\"># end of while loop - go back and do it again on a new set of selected records until count &lt; 26<\/span>\n\n<span style=\"font-size: 12pt\">print(\"Done\")<\/span><\/pre>\n<p>This worked pretty nicely, I must say, and was pretty basic.\u00a0 In the output you can see the added columns that show the distances from OBJECT_ID = 1 (from an exported CSV file &#8211; distances are in metres):<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/OutputCSV.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3441\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/OutputCSV.jpg\" alt=\"\" width=\"830\" height=\"526\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/OutputCSV.jpg 830w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/OutputCSV-300x190.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/OutputCSV-768x487.jpg 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/a><\/p>\n<p>I&#8217;d love to say that this was the end of it, but sadly, just after I sent this off, I revisited the original email and realised to my horror (<em>I was going to put in a link to Colonel Kurtz&#8217;s horror speech at the end of Apocalypse Now, but that was a bit too much<\/em>), that I hadn&#8217;t actually done what I was supposed to do&#8230;\u00a0 I hope there were a least a few of you out there that had a nagging suspicion about this from early on, but I wasn&#8217;t among them.\u00a0 Such hubris&#8230;I thought I knew what they wanted.\u00a0 At issue here is the windows themselves.\u00a0 What I did above was windows that were set up as:<\/p>\n<ul>\n<li>window 1 = day 1 and day 2<\/li>\n<li>window 2 = day 3 and day 4<\/li>\n<li>window 3 = day 5 and day 6<\/li>\n<li>etc<\/li>\n<\/ul>\n<p>What was wanted was:<\/p>\n<ul>\n<li>window 1 = day 1 and day 2<\/li>\n<li>window 2 &#8211; day 2 and day 3<\/li>\n<li>window 3 = day 3 and day 4<\/li>\n<li>etc<\/li>\n<\/ul>\n<p>Doh!\u00a0 My mistake.\u00a0 Big sigh.<\/p>\n<p>Well I can see what the next post will be about&#8230;better get back to work&#8230;<\/p>\n<p>This was fun while it lasted.\u00a0 And my only solace is that Python did exactly what I told it to do, frustratingly so.\u00a0 When things go wrong with scripts,\u00a0I find that it&#8217;s usually not Python that&#8217;s made the mistake, but the Python user.\u00a0 Tell that to your nearest and deerest ones next time you&#8217;re coding.<\/p>\n<p>C<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post we look at addressing a spatial problem, coming up with an approach and implementing the solution.\u00a0 (Spoiler alert &#8211; it worked, but not as it was supposed to.)\u00a0 We often get emails here at GIS Central asking for a bit of assistance with things spatial.\u00a0 One never knows what will come through [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3426","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/3426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/comments?post=3426"}],"version-history":[{"count":2,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/3426\/revisions"}],"predecessor-version":[{"id":4964,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/3426\/revisions\/4964"}],"wp:attachment":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/media?parent=3426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/categories?post=3426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/tags?post=3426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}