From 83ea425875061ec94dbec81a19b7394dd7d33014 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Wed, 7 Feb 2024 17:06:10 -0800 Subject: [PATCH 1/4] fix typo --- modules/05-geocoding-apis/lecture.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/05-geocoding-apis/lecture.ipynb b/modules/05-geocoding-apis/lecture.ipynb index 1266151..fe52f33 100644 --- a/modules/05-geocoding-apis/lecture.ipynb +++ b/modules/05-geocoding-apis/lecture.ipynb @@ -941,7 +941,7 @@ "ax = vacant.plot(c=\"b\", markersize=1, alpha=0.5)\n", "\n", "occupied = parking[parking[\"occupancystate\"] == \"OCCUPIED\"]\n", - "ax = vacant.plot(ax=ax, c=\"r\", markersize=1, alpha=0.5)" + "ax = occupied.plot(ax=ax, c=\"r\", markersize=1, alpha=0.5)" ] }, { From eb48b2f53d73c9c4192b835b68d4c6f37dce9544 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Tue, 13 Feb 2024 21:14:31 -0800 Subject: [PATCH 2/4] update --- modules/06-spatial-data/lecture.ipynb | 16 +++++++--------- modules/06-spatial-data/raster-crop-bbox.ipynb | 5 +++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/06-spatial-data/lecture.ipynb b/modules/06-spatial-data/lecture.ipynb index 51ae935..b3ff82b 100644 --- a/modules/06-spatial-data/lecture.ipynb +++ b/modules/06-spatial-data/lecture.ipynb @@ -28,7 +28,6 @@ "import folium\n", "import geopandas as gpd\n", "import matplotlib.pyplot as plt\n", - "import numpy as np\n", "import pandas as pd\n", "import rasterio\n", "import rasterio.features" @@ -171,9 +170,10 @@ "metadata": {}, "outputs": [], "source": [ - "# create a geopandas geodataframe from the pandas dataframe\n", - "gdf_business = gpd.GeoDataFrame(df)\n", - "gdf_business.shape" + "# create a geometry array to contain shapely geometry for geopandas to use\n", + "# notice the shapely points are lng, lat so that they are equivalent to x, y\n", + "geometry = gpd.points_from_xy(x=df[\"lng\"], y=df[\"lat\"])\n", + "geometry[:5]" ] }, { @@ -182,11 +182,9 @@ "metadata": {}, "outputs": [], "source": [ - "# create a geometry column to contain shapely geometry for geopandas to use\n", - "# notice the shapely points are lng, lat so that they are equivalent to x, y\n", + "# create a geopandas geodataframe from the pandas dataframe\n", "# also notice that we set the CRS explicitly\n", - "gdf_business[\"geometry\"] = gpd.points_from_xy(x=gdf_business[\"lng\"], y=gdf_business[\"lat\"])\n", - "gdf_business.crs = \"epsg:4326\"\n", + "gdf_business = gpd.GeoDataFrame(df, geometry=geometry, crs=\"epsg:4326\")\n", "gdf_business.shape" ] }, @@ -418,7 +416,7 @@ "# takes a few seconds...\n", "# dissolve lets you aggregate (merge geometries together) by shared attribute values\n", "# this is the spatial equivalent of pandas's groupby function\n", - "gdf_counties = gdf_tracts.dissolve(by=\"COUNTYFP\", aggfunc=np.sum)" + "gdf_counties = gdf_tracts.dissolve(by=\"COUNTYFP\", aggfunc=\"sum\")" ] }, { diff --git a/modules/06-spatial-data/raster-crop-bbox.ipynb b/modules/06-spatial-data/raster-crop-bbox.ipynb index 55f93c6..dffd901 100644 --- a/modules/06-spatial-data/raster-crop-bbox.ipynb +++ b/modules/06-spatial-data/raster-crop-bbox.ipynb @@ -15,7 +15,8 @@ "metadata": {}, "outputs": [], "source": [ - "import rasterio.mask\n", + "import rasterio\n", + "from rasterio.mask import mask\n", "from shapely.wkt import loads" ] }, @@ -54,7 +55,7 @@ "outputs": [], "source": [ "# crop the raster to the bounding box\n", - "out_image, out_transform = rasterio.mask.mask(raster, [bbox], crop=True)\n", + "out_image, out_transform = mask(raster, [bbox], crop=True)\n", "out_meta = raster.meta\n", "out_meta.update(\n", " {\n", From 340ebd2d1135d57b6ce3e372963c4b610a7537cd Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Thu, 15 Feb 2024 13:48:39 -0800 Subject: [PATCH 3/4] typo --- modules/06-spatial-data/lecture.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/06-spatial-data/lecture.ipynb b/modules/06-spatial-data/lecture.ipynb index b3ff82b..6a83fc3 100644 --- a/modules/06-spatial-data/lecture.ipynb +++ b/modules/06-spatial-data/lecture.ipynb @@ -829,7 +829,7 @@ " legend_name=\"Businesses per square km\",\n", ").add_to(m)\n", "\n", - "# add mouseover tooltip to the countries\n", + "# add mouseover tooltip to the tracts\n", "c.geojson.add_child(folium.features.GeoJsonTooltip([\"GEOID\", \"density\"]))\n", "\n", "# save web map to disk\n", From d8fda13bb7e710e0b648d72ac03396688e336891 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Wed, 21 Feb 2024 17:02:24 -0800 Subject: [PATCH 4/4] fix typo --- modules/07-urban-networks-i/lecture.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/07-urban-networks-i/lecture.ipynb b/modules/07-urban-networks-i/lecture.ipynb index 8672e6b..df83381 100644 --- a/modules/07-urban-networks-i/lecture.ipynb +++ b/modules/07-urban-networks-i/lecture.ipynb @@ -637,7 +637,7 @@ "metadata": {}, "outputs": [], "source": [ - "# restaurants near the empire state buildings\n", + "# restaurants near the empire state building\n", "address = \"350 5th Ave, New York, NY 10001\"\n", "tags = {\"amenity\": \"restaurant\"}\n", "gdf = ox.geometries_from_address(address, tags=tags, dist=500)\n",