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)" ] }, { diff --git a/modules/06-spatial-data/lecture.ipynb b/modules/06-spatial-data/lecture.ipynb index 51ae935..6a83fc3 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\")" ] }, { @@ -831,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", 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", 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",