We determine the Smith normal forms of the incidence matrices of points and projective
(
r
−
1
)
(r-1)
-dimensional subspaces of
PG
(
n
,
q
)
\operatorname {PG}(n,q)
and of the incidence matrices of points and
r
r
-dimensional affine subspaces of
AG
(
n
,
q
)
\operatorname {AG}(n,q)
for all
n
n
,
r
r
, and arbitrary prime power
q
q
.