In this post I’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.  If this doesn’t happen then there’s not much value in the analysis that you might carry out with those data.  Back 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).

Peter Almond recently got in touch because he had some data layers that he knew should line up but didn’t.  How could we fix this?  The data in question were two soil layers from some local farm paddocks, one collected by a class in 2011, the other in 2012.  Here’s what they look like on top of the old NZMG L37 topmap (that’s the Ashburton River off the left of the data – we’re about 7 km in from the coast here):

SpatialAdjust1

 

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.  As you can see, the 2012 layer (in purple) is offset from the 2011 layer (in blue).  Given the map underneath, the 2011 layer looks to be in the right place (plus Peter told me as much) so there’s something up with the 2012 layer.   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.  The offset (roughly 160 m to the NNE) smacks of a bad coordinate system transform (must do a post on this later…).

Solution 1

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’t solve the offset. (WGS84 is the universal blood donor of coordinate systems – but that’s another post.)

Solution 2

What I really needed to do here was to shift the 2012 layer to its correct position.  Many 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).  Wouldn’t it be great if we could do the same thing with vector data?  A solution is to use the Spatial Adjustment toolbar to do just that.  The toolbar can be added by right-clicking on a grey area above the map and picking Spatial Adjustment:

SpatialAdjustToolbar

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.  We’re essentially editing the data so we also need to open the Editor Toolbar and start an editing session.  Once we’ve done so, the buttons on the toolbar become active:

SpatialAdjustToolbarActive

Before setting up the links, I selected all the features in the 2012 layer (right-click on layer name > Selection > Select all features).  Next, I clicked the Links button, LinkButton, and picked 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).  Once I’d done at least three the “Adjust” option becomes active in the Spatial Adjustment layer.  I picked that et voila!:

SpatialAdjust2

So now the 2012 looks to be in the right place – 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.  These edits needed to be saved to make them permanent so I did a “Save Edits” from the Editor menu.

To summarise this:

  • Add the Spatial Adjustment toolbar;
  • Start an editing session;
  • Select all the features in the layer to be shifted (you can also specify the layer to be adjusted from the Spatial Adjustment menu > Set Adjust Data… without having to select the features);
  • Create at least three links clicking on the data to shift first and the correct location second;
  • then Spatial Adjustment menu > Adjust;
  • Save your edits and stop your editing session.

Solution 3

Though I didn’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.  The 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.

I thought this was a useful thing to know how to do and touches on some fundamental ideas behind GIS.  I still can’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  (the correct one would have been New_Zealand_1949_To_NZGD_2000_3_NTv2.  There’s a whole `nother post to explain that one).

Crile