In [1]:
%reload_ext autotime
import rasterio
import requests
from rasterio.features import shapes, sieve, rasterize
from rasterio.plot import show
import geopandas as gpd
import os
import numpy as np
from tqdm.auto import tqdm
from shapely.geometry import box, shape
from rasterio.mask import mask
from matplotlib import pyplot as plt
import xdem
import pandas as pd
tqdm.pandas()
pd.set_option('display.max_columns', None)
✔️ 2.45 s (2024-12-02T11:51:23/2024-12-02T11:51:26)
In [2]:
manifest = pd.json_normalize(requests.get("https://nz-elevation.s3.ap-southeast-2.amazonaws.com/gisborne/gisborne_2023/dem_1m/2193/collection.json").json()["links"])
manifest = manifest[manifest["rel"] == "item"]
manifest["tilename"] = manifest.href.str.replace(".json", "").str.strip("./")
manifest
✔️ 222 ms (2024-12-02T11:51:26/2024-12-02T11:51:26)
Out[2]:
rel href type file:checksum tilename
2 item ./BD43_10000_0204.json application/json 12208b52bfdff84d924430e9503bc70bcc7555c1861e5b... BD43_10000_0204
3 item ./BD43_10000_0205.json application/json 12204ec4b1257e965c8da142c4696b1f8cbbc6c78d0cf0... BD43_10000_0205
4 item ./BD43_10000_0304.json application/json 1220acfd4fd86a3866f4facf92bb75cd5224451e774ff4... BD43_10000_0304
5 item ./BD43_10000_0305.json application/json 122051507adf6a042f09c138f1842911fec7bd43c270d8... BD43_10000_0305
6 item ./BD43_10000_0404.json application/json 1220c63b7011af35652df009f8a6b69f4e3f8ea2db33d6... BD43_10000_0404
... ... ... ... ... ...
302 item ./BH43_10000_0102.json application/json 12200f2d3649a677e745f258162ca6ebc13904d6ecde95... BH43_10000_0102
303 item ./BH43_10000_0201.json application/json 1220d28f9ff3b2f6ad76139b4ccfa5bd86bc996b417e36... BH43_10000_0201
304 item ./BH43_10000_0202.json application/json 1220d78d97c89b75b5d35667f77acb8e5a2078d52b977b... BH43_10000_0202
305 item ./BH43_10000_0301.json application/json 12200b058bab70e426eccd9ae990a5888e1754b27b97c2... BH43_10000_0301
306 item ./BH43_10000_0302.json application/json 12203c93b413b89941df279575d9d352046cc8b6977deb... BH43_10000_0302

305 rows × 5 columns

In [3]:
manifest.head(10)
✔️ 10.1 ms (2024-12-02T11:51:26/2024-12-02T11:51:26)
Out[3]:
rel href type file:checksum tilename
2 item ./BD43_10000_0204.json application/json 12208b52bfdff84d924430e9503bc70bcc7555c1861e5b... BD43_10000_0204
3 item ./BD43_10000_0205.json application/json 12204ec4b1257e965c8da142c4696b1f8cbbc6c78d0cf0... BD43_10000_0205
4 item ./BD43_10000_0304.json application/json 1220acfd4fd86a3866f4facf92bb75cd5224451e774ff4... BD43_10000_0304
5 item ./BD43_10000_0305.json application/json 122051507adf6a042f09c138f1842911fec7bd43c270d8... BD43_10000_0305
6 item ./BD43_10000_0404.json application/json 1220c63b7011af35652df009f8a6b69f4e3f8ea2db33d6... BD43_10000_0404
7 item ./BD43_10000_0405.json application/json 12209178da4e9715af3e411c77c5fc728fee6e5cd87ca9... BD43_10000_0405
8 item ./BD43_10000_0505.json application/json 122050df23b562830f3ec021108bd62c2d6eac4acefb24... BD43_10000_0505
9 item ./BD44_10000_0102.json application/json 1220d5c42a1019b4ef3a3ba1d649f2f8461e80fa1f173a... BD44_10000_0102
10 item ./BD44_10000_0103.json application/json 1220244ab98540f7cd70cee30918b88eb9f22922c935c3... BD44_10000_0103
11 item ./BD44_10000_0104.json application/json 122021d7a9dee6a498ccf959bb651b7ca6894c814e3add... BD44_10000_0104
In [4]:
tilename = "BD44_10000_0503"
old = rasterio.open(f"https://nz-elevation.s3.ap-southeast-2.amazonaws.com/gisborne/gisborne_2018-2020/dem_1m/2193/{tilename}.tiff")
new = rasterio.open(f"https://nz-elevation.s3.ap-southeast-2.amazonaws.com/gisborne/gisborne_2023/dem_1m/2193/{tilename}.tiff")
✔️ 1.21 s (2024-12-02T11:51:26/2024-12-02T11:51:28)
In [5]:
new.crs, old.crs
✔️ 4.89 ms (2024-12-02T11:51:28/2024-12-02T11:51:28)
Out[5]:
(CRS.from_wkt('PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",GEOGCS["NZGD2000",DATUM["New_Zealand_Geodetic_Datum_2000",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6167"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4167"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",173],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",1600000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Northing",NORTH],AXIS["Easting",EAST],AUTHORITY["EPSG","2193"]]'),
 CRS.from_wkt('PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",GEOGCS["NZGD2000",DATUM["New_Zealand_Geodetic_Datum_2000",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6167"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4167"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",173],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",1600000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Northing",NORTH],AXIS["Easting",EAST],AUTHORITY["EPSG","2193"]]'))
