Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Mar 6, 2024
1 parent 111e81a commit e6c7270
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions modules/09-spatial-analysis/lecture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,8 @@
"metadata": {},
"outputs": [],
"source": [
"# get the tract labels (GEOIDs) and pick one (arbitrarily) to work with throughout\n",
"labels = tracts.index.tolist()\n",
"label = labels[603]\n",
"label"
"# arbitrarily pick one tract label (GEOID) to work with throughout\n",
"label = \"06037269905\""
]
},
{
Expand All @@ -346,7 +344,7 @@
"outputs": [],
"source": [
"# calculate rook spatial weights\n",
"w_rook = weights.Rook.from_dataframe(tracts, ids=labels, id_order=labels)"
"w_rook = weights.Rook.from_dataframe(tracts, use_index=True)"
]
},
{
Expand Down Expand Up @@ -376,7 +374,7 @@
"outputs": [],
"source": [
"# calculate queen spatial weights\n",
"w_queen = weights.Queen.from_dataframe(tracts, ids=labels, id_order=labels)"
"w_queen = weights.Queen.from_dataframe(tracts, use_index=True)"
]
},
{
Expand Down Expand Up @@ -553,7 +551,7 @@
"x = tracts.centroid.x\n",
"y = tracts.centroid.y\n",
"coords = np.array([x, y]).T\n",
"threshold = weights.min_threshold_distance(coords)\n",
"threshold = np.ceil(weights.min_threshold_distance(coords))\n",
"threshold"
]
},
Expand Down Expand Up @@ -825,7 +823,8 @@
"outputs": [],
"source": [
"# recompute spatial weights for just these observations then row-standardize\n",
"w_queen = weights.Queen.from_dataframe(tracts_not_null)\n",
"# may get disconnected components because we dropped tracts with null values\n",
"w_queen = weights.Queen.from_dataframe(tracts_not_null, use_index=True)\n",
"w_queen.set_transform(\"R\")"
]
},
Expand Down

0 comments on commit e6c7270

Please sign in to comment.