Skip to content

Commit 4b5784c

Browse files
committed
Tidy up variable names
1 parent a9b965e commit 4b5784c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

spatial_kde/kde.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ def spatial_kernel_density(
8888
kde_pnts = pd.DataFrame(kdt.query_ball_point(xy, r=radius), columns=["nn"])
8989

9090
# Filter out points that have no neighbours within the search radius
91-
# and therefore their KDE value will be 0
9291
kde_pnts["num"] = kde_pnts.nn.apply(len)
9392
kde_pnts = kde_pnts.query("num > 0").drop(columns=["num"])
9493

9594
# Slow implementation iterating over every pixel / point
9695
ndv = -9999
97-
Z_scalar = (ndv + np.zeros_like(xc)).flatten()
96+
z_scalar = (ndv + np.zeros_like(xc)).flatten()
9897

9998
# TODO vectorise this
10099
# calculate the KDE value for every point that has neighbours
@@ -106,34 +105,34 @@ def spatial_kernel_density(
106105
if weight_col:
107106
weights = [points.at[i, weight_col] for i in row.nn]
108107

109-
Z_scalar[row.Index] = quartic(
108+
z_scalar[row.Index] = quartic(
110109
distances=distances,
111110
radius=radius,
112111
weights=weights,
113112
scaled=scaled,
114113
)
115114

116115
# create the output raster
117-
Z = Z_scalar.reshape(xc.shape)
116+
z = z_scalar.reshape(xc.shape)
118117
with rasterio.open(
119118
fp=output_path,
120119
mode="w",
121120
driver=output_driver,
122-
height=Z.shape[0],
123-
width=Z.shape[1],
121+
height=z.shape[0],
122+
width=z.shape[1],
124123
count=1,
125-
dtype=Z.dtype,
124+
dtype=z.dtype,
126125
crs=CRS.from_user_input(points.crs),
127126
transform=rasterio.transform.from_bounds(
128127
west=bounds.min_x,
129128
south=bounds.min_y,
130129
east=bounds.max_x,
131130
north=bounds.max_y,
132-
width=Z.shape[1],
133-
height=Z.shape[0],
131+
width=z.shape[1],
132+
height=z.shape[0],
134133
),
135134
nodata=ndv,
136135
) as dst:
137136
# numpy arrays start at the "bottom left", whereas rasters are written
138137
# from the "top left", hence flipping the array up-down before writing
139-
dst.write(np.flipud(Z), 1)
138+
dst.write(np.flipud(z), 1)

0 commit comments

Comments
 (0)