In [6]:
show(old, title="2018-2020 DEM")
✔️ 3.96 s (2024-12-02T11:51:28/2024-12-02T11:51:32)
No description has been provided for this image
Out[6]:
<Axes: title={'center': '2018-2020 DEM'}>
In [7]:
show(new, title="2023 DEM")
✔️ 4.67 s (2024-12-02T11:51:32/2024-12-02T11:51:37)
No description has been provided for this image
Out[7]:
<Axes: title={'center': '2023 DEM'}>
In [8]:
diff = new.read(1) - old.read(1)
print(diff.shape)
plt.imshow(diff, cmap="coolwarm_r", vmin=-1, vmax=1)
plt.colorbar()
✔️ 1.65 s (2024-12-02T11:51:37/2024-12-02T11:51:39)
(7200, 4800)
Out[8]:
<matplotlib.colorbar.Colorbar at 0x7f470761b430>
No description has been provided for this image
In [9]:
_ = plt.hist(diff.flatten(), bins=100, range=(-2, 2))
plt.title("Histogram of elevation differences")
✔️ 484 ms (2024-12-02T11:51:39/2024-12-02T11:51:40)
Out[9]:
Text(0.5, 1.0, 'Histogram of elevation differences')
No description has been provided for this image
In [10]:
result = diff.round().clip(min=-1, max=1).astype(np.int16)
result = sieve(result, 4000)
result = np.where(result != 0, result, np.nan)
plt.imshow(result, cmap="coolwarm_r")
plt.colorbar()
✔️ 3.85 s (2024-12-02T11:51:40/2024-12-02T11:51:44)
Out[10]:
<matplotlib.colorbar.Colorbar at 0x7f4718c0b790>
No description has been provided for this image
In [11]:
areas = gpd.GeoDataFrame(geometry=[shape(s) for s, v in shapes(result, transform=new.transform) if not np.isnan(v)], crs=2193)
areas["area"] = areas.area
areas.sort_values("area", ascending=False, inplace=True)
areas.plot("area", legend=True)
✔️ 1.44 s (2024-12-02T11:51:44/2024-12-02T11:51:45)
Out[11]:
<Axes: >
No description has been provided for this image
In [12]:
largest_area = areas.iloc[0]#.head(1)
largest_area
✔️ 13 ms (2024-12-02T11:51:45/2024-12-02T11:51:45)
Out[12]:
geometry    POLYGON ((2054419 5803910, 2054419 5803909, 20...
area                                                 530308.0
Name: 176, dtype: object
In [13]:
masked_old, transform = mask(old, [largest_area.geometry], nodata=np.nan)
nonan = np.argwhere(~np.isnan(masked_old[0]))
top_left = nonan.min(axis=0)
bottom_right = nonan.max(axis=0)
print(top_left, bottom_right)
masked_old = masked_old[0][top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1]
show(masked_old)
⌛ 2.55 µs (2024-12-02T11:51:45)
[5290    0] [7044 3057]
No description has been provided for this image
Out[13]:
<Axes: >
In [14]:
masked_new, transform = mask(new, [largest_area.geometry], nodata=np.nan)
masked_new = masked_new[0][top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1]
show(masked_new)
✔️ 1.2 s (2024-12-02T11:51:47/2024-12-02T11:51:48)
No description has been provided for this image
Out[14]:
<Axes: >
In [15]:
features = {
    "old_min": np.nanmin(masked_old),
    "old_max": np.nanmax(masked_old),
    "old_mean": np.nanmean(masked_old),
    "old_median": np.nanmedian(masked_old),
    "old_std": np.nanstd(masked_old),
    "new_min": np.nanmin(masked_new),
    "new_max": np.nanmax(masked_new),
    "new_mean": np.nanmean(masked_new),
    "new_median": np.nanmedian(masked_new),
    "new_std": np.nanstd(masked_new),
}
features
✔️ 160 ms (2024-12-02T11:51:48/2024-12-02T11:51:48)
Out[15]:
{'old_min': 264.148,
 'old_max': 520.245,
 'old_mean': 347.9752,
 'old_median': 350.69598,
 'old_std': 49.78903,
 'new_min': 264.706,
 'new_max': 519.89703,
 'new_mean': 356.3459,
 'new_median': 364.74097,
 'new_std': 53.15585}
In [16]:
raster = rasterize([largest_area.geometry], out_shape=result.shape, transform=new.transform)
masked_diff = np.where(raster, diff, np.nan)
masked_diff = masked_diff[top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1]
show(masked_diff)
✔️ 726 ms (2024-12-02T11:51:49/2024-12-02T11:51:49)
No description has been provided for this image
Out[16]:
<Axes: >
In [17]:
features.update({
    "diff_min": np.nanmin(masked_diff),
    "diff_max": np.nanmax(masked_diff),
    "diff_mean": np.nanmean(masked_diff),
    "diff_median": np.nanmedian(masked_diff),
    "diff_std": np.nanstd(masked_diff),
})
features
✔️ 96.6 ms (2024-12-02T11:51:49/2024-12-02T11:51:50)
Out[17]:
{'old_min': 264.148,
 'old_max': 520.245,
 'old_mean': 347.9752,
 'old_median': 350.69598,
 'old_std': 49.78903,
 'new_min': 264.706,
 'new_max': 519.89703,
 'new_mean': 356.3459,
 'new_median': 364.74097,
 'new_std': 53.15585,
 'diff_min': -6.8740234,
 'diff_max': 43.521973,
 'diff_mean': 8.370939,
 'diff_median': 4.911972,
 'diff_std': 9.06017}
In [18]:
attribute_names = ["roughness", "slope", "aspect", "curvature", "terrain_ruggedness_index", "rugosity", "profile_curvature", "planform_curvature"]
attributes = xdem.terrain.get_terrain_attribute(
    masked_diff,
    resolution=old.res,
    attribute=attribute_names
)

plt.figure(figsize=(8, 6.5))
for i in range(8):
    plt.subplot(4, 2, i + 1)
    plt.imshow(attributes[i].squeeze(), cmap="viridis")
    cbar = plt.colorbar()
    cbar.set_label(attribute_names[i])
    plt.xticks([])
    plt.yticks([])

plt.tight_layout()
plt.show()
✔️ 29.3 s (2024-12-02T11:51:50/2024-12-02T11:52:19)
No description has been provided for this image
In [19]:
for i, name in enumerate(attribute_names):
    features.update({
        f"{name}_min": np.nanmin(attributes[i]),
        f"{name}_max": np.nanmax(attributes[i]),
        f"{name}_mean": np.nanmean(attributes[i]),
        f"{name}_median": np.nanmedian(attributes[i]),
        f"{name}_std": np.nanstd(attributes[i]),
    })
features
✔️ 815 ms (2024-12-02T11:52:19/2024-12-02T11:52:20)
Out[19]:
{'old_min': 264.148,
 'old_max': 520.245,
 'old_mean': 347.9752,
 'old_median': 350.69598,
 'old_std': 49.78903,
 'new_min': 264.706,
 'new_max': 519.89703,
 'new_mean': 356.3459,
 'new_median': 364.74097,
 'new_std': 53.15585,
 'diff_min': -6.8740234,
 'diff_max': 43.521973,
 'diff_mean': 8.370939,
 'diff_median': 4.911972,
 'diff_std': 9.06017,
 'roughness_min': 0.024993896484375,
 'roughness_max': 16.99798583984375,
 'roughness_mean': 0.8664416971654487,
 'roughness_median': 0.501007080078125,
 'roughness_std': 0.9008248692669407,
 'slope_min': 0.00030909907704678905,
 'slope_max': 83.09449329265449,
 'slope_mean': 15.825287450127606,
 'slope_median': 9.967977228482425,
 'slope_std': 14.601294984565905,
 'aspect_min': 0.0,
 'aspect_max': 359.9997588896344,
 'aspect_mean': 172.74772778897523,
 'aspect_median': 183.00927436545985,
 'aspect_std': 104.09906838438863,
 'curvature_min': -1643.609619140625,
 'curvature_max': 2639.605712890625,
 'curvature_mean': 1.7315227064581844,
 'curvature_median': 0.8087158203125,
 'curvature_std': 43.72569863077058,
 'terrain_ruggedness_index_min': 0.024669455802839076,
 'terrain_ruggedness_index_max': 27.121265279417575,
 'terrain_ruggedness_index_mean': 0.8939862986187255,
 'terrain_ruggedness_index_median': 0.5406418612709043,
 'terrain_ruggedness_index_std': 0.8938326265050937,
 'rugosity_min': 1.000078699472661,
 'rugosity_max': 9.8867222334156,
 'rugosity_mean': 1.1083063933475281,
 'rugosity_median': 1.0261556432873709,
 'rugosity_std': 0.19958467669264315,
 'profile_curvature_min': -1767.2495203822261,
 'profile_curvature_max': 1433.1465250703304,
 'profile_curvature_mean': -1.2548662332856713,
 'profile_curvature_median': -0.5842965641336939,
 'profile_curvature_std': 28.49170269374419,
 'planform_curvature_min': -624.432616658446,
 'planform_curvature_max': 978.0291066330788,
 'planform_curvature_mean': 0.4766817029082818,
 'planform_curvature_median': 0.18651537440086147,
 'planform_curvature_std': 21.37279648106214}
In [20]:
REC = gpd.read_file("nzRec2_v5.gdb", engine='pyogrio', use_arrow=True)
REC
✔️ 4.46 s (2024-12-02T11:52:20/2024-12-02T11:52:25)
/home/ubuntu/.local/lib/python3.10/site-packages/pyogrio/raw.py:287: UserWarning: More than one layer found in 'nzRec2_v5.gdb': 'riverlines' (default), 'Hydro_Net_Junctions', 'rec2ws', 'rec2_rain_runoff_V5', 'rec2_stew_baserock_V5', 'rec2_stew_toprock_V5', 'rec2_utility_variables_V5', 'rec2_lcdb2_V5', 'rec2_lcdb1_V5', 'rec2_lcdb3_V5', 'rec2_ni_baserock_V5', 'rec2_ni_toprock_V5', 'rec2_si_baserock_V5', 'rec2_si_toprock_V5', 'rec2_elevband_rain_V5', 'LAYERKEYTABLE', 'APUNIQUEID', 'riverlines_FS', 'N_1_Desc', 'N_1_EDesc', 'N_1_EStatus', 'N_1_ETopo', 'N_1_FloDir', 'N_1_JDesc', 'N_1_JStatus', 'N_1_JTopo', 'N_1_JTopo2', 'N_1_Props'. Specify layer parameter to avoid this warning.
  with open_arrow(
Out[20]:
OBJECTID HydroID NextDownID CATAREA CUM_AREA nzsegment Enabled LENGTHDOWN Headwater Hydseq StreamOrde euclid_dis upElev downElev upcoordX downcoordX downcoordY upcoordY sinuosity nzreach_re headw_dist segslpmean LID reachtype FROM_NODE TO_NODE Shape_Leng Shape_Length FLOWDIR geometry
0 1 1 9 218553.786394 2.185538e+05 1000005 1 1801.260253 1 1 1 199.150697 119.994514 90.628487 1.601529e+06 1.601574e+06 6.192386e+06 6.192580e+06 1.072393 1000004 0 8.388180 0 0 1 2 213.567866 213.567866 1 MULTILINESTRING ((1601528.857 6192580.4, 16015...
1 2 2 9 455995.848576 4.559958e+05 1000003 1 1801.260253 1 2 1 537.313689 163.071075 90.628487 1.601783e+06 1.601574e+06 6.192386e+06 6.192881e+06 1.082775 1000005 0 7.678527 0 0 3 2 581.789877 581.789877 1 MULTILINESTRING ((1601782.856 6192881.076, 160...
2 3 3 4 461385.667778 4.613857e+05 1000008 1 335.656220 1 4 1 596.782205 64.632355 20.004650 1.599355e+06 1.599237e+06 6.191779e+06 6.192364e+06 1.163688 1000009 0 4.276652 0 0 4 5 694.468045 694.468045 1 MULTILINESTRING ((1599355.244 6192363.83, 1599...
3 4 4 -1 135806.633398 2.330307e+06 1000010 1 0.000000 0 9 2 288.064229 20.004650 4.172440 1.599237e+06 1.598982e+06 6.191913e+06 6.191779e+06 1.165213 1000010 788 3.145852 0 0 5 6 335.656220 335.656220 1 MULTILINESTRING ((1599237.074 6191778.666, 159...
4 5 5 -1 863421.445984 8.634214e+05 1000006 1 0.000000 1 5 1 1020.122542 143.468826 4.437851 1.602684e+06 1.602267e+06 6.191623e+06 6.192554e+06 1.182202 1000006 0 7.760943 0 0 7 8 1205.990464 1205.990464 1 MULTILINESTRING ((1602683.557 6192553.928, 160...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
593512 593614 593513 -1 51990.267885 1.174888e+09 4170001 1 NaN 0 124017 6 0.000000 0.000000 0.000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000 0 0 0.000000 0 0 85116 604841 542.278140 542.278140 1 MULTILINESTRING ((1975828.498 5785372.292, 197...
593513 593616 593514 -1 150666.238187 2.061735e+08 1040001 1 NaN 0 27152 5 0.000000 12.272364 0.000000 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000 0 0 0.000000 0 0 26864 604842 1675.015974 1675.015974 1 MULTILINESTRING ((1731848.082 6017486.385, 173...
593514 593620 593515 -1 53587.929573 5.503258e+07 7260002 1 NaN 0 239462 5 0.000000 4.917045 3.455193 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000 0 0 0.000000 0 0 244056 604843 156.868127 156.868127 1 MULTILINESTRING ((1789499.342 5528919.92, 1789...
593515 593621 593516 593515 8667.469549 5.432822e+07 7260001 1 NaN 0 239461 5 0.000000 6.187159 4.917045 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000 0 0 0.000000 0 0 244073 244056 116.148688 116.148688 1 MULTILINESTRING ((1789607.824 5528878.42, 1789...
593516 593622 593517 -1 492400.109562 1.856727e+08 7247115 1 529.317107 0 249508 5 964.116694 5.069054 1.886685 1.782739e+06 1.782650e+06 5.496834e+06 5.497794e+06 1.086063 7047051 36796 0.272352 0 0 252501 604844 151.702564 151.702564 1 MULTILINESTRING ((1782739.481 5497793.71, 1782...

593517 rows × 30 columns

In [21]:
REC[REC.intersects(largest_area.geometry)].explore("euclid_dis", legend=True, tiles="ESRI.WorldImagery")
✔️ 2.03 s (2024-12-02T11:52:25/2024-12-02T11:52:27)
Out[21]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [22]:
LCDB = gpd.read_file("lcdb-v50-land-cover-database-version-50-mainland-new-zealand.gpkg", engine='pyogrio', use_arrow=True)
LCDB
✔️ 7.94 s (2024-12-02T11:52:27/2024-12-02T11:52:35)
Out[22]:
Name_2018 Name_2012 Name_2008 Name_2001 Name_1996 Class_2018 Class_2012 Class_2008 Class_2001 Class_1996 Wetland_18 Wetland_12 Wetland_08 Wetland_01 Wetland_96 Onshore_18 Onshore_12 Onshore_08 Onshore_01 Onshore_96 EditAuthor EditDate LCDB_UID geometry
0 Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation 46 46 46 46 46 yes yes yes yes yes no no no no no Terralink 2004-06-30 lcdb2000096676 MULTIPOLYGON (((1613722.435 5425797.372, 16137...
1 Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation 46 46 46 46 46 yes yes yes yes yes no no no no no Regional Council 2019-12-01 lcdb1000513359 MULTIPOLYGON (((1816770.219 5947804.627, 18167...
2 Mangrove Mangrove Mangrove Mangrove Mangrove 70 70 70 70 70 yes yes yes yes yes no no no no no Terralink 2004-06-30 lcdb1000182160 MULTIPOLYGON (((1715672.186 5958842.706, 17156...
3 Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation Herbaceous Saline Vegetation 46 46 46 46 46 yes yes yes yes yes no no no no no Terralink 2004-06-30 lcdb1000065930 MULTIPOLYGON (((1705330.918 6088979.74, 170531...
4 Estuarine Open Water Estuarine Open Water Estuarine Open Water Estuarine Open Water Estuarine Open Water 22 22 22 22 22 no no no no no no no no no no Regional Council 2019-12-01 lcdb1000065472 MULTIPOLYGON (((1761684.636 5789742.527, 17616...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
511099 Low Producing Grassland Low Producing Grassland Low Producing Grassland Manuka and/or Kanuka Low Producing Grassland 41 41 41 52 41 no no no no no yes yes yes yes yes Landcare Research 2019-12-01 lcdb1000505810 MULTIPOLYGON (((1785112.194 5684560.595, 17851...
511100 Indigenous Forest Indigenous Forest Indigenous Forest Indigenous Forest Indigenous Forest 69 69 69 69 69 no no no no no yes yes yes yes yes Landcare Research 2019-12-01 lcdb2000193885 MULTIPOLYGON (((1607510.75 5432591.699, 160754...
511101 Exotic Forest Exotic Forest Exotic Forest Exotic Forest Exotic Forest 71 71 71 71 71 no no no no no yes yes yes yes yes Landcare Research 2011-06-30 lcdb2000219027 MULTIPOLYGON (((1603592.31 5269947.382, 160360...
511102 Herbaceous Freshwater Vegetation Herbaceous Freshwater Vegetation Herbaceous Freshwater Vegetation Herbaceous Freshwater Vegetation Herbaceous Freshwater Vegetation 45 45 45 45 45 yes yes yes yes yes yes yes yes yes yes Regional Council 2014-06-30 lcdb1000417326 MULTIPOLYGON (((1822629.596 5477414.336, 18226...
511103 High Producing Exotic Grassland High Producing Exotic Grassland Exotic Forest Exotic Forest Exotic Forest 40 40 71 71 71 no no no no no yes yes yes yes yes Landcare Research 2014-06-30 lcdb1000145507 MULTIPOLYGON (((1704402.741 5624819.729, 17044...

511104 rows × 24 columns

In [23]:
LCDB[LCDB.intersects(largest_area.geometry)]
✔️ 716 ms (2024-12-02T11:52:35/2024-12-02T11:52:36)
Out[23]:
Name_2018 Name_2012 Name_2008 Name_2001 Name_1996 Class_2018 Class_2012 Class_2008 Class_2001 Class_1996 Wetland_18 Wetland_12 Wetland_08 Wetland_01 Wetland_96 Onshore_18 Onshore_12 Onshore_08 Onshore_01 Onshore_96 EditAuthor EditDate LCDB_UID geometry
17220 Exotic Forest Exotic Forest Exotic Forest Exotic Forest High Producing Exotic Grassland 71 71 71 71 40 no no no no no yes yes yes yes yes Landcare Research 2011-06-30 lcdb1000053082 MULTIPOLYGON (((2054973.343 5805787.881, 20549...
18662 Gravel or Rock Gravel or Rock Gravel or Rock Gravel or Rock Gravel or Rock 16 16 16 16 16 no no no no no yes yes yes yes yes Landcare Research 2004-06-30 lcdb1000016122 MULTIPOLYGON (((2048258.705 5805949.487, 20482...
20295 Exotic Forest Exotic Forest Exotic Forest Exotic Forest Broadleaved Indigenous Hardwoods 71 71 71 71 54 no no no no no yes yes yes yes yes Landcare Research 2011-06-30 lcdb1000127897 MULTIPOLYGON (((2054496.624 5803468.778, 20545...
23069 Broadleaved Indigenous Hardwoods Broadleaved Indigenous Hardwoods Broadleaved Indigenous Hardwoods Broadleaved Indigenous Hardwoods Broadleaved Indigenous Hardwoods 54 54 54 54 54 no no no no no yes yes yes yes yes Landcare Research 2019-12-01 lcdb1000119141 MULTIPOLYGON (((2054140.516 5804625.89, 205416...
349500 Exotic Forest Exotic Forest Exotic Forest Exotic Forest Broadleaved Indigenous Hardwoods 71 71 71 71 54 no no no no no yes yes yes yes yes Landcare Research 2011-06-30 lcdb1000127894 MULTIPOLYGON (((2056301.039 5802553.702, 20562...
388204 Exotic Forest Exotic Forest Exotic Forest Exotic Forest Broadleaved Indigenous Hardwoods 71 71 71 71 54 no no no no no yes yes yes yes yes Landcare Research 2011-06-30 lcdb1000127900 MULTIPOLYGON (((2054727.599 5803954.788, 20547...
445455 Mixed Exotic Shrubland Mixed Exotic Shrubland Mixed Exotic Shrubland Mixed Exotic Shrubland Gravel or Rock 56 56 56 56 16 no no no no no yes yes yes yes yes Landcare Research 2019-12-01 lcdb2000515912 MULTIPOLYGON (((2055082.956 5803253.022, 20550...
In [24]:
LCDB[LCDB.intersects(largest_area.geometry)].drop(columns="EditDate").explore("Name_2018", legend=True, tiles="ESRI.WorldImagery")
✔️ 401 ms (2024-12-02T11:52:36/2024-12-02T11:52:36)
Out[24]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [25]:
areas.crs
✔️ 3.83 ms (2024-12-02T11:52:36/2024-12-02T11:52:36)
Out[25]:
<Projected CRS: EPSG:2193>
Name: NZGD2000 / New Zealand Transverse Mercator 2000
Axis Info [cartesian]:
- N[north]: Northing (metre)
- E[east]: Easting (metre)
Area of Use:
- name: New Zealand - North Island, South Island, Stewart Island - onshore.
- bounds: (166.37, -47.33, 178.63, -34.1)
Coordinate Operation:
- name: New Zealand Transverse Mercator 2000
- method: Transverse Mercator
Datum: New Zealand Geodetic Datum 2000
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich
In [26]:
any(LCDB.intersects(largest_area.geometry))
✔️ 322 ms (2024-12-02T11:52:37/2024-12-02T11:52:37)
Out[26]:
True
In [27]:
LCDB.loc[LCDB.intersects(largest_area.geometry), ["Class_2018", "Wetland_18", "Onshore_18"]].mode()
✔️ 341 ms (2024-12-02T11:52:37/2024-12-02T11:52:38)
Out[27]:
Class_2018 Wetland_18 Onshore_18
0 71 no yes
In [28]:
all_streams = REC.unary_union
✔️ 13 s (2024-12-02T11:52:38/2024-12-02T11:52:51)
/tmp/ipykernel_3784186/3529544978.py:1: DeprecationWarning: The 'unary_union' attribute is deprecated, use the 'union_all()' method instead.
  all_streams = REC.unary_union
In [29]:
features["distance_to_river"] = largest_area.geometry.distance(all_streams)
features["distance_to_river"]
✔️ 263 ms (2024-12-02T11:52:51/2024-12-02T11:52:51)
Out[29]:
0.0
In [30]:
def get_features(row):
    geom = row.geometry
    masked_old, transform = mask(old, [geom], nodata=np.nan)
    nonan = np.argwhere(~np.isnan(masked_old[0]))
    top_left = nonan.min(axis=0)
    bottom_right = nonan.max(axis=0)
    masked_old = masked_old[0][top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1]

    masked_new, transform = mask(new, [geom], nodata=np.nan)
    masked_new = masked_new[0][top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1]

    raster = rasterize([geom], out_shape=result.shape, transform=new.transform)
    masked_diff = np.where(raster, diff, np.nan)
    masked_diff = masked_diff[top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1]
    
    row = row.to_dict()
    row.update({
        "old_min": np.nanmin(masked_old),
        "old_max": np.nanmax(masked_old),
        "old_mean": np.nanmean(masked_old),
        "old_median": np.nanmedian(masked_old),
        "old_std": np.nanstd(masked_old),
        "new_min": np.nanmin(masked_new),
        "new_max": np.nanmax(masked_new),
        "new_mean": np.nanmean(masked_new),
        "new_median": np.nanmedian(masked_new),
        "new_std": np.nanstd(masked_new),
        "diff_min": np.nanmin(masked_diff),
        "diff_max": np.nanmax(masked_diff),
        "diff_mean": np.nanmean(masked_diff),
        "diff_median": np.nanmedian(masked_diff),
        "diff_std": np.nanstd(masked_diff),
        "distance_to_river": geom.distance(all_streams)
    })

    row.update(LCDB.loc[LCDB.intersects(geom), ["Class_2018", "Wetland_18", "Onshore_18"]].mode().iloc[0].replace({"no": False, "yes": True}))

    attribute_names = ["roughness", "slope", "aspect", "curvature", "terrain_ruggedness_index", "rugosity", "profile_curvature", "planform_curvature"]
    diff_attributes = xdem.terrain.get_terrain_attribute(
        masked_diff,
        resolution=old.res,
        attribute=attribute_names
    )
    old_attributes = xdem.terrain.get_terrain_attribute(
        masked_old,
        resolution=old.res,
        attribute=attribute_names
    )
    new_attributes = xdem.terrain.get_terrain_attribute(
        masked_new,
        resolution=old.res,
        attribute=attribute_names
    )

    for i, name in enumerate(attribute_names):
        row.update({
            f"old_{name}_min": np.nanmin(old_attributes[i]),
            f"old_{name}_max": np.nanmax(old_attributes[i]),
            f"old_{name}_mean": np.nanmean(old_attributes[i]),
            f"old_{name}_median": np.nanmedian(old_attributes[i]),
            f"old_{name}_std": np.nanstd(old_attributes[i]),
            f"new_{name}_min": np.nanmin(new_attributes[i]),
            f"new_{name}_max": np.nanmax(new_attributes[i]),
            f"new_{name}_mean": np.nanmean(new_attributes[i]),
            f"new_{name}_median": np.nanmedian(new_attributes[i]),
            f"new_{name}_std": np.nanstd(new_attributes[i]),
            f"diff_{name}_min": np.nanmin(diff_attributes[i]),
            f"diff_{name}_max": np.nanmax(diff_attributes[i]),
            f"diff_{name}_mean": np.nanmean(diff_attributes[i]),
            f"diff_{name}_median": np.nanmedian(diff_attributes[i]),
            f"diff_{name}_std": np.nanstd(diff_attributes[i]),
        })

    return pd.Series(row)

#get_features(areas.iloc[0])
features = areas.progress_apply(get_features, axis=1)
features
✔️ 6 min 22 s (2024-12-02T11:52:51/2024-12-02T11:59:14)
  0%|          | 0/188 [00:00<?, ?it/s]
Out[30]:
geometry area old_min old_max old_mean old_median old_std new_min new_max new_mean new_median new_std diff_min diff_max diff_mean diff_median diff_std distance_to_river Class_2018 Wetland_18 Onshore_18 old_roughness_min old_roughness_max old_roughness_mean old_roughness_median old_roughness_std new_roughness_min new_roughness_max new_roughness_mean new_roughness_median new_roughness_std diff_roughness_min diff_roughness_max diff_roughness_mean diff_roughness_median diff_roughness_std old_slope_min old_slope_max old_slope_mean old_slope_median old_slope_std new_slope_min new_slope_max new_slope_mean new_slope_median new_slope_std diff_slope_min diff_slope_max diff_slope_mean diff_slope_median diff_slope_std old_aspect_min old_aspect_max old_aspect_mean old_aspect_median old_aspect_std new_aspect_min new_aspect_max new_aspect_mean new_aspect_median new_aspect_std diff_aspect_min diff_aspect_max diff_aspect_mean diff_aspect_median diff_aspect_std old_curvature_min old_curvature_max old_curvature_mean old_curvature_median old_curvature_std new_curvature_min new_curvature_max new_curvature_mean new_curvature_median new_curvature_std diff_curvature_min diff_curvature_max diff_curvature_mean diff_curvature_median diff_curvature_std old_terrain_ruggedness_index_min old_terrain_ruggedness_index_max old_terrain_ruggedness_index_mean old_terrain_ruggedness_index_median old_terrain_ruggedness_index_std new_terrain_ruggedness_index_min new_terrain_ruggedness_index_max new_terrain_ruggedness_index_mean new_terrain_ruggedness_index_median new_terrain_ruggedness_index_std diff_terrain_ruggedness_index_min diff_terrain_ruggedness_index_max diff_terrain_ruggedness_index_mean diff_terrain_ruggedness_index_median diff_terrain_ruggedness_index_std old_rugosity_min old_rugosity_max old_rugosity_mean old_rugosity_median old_rugosity_std new_rugosity_min new_rugosity_max new_rugosity_mean new_rugosity_median new_rugosity_std diff_rugosity_min diff_rugosity_max diff_rugosity_mean diff_rugosity_median diff_rugosity_std old_profile_curvature_min old_profile_curvature_max old_profile_curvature_mean old_profile_curvature_median old_profile_curvature_std new_profile_curvature_min new_profile_curvature_max new_profile_curvature_mean new_profile_curvature_median new_profile_curvature_std diff_profile_curvature_min diff_profile_curvature_max diff_profile_curvature_mean diff_profile_curvature_median diff_profile_curvature_std old_planform_curvature_min old_planform_curvature_max old_planform_curvature_mean old_planform_curvature_median old_planform_curvature_std new_planform_curvature_min new_planform_curvature_max new_planform_curvature_mean new_planform_curvature_median new_planform_curvature_std diff_planform_curvature_min diff_planform_curvature_max diff_planform_curvature_mean diff_planform_curvature_median diff_planform_curvature_std
176 POLYGON ((2054419 5803910, 2054419 5803909, 20... 530308.0 264.148010 520.244995 347.975189 350.695984 49.789028 264.705994 519.897034 356.345886 364.740967 53.155849 -6.874023 43.521973 8.370939 4.911972 9.060170 0.000000 71 False True 0.011993 15.246002 0.813846 0.357971 0.986039 0.000000 24.876007 0.605599 0.298004 0.856395 0.024994 16.997986 0.866442 0.501007 0.900825 0.000000 79.826914 15.070274 7.370222 15.627128 0.000000 85.002716 11.247439 5.880780 13.130905 0.000309 83.094493 15.825287 9.967977 14.601295 0.000000 359.999437 142.213513 140.381350 85.871897 0.000000 359.999447 143.702192 148.718709 74.913813 0.000000 359.999759 172.747728 183.009274 104.099068 -987.597656 618.389893 -1.687098 -0.201416 28.131659 -1635.809326 2639.611816 0.044426 0.000000 34.811855 -1643.609619 2639.605713 1.731523 0.808716 43.725699 0.012652 13.388140 0.820005 0.377151 0.959593 0.000000 31.845440 0.621672 0.320248 0.857954 0.024669 27.121265 0.893986 0.540642 0.893833 1.000023 5.817036 1.104334 1.012619 0.214678 1.000000 12.571797 1.070123 1.009403 0.200252 1.000079 9.886722 1.108306 1.026156 0.199585 -382.194110 650.668520 1.567452 0.189370 18.953910 -1703.312897 1357.086958 0.286885 0.000000 23.323260 -1767.249520 1433.146525 -1.254866 -0.584297 28.491703 -336.929136 280.484480 -0.119620 0.002551 13.513719 -770.656443 952.747795 0.331345 0.000000 16.410531 -624.432617 978.029107 0.476682 0.186515 21.372796
155 POLYGON ((2054514 5804756, 2054514 5804755, 20... 319463.0 384.855011 949.697021 698.896851 715.611023 132.071274 384.348999 949.190002 684.987671 692.672974 129.693771 -52.056030 5.609009 -13.909487 -9.703979 12.755947 0.000000 54 False True 0.036011 7.057983 1.615773 1.567993 0.702248 0.052979 10.955994 1.925666 1.877991 0.849821 0.027039 10.799988 1.465731 1.246033 0.944709 0.143641 68.213911 30.776987 31.572131 10.751121 0.086116 78.388411 34.906420 36.187041 11.525419 0.021028 77.297658 26.350639 24.870094 14.383982 0.153299 359.678922 193.689923 196.743656 39.959922 0.156069 359.988549 193.572123 195.402276 48.195220 0.000000 359.999410 183.019811 185.773786 100.256831 -396.191406 449.609375 0.419435 0.195312 30.873878 -887.304688 683.996582 -0.717594 -1.000977 50.070978 -954.620361 692.401123 -1.137023 -1.690674 58.625323 0.034709 6.135811 1.569799 1.538249 0.656465 0.066506 11.827429 1.892576 1.846572 0.831678 0.035931 10.752627 1.490565 1.282474 0.923966 1.000112 2.712165 1.208675 1.181108 0.150430 1.000628 4.989071 1.289567 1.253175 0.219370 1.000176 4.733187 1.209573 1.132283 0.229804 -297.336262 281.595911 -0.216688 -0.107691 18.303772 -430.834987 558.189379 0.389590 0.387500 28.101736 -440.434936 585.141157 0.664059 0.707163 35.661075 -226.754572 278.360866 0.202747 0.147264 16.836719 -329.115308 325.603230 -0.328004 -0.200578 29.185825 -369.479204 312.140260 -0.473099 -0.604222 31.241830
37 POLYGON ((2056589 5808659, 2056589 5808657, 20... 304243.0 543.239014 968.459961 752.026978 758.137024 89.943939 542.731018 968.713989 750.921082 757.086975 90.210747 -13.114990 5.141968 -1.105809 -0.944031 1.355662 0.000000 12 False True 0.026001 5.880920 1.092455 0.981018 0.594755 0.023987 6.030029 1.145941 1.003967 0.665144 0.014038 6.578003 0.709351 0.576965 0.492890 0.059968 65.257364 22.147059 20.918663 10.703999 0.020401 68.914877 22.821479 21.197918 11.516725 0.019821 66.326472 13.694865 11.374013 9.495378 0.000000 359.999189 124.863880 76.216373 121.643387 0.000000 359.999433 125.577582 77.578296 121.071010 0.000000 359.998682 180.263642 180.474840 104.744639 -357.995605 491.906738 0.355992 0.012207 25.225392 -448.986816 410.400391 -1.615505 -0.585938 31.171988 -472.998047 416.595459 -1.971487 -1.379395 39.778407 0.025389 6.711020 1.079740 0.966075 0.584580 0.025599 7.423714 1.139057 0.991976 0.658104 0.014390 5.968466 0.742228 0.609774 0.502908 1.000059 2.550049 1.113527 1.075567 0.112212 1.000070 2.881251 1.127535 1.079821 0.134691 1.000017 2.568007 1.063572 1.033145 0.087242 -275.565840 363.708496 -0.161719 -0.011238 15.094135 -231.462837 353.135175 0.948850 0.260109 18.911185 -275.317190 316.405986 1.262352 0.660475 23.922942 -186.447623 228.270899 0.194273 0.018219 13.673287 -208.265517 231.109694 -0.666655 -0.131640 16.789105 -335.581215 226.580603 -0.709152 -0.401965 21.456914
115 POLYGON ((2054495 5806342, 2054495 5806340, 20... 173781.0 333.551025 461.656006 378.365387 375.186005 26.501810 334.056000 461.194000 381.083679 378.898010 26.786768 -4.665009 12.177979 2.718257 2.453003 1.906919 0.000000 12 False True 0.014008 9.388000 0.677875 0.377991 0.809535 0.000000 13.169983 0.500877 0.257996 0.733357 0.028015 6.747986 0.664326 0.454987 0.605888 0.020094 75.921808 12.770494 7.700856 13.092742 0.000000 78.546067 9.365190 5.019157 11.374223 0.028203 69.110675 12.514475 8.870377 11.030167 0.000000 359.998988 143.421873 139.931397 83.692273 0.000000 359.998959 140.643502 135.437162 73.845481 0.000000 359.999000 164.568461 177.295377 100.462405 -535.192871 556.091309 -2.716478 -1.409912 31.838496 -597.601318 662.799072 -0.109209 0.109863 28.533340 -553.802490 687.600708 2.607275 1.797485 41.001715 0.015763 10.321819 0.695710 0.395150 0.815382 0.000000 11.936360 0.518734 0.274118 0.741411 0.032552 7.412247 0.699980 0.489235 0.623502 1.000043 4.193018 1.076419 1.013918 0.181408 1.000000 5.070165 1.052140 1.006947 0.171100 1.000124 2.874868 1.065598 1.021682 0.119312 -363.294747 396.078253 2.560642 1.164279 22.388314 -480.217390 552.721923 0.428056 -0.044049 19.206594 -479.441262 366.685717 -2.050307 -1.421865 27.232389 -263.949719 302.255294 -0.155819 -0.002418 14.162880 -302.559382 333.603464 0.318558 0.204243 13.589009 -357.169244 403.752029 0.556968 0.261994 19.498026
126 POLYGON ((2054821 5806083, 2054821 5806082, 20... 147413.0 405.266998 984.378967 666.230042 680.250000 128.762848 404.644012 984.406982 662.956543 677.700012 128.024765 -25.545959 10.151001 -3.273446 -2.276978 3.636282 0.000000 71 False True 0.013977 9.799988 1.897941 1.830994 0.998610 0.068024 9.049988 2.091734 2.042969 1.022423 0.049988 8.898010 1.275577 1.083984 0.813165 0.304217 75.238360 33.962256 35.759127 13.439006 0.275817 75.670884 36.282362 38.212662 13.350132 0.040820 73.866107 23.143639 21.255515 13.418823 0.000000 359.999124 157.248090 135.652681 114.426702 0.000000 359.999338 161.081901 137.127876 110.325155 0.000000 359.998574 184.088882 176.004473 102.389142 -603.796387 493.811035 0.157306 0.012207 36.876663 -741.406250 808.801270 -3.843777 -3.002930 51.480536 -767.303467 707.580566 -4.001010 -3.497314 62.809494 0.012950 9.102864 1.845368 1.799107 0.943181 0.085196 9.792164 2.035272 1.988031 0.979830 0.051240 8.480720 1.322321 1.132742 0.821058 1.000015 3.965516 1.286322 1.240496 0.246071 1.000924 4.062382 1.333409 1.288019 0.262484 1.000402 3.628650 1.171587 1.106380 0.191066 -327.484642 402.217137 0.033293 -0.009619 22.009401 -546.160758 450.024782 2.402529 1.295699 30.575169 -536.233840 418.001613 2.441112 1.776779 38.928714 -342.082703 350.547810 0.190599 0.028559 20.121584 -392.257973 352.410999 -1.441247 -1.049155 28.378480 -393.931141 379.570854 -1.559898 -1.174689 33.025140
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
51 POLYGON ((2057180 5807155, 2057180 5807154, 20... 4309.0 754.164001 862.838013 810.229065 812.798035 27.570267 753.013000 862.265991 808.988464 811.622009 27.611164 -5.234009 0.836975 -1.240615 -1.079041 0.706411 377.665475 69 False True 0.862000 5.342041 2.418738 2.452026 0.654043 0.961975 6.997009 2.452310 2.343506 0.656909 0.091980 3.499023 0.810893 0.724518 0.466198 7.297403 66.831758 43.179100 44.379501 7.779697 20.054158 68.072071 43.621004 42.706191 6.913516 0.258646 54.086741 15.535889 14.296695 9.054989 35.303553 314.984212 189.433762 177.787442 37.393464 130.464061 336.569548 188.786728 176.555501 36.995518 0.000000 359.873676 180.929910 181.396905 105.351676 -466.186523 231.799316 0.527063 0.097656 39.948877 -245.996094 119.812012 -6.563127 -2.453613 31.257455 -295.800781 442.993164 -7.090177 -4.492188 47.193806 0.814646 5.598710 2.415604 2.431221 0.640636 0.962379 6.180429 2.438234 2.285079 0.665418 0.086022 3.618491 0.855655 0.758100 0.486536 1.073822 2.615977 1.416230 1.409118 0.184599 1.076960 2.694157 1.421669 1.367197 0.204674 1.001061 1.724303 1.077381 1.049964 0.088696 -183.252569 271.567569 -1.161028 -0.062861 22.652142 -81.848339 147.545809 1.926143 0.388606 17.918339 -238.362703 175.115296 2.803598 1.571423 27.481605 -194.618954 131.252141 -0.633965 0.033732 23.575519 -134.954866 67.502446 -4.636984 -1.530424 18.541685 -176.705037 204.630461 -4.286579 -2.724701 26.676936
77 POLYGON ((2057221 5806249, 2057221 5806248, 20... 4231.0 463.237000 558.276001 506.580353 501.701996 21.162735 462.401001 557.640991 504.420471 500.536987 21.546041 -9.316010 0.420044 -2.159984 -1.524994 1.754438 0.000000 16 False True 0.253998 5.921997 2.383448 2.287994 1.030381 0.422028 6.760010 2.422792 2.309998 0.838149 0.123962 5.431030 1.354514 1.208984 0.781550 5.131232 67.666628 40.237979 40.998544 12.378692 8.655775 67.904992 41.710540 41.690704 9.490442 0.243961 63.330647 24.899263 23.870917 12.951836 0.281502 359.783101 67.853488 61.358284 55.134721 0.008154 359.839936 66.387609 60.087674 53.433536 0.117864 359.932983 184.918589 175.719571 102.218871 -228.100586 368.609619 5.698443 0.305176 37.012155 -301.403809 187.207031 -5.867077 -3.295898 41.224008 -365.005493 229.119873 -11.565558 -9.808350 54.859841 0.220716 5.918797 2.283590 2.195514 0.979771 0.426887 6.027872 2.346393 2.225846 0.813919 0.102363 4.997128 1.382453 1.254762 0.757155 1.004053 2.677477 1.397387 1.338811 0.272643 1.018046 2.661962 1.403323 1.350940 0.239105 1.000989 2.266732 1.179069 1.126430 0.172435 -207.845305 143.786976 -3.793339 -0.195312 21.086335 -127.668387 153.460206 2.340637 1.300801 23.080101 -180.493919 211.376430 5.078110 3.214066 31.870435 -124.158137 160.764314 1.905104 0.146811 21.001286 -148.018753 120.872095 -3.526440 -1.380111 24.167658 -207.633207 137.569661 -6.487448 -5.183216 31.373435
181 POLYGON ((2054921 5802132, 2054921 5802131, 20... 4168.0 727.848999 777.617981 750.956482 751.011475 10.164408 727.346008 777.073975 748.487061 747.432495 10.804439 -7.746033 0.098999 -2.469438 -1.833984 1.776451 313.839735 71 False True 0.091980 3.315979 1.433986 1.580017 0.569036 0.364990 3.245972 1.419160 1.384033 0.423065 0.050049 2.488037 0.713715 0.641541 0.372780 1.098170 49.399885 27.509585 31.135594 9.159969 8.623230 52.231216 28.404272 28.099978 7.057982 0.161113 41.709637 14.652946 13.619203 7.531259 4.078816 350.963453 119.304579 127.164299 21.703204 66.883923 215.329236 125.795694 121.523206 23.943849 0.239895 359.927197 183.505383 172.413544 104.640565 -204.504395 161.499023 0.959035 0.000000 16.585738 -126.196289 107.800293 -2.077581 -1.501465 19.117937 -209.301758 189.300537 -3.036568 -1.809692 25.295615 0.103171 2.887991 1.326473 1.490779 0.488372 0.425771 3.221281 1.367897 1.320521 0.410827 0.050731 2.201049 0.710312 0.651643 0.352425 1.001146 1.541166 1.151220 1.170559 0.089427 1.014477 1.637875 1.154505 1.135886 0.087239 1.000237 1.344907 1.051155 1.036017 0.048002 -87.581979 113.251887 -0.649685 -0.011023 10.550427 -67.483272 81.503804 1.015562 0.649885 11.334083 -116.756886 137.333515 1.427443 0.626500 14.888978 -95.272541 74.323632 0.309349 0.000000 7.803784 -57.412187 51.057154 -1.062019 -0.666110 10.300071 -90.982558 93.936800 -1.609124 -0.725124 13.837087
112 POLYGON ((2056165 5805098, 2056165 5805097, 20... 4168.0 330.009003 414.976013 347.387390 338.135986 19.942204 329.310974 414.473022 345.676178 335.724487 20.337126 -6.242035 0.404999 -1.711227 -1.103989 1.331259 20.061887 16 False True 0.034027 4.681000 1.260574 1.067993 1.077490 0.055969 7.058014 1.389383 0.999023 1.233171 0.067993 5.648010 0.916036 0.627975 0.812676 0.064318 63.088289 23.554792 21.649303 18.872994 0.369729 71.973824 24.741835 19.494937 19.787166 0.072869 67.422201 16.667242 11.679819 14.067467 0.316361 357.224694 160.004295 173.322019 56.523348 0.479943 359.992713 151.516241 164.790807 60.669078 0.000371 359.989076 160.836444 161.757142 101.798624 -177.001953 431.005859 1.097549 0.000000 34.143251 -624.798584 281.402588 -9.696480 -3.903198 43.573170 -645.401001 310.797119 -10.793974 -5.749512 54.868025 0.040245 5.232248 1.300285 1.144392 1.091766 0.056225 7.955593 1.425942 1.049131 1.246595 0.061296 7.057928 0.977414 0.664636 0.868992 1.000155 2.240313 1.195881 1.103788 0.221883 1.000398 3.304296 1.229885 1.090967 0.281707 1.000381 2.796020 1.118655 1.040430 0.184431 -214.626248 120.703019 -1.065026 0.000000 25.228906 -190.885812 425.049505 6.683065 1.341190 32.265485 -213.102706 411.064214 7.399746 3.237263 38.168409 -116.901834 253.001386 0.032523 0.015642 16.091164 -199.749079 124.561000 -3.013415 -1.414476 19.181300 -249.806248 200.170430 -3.394228 -2.160090 26.729371
70 POLYGON ((2056954 5806554, 2056954 5806551, 20... 4069.0 580.815002 632.517029 607.255920 607.020020 11.594285 580.307007 632.016968 605.696106 604.859009 11.600400 -5.670044 -0.108032 -1.559806 -1.331970 0.911266 44.852111 69 False True 0.429016 3.679993 2.002929 1.985962 0.574013 0.492004 4.010010 2.038499 2.032501 0.588054 0.078003 2.404053 0.727969 0.664001 0.367533 9.476656 56.456498 37.384745 38.126525 7.814650 4.951910 56.780866 37.360473 38.628186 7.718352 0.283751 40.625595 14.404642 13.091004 7.748489 0.000000 359.607342 78.049300 67.815717 61.717324 0.325269 359.680672 76.051164 65.030331 56.452893 0.185128 359.981782 184.885313 190.514454 104.413637 -182.897949 156.396484 3.885644 0.195312 25.011336 -165.515137 157.006836 -2.436468 -0.903320 25.829390 -207.397461 179.193115 -6.322378 -4.388428 34.206604 0.505644 3.813717 1.946766 1.947002 0.524042 0.435629 4.016717 1.943065 1.975381 0.506510 0.078687 2.184222 0.748892 0.687885 0.359458 1.021333 1.838914 1.288482 1.276383 0.131050 1.015939 1.857929 1.286898 1.284802 0.125296 1.000577 1.326722 1.056693 1.041069 0.049973 -109.279958 104.358946 -1.918385 -0.122937 14.980567 -86.383262 126.824579 1.251487 0.604351 15.566927 -87.630775 112.695939 2.519276 1.309808 19.584720 -82.387921 90.554320 1.967260 0.048254 13.946112 -99.726944 71.273957 -1.184981 -0.256913 13.858576 -115.848622 91.562340 -3.803102 -2.074324 19.314333

188 rows × 141 columns

In [31]:
features.crs = new.crs
✔️ 22.7 ms (2024-12-02T11:59:14/2024-12-02T11:59:14)
In [32]:
features.explore("Class_2018", legend=True, tiles="ESRI.WorldImagery")
✔️ 2.1 s (2024-12-02T11:59:14/2024-12-02T11:59:16)
Out[32]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [34]:
features.to_parquet(f"{tilename}.parquet")
✔️ 61.1 ms (2024-12-02T12:01:27/2024-12-02T12:01:27)