{"id":22,"date":"2013-02-20T00:35:55","date_gmt":"2013-02-20T00:35:55","guid":{"rendered":"http:\/\/www.lincoln.ac.nz\/conversation\/gis\/?p=22"},"modified":"2013-02-20T00:35:55","modified_gmt":"2013-02-20T00:35:55","slug":"my-data-arent-lining-up","status":"publish","type":"post","link":"https:\/\/blogs.lincoln.ac.nz\/gis\/my-data-arent-lining-up\/","title":{"rendered":"My data aren&#8217;t lining up!"},"content":{"rendered":"<p><em>In this post I&#8217;ll talk about using the Spatial Adjustment toolbar to shift vector data from where it is to where it should be.<\/em><\/p>\n<p>A key underlying idea of GIS is that data layers overlay because they all live in the same geographic space. \u00a0If this doesn&#8217;t happen then there&#8217;s not much value in the analysis that you might carry out with those data. \u00a0Back in the day, of course, this would just have meant moving the layers of acetate around until they all matched up (assuming the data were all at the same scale).<\/p>\n<p>Peter Almond recently got in touch because he had some data layers that he knew should line up but didn&#8217;t. \u00a0How could we fix this? \u00a0The data in question were two soil layers from some local farm paddocks, one collected by a class in 2011, the other in 2012. \u00a0Here&#8217;s what they look like on top of the old NZMG L37 topmap (that&#8217;s the Ashburton River off the left of the data &#8211; we&#8217;re about 7 km in from the coast here):<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-809\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1.jpg\" alt=\"SpatialAdjust1\" width=\"1778\" height=\"1147\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1.jpg 1778w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1-300x194.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1-1024x661.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1-768x495.jpg 768w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust1-1536x991.jpg 1536w\" sizes=\"auto, (max-width: 1778px) 100vw, 1778px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The original data are in New Zealand Map Grid (NZMG) coordinates and Peter had said he wanted to keep all the data in that system. \u00a0As you can see, the 2012 layer (in purple) is offset from the 2011 layer (in blue). \u00a0Given the map underneath, the 2011 layer looks to be in the right place (plus Peter told me as much) so there&#8217;s something up with the 2012 layer. \u00a0 My first thought was that the 2012 data were originally captured in the New Zealand Transverse Mercator (NZTM) coordinate system and an incorrect transformation was used to reproject it back to NZMG. \u00a0The offset (roughly 160 m to the NNE) smacks of a bad coordinate system transform (must do a post on this later&#8230;).<\/p>\n<p><span style=\"color: #000000\"><strong>Solution 1<\/strong><\/span><\/p>\n<p><span style=\"color: #000000\">So going on my gut feeling about the coordinate system, I tried to project the layer from NZMG to WGS84 (the system used for the Global Positioning System, GPS, and in Latitude and Longitude) so I could then reproject it to NZMG, but this didn&#8217;t solve the offset. (WGS84 is the universal blood donor of coordinate systems &#8211; but that&#8217;s another post.)<\/span><\/p>\n<p><span style=\"color: #000000\"><strong>Solution 2<\/strong><\/span><\/p>\n<p><span style=\"color: #000000\">What I really needed to do here was to shift the 2012 layer to its correct position. \u00a0Many of you are already familiar with georeferencing images (the process of matching up an image (aerial photo, satellite image, scanned map) with a coordinate system using existing data). \u00a0Wouldn&#8217;t it be great if we could do the same thing with vector data? \u00a0A solution is to use the Spatial Adjustment toolbar to do just that. \u00a0The toolbar can be added by right-clicking on a grey area above the map and picking Spatial Adjustment:<\/span><\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbar.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-810\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbar.jpg\" alt=\"SpatialAdjustToolbar\" width=\"399\" height=\"35\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbar.jpg 399w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbar-300x26.jpg 300w\" sizes=\"auto, (max-width: 399px) 100vw, 399px\" \/><\/a><\/p>\n<p><span style=\"color: #000000\">As with georeferencing, we can set up links between existing data (or locations in a coordinate space to be more exact) and features of the data to be shifted and then the tool will shift the layer to a new location. \u00a0We&#8217;re essentially editing the data so we also need to open the Editor Toolbar and start an editing session. \u00a0Once we&#8217;ve done so, the buttons on the toolbar become active:<\/span><\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbarActive.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-811\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbarActive.jpg\" alt=\"SpatialAdjustToolbarActive\" width=\"467\" height=\"58\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbarActive.jpg 467w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjustToolbarActive-300x37.jpg 300w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p><span style=\"color: #000000\">Before setting up the links, I selected all the features in the 2012 layer (right-click on layer name &gt; Selection &gt; Select all features). \u00a0Next, I clicked the Links button, <a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/LinkButton.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-812\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/LinkButton.jpg\" alt=\"LinkButton\" width=\"28\" height=\"26\" \/><\/a>, and\u00a0picked out a few (at least three) obvious common features (like corners), clicking first on the data to be shifted (the 2012 layer) and then on the correct position (in the 2011 layer). \u00a0Once I&#8217;d done at least three the &#8220;Adjust&#8221; option becomes active in the Spatial Adjustment layer. \u00a0I picked that et voila!:<\/span><\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust21.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-813\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust21.jpg\" alt=\"SpatialAdjust2\" width=\"1138\" height=\"708\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust21.jpg 1138w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust21-300x187.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust21-1024x637.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/02\/SpatialAdjust21-768x478.jpg 768w\" sizes=\"auto, (max-width: 1138px) 100vw, 1138px\" \/><\/a><\/p>\n<p><span style=\"color: #000000\">So now the 2012 looks to be in the right place &#8211; you can see changes the purple 2012 layer peeking through underneath the blue soil polygons; one easy way to see the differences between the two layers. \u00a0These edits needed to be saved to make them permanent so I did a &#8220;Save Edits&#8221; from the Editor menu.<\/span><\/p>\n<p><span style=\"color: #000000\">To summarise this:<\/span><\/p>\n<ul>\n<li>Add the Spatial Adjustment toolbar;<\/li>\n<li>Start an editing session;<\/li>\n<li>Select all the features in the layer to be shifted (you can also specify the layer to be adjusted from the Spatial Adjustment menu &gt; Set Adjust Data&#8230; without having to select the features);<\/li>\n<li>Create at least three links clicking on the data to shift first and the correct location second;<\/li>\n<li>then Spatial Adjustment menu &gt; Adjust;<\/li>\n<li>Save your edits and stop your editing session.<\/li>\n<\/ul>\n<p><span style=\"color: #000000\"><strong>Solution 3<\/strong><\/span><\/p>\n<p><span style=\"color: #000000\">Though I didn&#8217;t try this, another solution could be to start an editing session, select all the features in the 2012 layer and simply drag them to where they should be by clicking on the arrow, then clicking and holding a portion of the selected layer. \u00a0The benefit of using the Spatial Adjustment tool is that any scaling that might need to be done is carried out automatically and I think you can do it a lot more accurately. <\/span><\/p>\n<p><span style=\"color: #000000\">I thought this was a useful thing to know how to do and touches on some fundamental ideas behind GIS. \u00a0I still can&#8217;t quite figure out why the 2012 layer is offest to begin with, but I still suspect that the original layer was created in NZTM and the incorrect transformation was used to reproject it to NZMG \u00a0(the correct one would have been New_Zealand_1949_To_NZGD_2000_3_NTv2. \u00a0There&#8217;s a whole `nother post to explain that one).<\/span><\/p>\n<p><span style=\"color: #000000\">Crile<\/span>    \t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post I&#8217;ll talk about using the Spatial Adjustment toolbar to shift vector data from where it is to where it should be. A key underlying idea of GIS is that data layers overlay because they all live in the same geographic space. \u00a0If this doesn&#8217;t happen then there&#8217;s not much value in the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[6,7,8,9],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-interesting-problems","tag-nzmg","tag-nztm","tag-spatial-adjustment","tag-vector-data"],"_links":{"self":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/22","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=22"}],"version-history":[{"count":0,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}