Setup

1. LINZ parcel information

a. LINZ_parcel_ID Parcel identifier - “certificate of title”.
b. LINZ_parcel_centroid_lon
c. LINZ_parcel_centroid_lat
d. LINZ_parcel_vertices_lon vector of longitudes of the vertices of the matched LINZ parcels
e. LINZ_parcel_vertices_lat
f. LINZ_parcel_roadvertices_lon subvector of longitudes of parcel that sits adjacent to a road
g. LINZ_parcel_roadvertices_lat
h. LINZ_adjoining_parcel_ID id of adjoining LINZ parcels
i. LINZ_parcel_sides_zones AUP Zone Code of adjoining parcels (this includes residential, business, and rural zones; it should also include roads, water and open spaces)

For convenience/speed, 1h and 1i can be gotten simultaneously.
Note: not doing it for each side of a parcel. Only taking a neighbouring parcel once, even if it borders more than one side.

Do 2a and 2b here first, which are needed for 1i.

What to use for joining parcels with AUP zones?

first, 2a and 2b - needed for 1i.

now do 1h & 1i (now that parcels have zones)

j. i. LINZ_TRNSPWR_ohead_indicator Indicator (0 or 1) for LINZ parcel located under overhead transpower line. Leave blank otherwise. Note that ‘TRANSLINE’ denotes overhead transmission lines in the GIS dataset, while ‘CABLE’ denotes underground transmission lines and can be ignored.
j. ii. LINZ_TRNSPWR_ohead_name

Note: What name to use? 'descriptio'?

k. i. LINZ_VWSHFT_ohead_indicator Indicator (0 or 1) for LINZ parcel located under viewshafts. Leave blank otherwise.
k. ii. LINZ_VWSHFT_ohead_name Name of the volcanic cone (e.g. Mt Albert). Leave blank if no viewshaft applies.
k. iii. LINZ_VWSHFT_ohead_ID OBJECTID of the viewshaft. Leave blank if no viewshaft applies.

2. AUP shapefile information. Calculations are based on centroid of matched parcels:

Done above in 1h and 1i.

c. Hdist_rural Minimum Haversine distance to nearest Rural Zone, plus
c. i. Hdist_rural_name Name of rural zone identified
c. ii. Hdist_rural_code Numeric code of rural zone identified

I've included all of these as rural:
['Rural - Mixed Rural Zone',
'Rural - Rural Coastal Zone',
'Rural - Countryside Living Zone',
'Rural - Rural Production Zone',
'Rural - Rural Conservation Zone',
'Rural - Waitakere Ranges Zone',
'Rural - Waitakere Foothills Zone']

d. Hdist_bus Minimum Haversine distance to nearest Business Zone
d. i. Hdist_bus_name
d. ii. Hdist_bus_code
e. Hdist_resid Minimum Haversine distance to nearest Residential Zone,
e. i. Hdist_resid_name
e. ii. Hdist_resid_code
f. Hdist_SH Minimum Haversine distance to Residential - Single House Zone
g. Hdist_MHS Minimum Haversine distance to Residential - Mixed Housing Suburban Zone
h. Hdist_MHU Minimum Haversine distance to Residential - Mixed Housing Urban Zone
i. Zone Hdist_THA Minimum Haversine distance to Residential - Terrace Housing and Apartments

Note: this is the real name for i: 'Residential - Terrace Housing and Apartment Building Zone'

3-7: Areas that parcels are located in (e.g. sa2, aup etc.)

3 - 7 will be done all at once, in a for loop below; but first, load in data and set up parameters.
Parcels often end up overlapping multiple areas; in this case, use the area with the greatest overlap.

a. Name (just the string is fine; I did not generate numeric codes for the local areas generated) Local_Area_name
a. Name (string) SA22018_name
b. Numeric code SA22018_code
a. Name (string) AU2013_name
b. Numeric code AU2013_code
a. Code MB2018_code
a. Code MB2013_code

3 - 7. perform the joins

For these distance calculations, use EPSG 2193 (less distortion).

a. Minimum Haversine distance to coastline Hdist_coast

There are a few different datasets that could be used for this:

- NZ Coastlines (Topo 1:50k) https://data.linz.govt.nz/layer/50258-nz-coastlines-topo-150k/
- NZ Coastline - mean high water https://data.linz.govt.nz/layer/105085-nz-coastline-mean-high-water/
- NZ Coastlines and Islands Polygons (Topo 1:50k) https://data.linz.govt.nz/layer/51153-nz-coastlines-and-islands-polygons-topo-150k/  

The first doesn't have islands (e.g. Waiheke).
The second is probably most appropriate.

b. Minimum Haversinedistance to Open Space(set of AUP Zones) Hdist_open
c. Minimum Haversine distance to motorway Hdist_motorway
d. Minimum Haversine distance to main arterial road Hdist_main_road
e. Minimum Haversine distance to rail line Hdist_rail
f. Haversine distance to downtown (use Skytower coordinates) Hdist_skytower

9. Special Housing Area (SpHAs)

Indicator (1 or 0) for consent located in SpHAs SpHA_indicator
Note: here I've used centroids. Maybe should use parcel polygons instead.

Save

10. Ranged Address Indicator

11. Matching Type Indicators

a. LINZ_MATCH_CODE
b. LINZ_2ND_MATCH_CODE