From 791b21bc4ad2eef225acc9e99d6340957df04079 Mon Sep 17 00:00:00 2001 From: ryanward-io Date: Sat, 4 Dec 2021 21:40:44 +1100 Subject: [PATCH] DOC: Replaced instances of deprecated op with predicate (#2249) --- benchmarks/sjoin.py | 4 +- doc/source/gallery/spatial_joins.ipynb | 78 +++++++++++++------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/benchmarks/sjoin.py b/benchmarks/sjoin.py index 0d06391..81dbacf 100644 --- a/benchmarks/sjoin.py +++ b/benchmarks/sjoin.py @@ -26,5 +26,5 @@ class Bench: self.df1, self.df2 = df1, df2 - def time_sjoin(self, op): - sjoin(self.df1, self.df2, op=op) + def time_sjoin(self, predicate): + sjoin(self.df1, self.df2, predicate=predicate) diff --git a/doc/source/gallery/spatial_joins.ipynb b/doc/source/gallery/spatial_joins.ipynb index a295c41..38f06e3 100644 --- a/doc/source/gallery/spatial_joins.ipynb +++ b/doc/source/gallery/spatial_joins.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# Spatial Joins\n", "\n", @@ -12,11 +13,11 @@ "A common use case might be a spatial join between a point layer and a polygon layer where you want to retain the point geometries and grab the attributes of the intersecting polygons.\n", "\n", "![illustration](https://web.natur.cuni.cz/~langhamr/lectures/vtfg1/mapinfo_1/about_gis/Image23.gif)" - ], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\n", "## Types of spatial joins\n", @@ -84,21 +85,22 @@ " 0101000000F0D88AA0E1A4EEBF7052F7E5B115E9BF | 2 | 20\n", "(4 rows) \n", "```" - ], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Spatial Joins between two GeoDataFrames\n", "\n", "Let's take a look at how we'd implement these using `GeoPandas`. First, load up the NYC test data into `GeoDataFrames`:" - ], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "%matplotlib inline\n", "from shapely.geometry import Point\n", @@ -118,101 +120,99 @@ "\n", "# Make sure they're using the same projection reference\n", "pointdf.crs = polydf.crs" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "pointdf" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "polydf" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "pointdf.plot()" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "polydf.plot()" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Joins" - ], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "join_left_df = pointdf.sjoin(polydf, how=\"left\")\n", "join_left_df\n", "# Note the NaNs where the point did not intersect a boro" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "join_right_df = pointdf.sjoin(polydf, how=\"right\")\n", "join_right_df\n", "# Note Staten Island is repeated" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "join_inner_df = pointdf.sjoin(polydf, how=\"inner\")\n", "join_inner_df\n", "# Note the lack of NaNs; dropped anything that didn't intersect" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "We're not limited to using the `intersection` binary predicate. Any of the `Shapely` geometry methods that return a Boolean can be used by specifying the `op` kwarg." - ], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": null, - "source": [ - "pointdf.sjoin(polydf, how=\"left\", op=\"within\")" - ], + "metadata": {}, "outputs": [], - "metadata": {} + "source": [ + "pointdf.sjoin(polydf, how=\"left\", predicate=\"within\")" + ] } ], "metadata": { @@ -236,4 +236,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +}