You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2021/03/23 07:45:06 UTC
[incubator-sedona] branch master updated: Update Python Binder
examples
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sedona.git
The following commit(s) were added to refs/heads/master by this push:
new a8c4289 Update Python Binder examples
a8c4289 is described below
commit a8c42896a8fc2f15b56fe817121c965adf0dc2f5
Author: Jia Yu <ji...@apache.org>
AuthorDate: Tue Mar 23 00:44:45 2021 -0700
Update Python Binder examples
---
binder/ApacheSedonaSQL.ipynb | 9 ++++
...eSedonaSQL_SpatialJoin_AirportsPerCountry.ipynb | 54 +++++++++++-----------
2 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/binder/ApacheSedonaSQL.ipynb b/binder/ApacheSedonaSQL.ipynb
index 5643176..f3ec6f1 100644
--- a/binder/ApacheSedonaSQL.ipynb
+++ b/binder/ApacheSedonaSQL.ipynb
@@ -295,6 +295,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
+ "### Spatial Join - Range Join and RDD API Join\n",
+ "\n",
+ "Please refer to the example - airports per country: https://github.com/apache/incubator-sedona/blob/master/binder/ApacheSedonaSQL_SpatialJoin_AirportsPerCountry.ipynb"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### Converting GeoPandas to Apache Sedona"
]
},
diff --git a/binder/ApacheSedonaSQL_SpatialJoin_AirportsPerCountry.ipynb b/binder/ApacheSedonaSQL_SpatialJoin_AirportsPerCountry.ipynb
index b055d9f..2444575 100644
--- a/binder/ApacheSedonaSQL_SpatialJoin_AirportsPerCountry.ipynb
+++ b/binder/ApacheSedonaSQL_SpatialJoin_AirportsPerCountry.ipynb
@@ -18,7 +18,7 @@
"from sedona.utils.adapter import Adapter\n",
"from sedona.core.enums import GridType\n",
"from sedona.core.enums import IndexType\n",
- "from sedona.core.spatialOperator import JoinQuery"
+ "from sedona.core.spatialOperator import JoinQueryRaw"
]
},
{
@@ -182,7 +182,7 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -221,7 +221,7 @@
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -237,7 +237,7 @@
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -258,13 +258,13 @@
"considerBoundaryIntersection = True\n",
"airports_rdd.buildIndex(IndexType.QUADTREE, buildOnSpatialPartitionedRDD)\n",
"\n",
- "result_pair_rdd = JoinQuery.SpatialJoinQueryFlat(airports_rdd, countries_rdd, usingIndex, considerBoundaryIntersection)\n",
+ "result_pair_rdd = JoinQueryRaw.SpatialJoinQueryFlat(airports_rdd, countries_rdd, usingIndex, considerBoundaryIntersection)\n",
"\n",
"result2 = Adapter.toDf(result_pair_rdd, countries_rdd.fieldNames, airports.fieldNames, spark)\n",
"\n",
"result2.createOrReplaceTempView(\"join_result_with_all_cols\")\n",
"# Select the columns needed in the join\n",
- "result2 = spark.sql(\"SELECT geom_1 as country_geom, NAME_EN, geom_2 as airport_geom, name FROM join_result_with_all_cols\")"
+ "result2 = spark.sql(\"SELECT leftgeometry as country_geom, NAME_EN, rightgeometry as airport_geom, name FROM join_result_with_all_cols\")"
]
},
{
@@ -276,7 +276,7 @@
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -354,7 +354,7 @@
},
{
"cell_type": "code",
- "execution_count": 40,
+ "execution_count": 8,
"metadata": {
"scrolled": true
},
@@ -366,26 +366,26 @@
"+--------------------+--------------------+------------+\n",
"| NAME_EN| country_geom|AirportCount|\n",
"+--------------------+--------------------+------------+\n",
- "|Denmark ...|MULTIPOLYGON (((1...| 1|\n",
- "|Algeria ...|POLYGON ((8.57656...| 1|\n",
- "|Lesotho ...|POLYGON ((28.7369...| 1|\n",
- "|Pakistan ...|POLYGON ((76.7668...| 3|\n",
- "|Paraguay ...|POLYGON ((-58.159...| 1|\n",
- "|Madagascar ...|MULTIPOLYGON (((4...| 1|\n",
- "|United Kingdom ...|MULTIPOLYGON (((-...| 2|\n",
- "|Haiti ...|MULTIPOLYGON (((-...| 1|\n",
- "|Tanzania ...|MULTIPOLYGON (((3...| 1|\n",
- "|United Arab Emira...|MULTIPOLYGON (((5...| 1|\n",
- "|Nigeria ...|MULTIPOLYGON (((7...| 3|\n",
- "|Guinea ...|POLYGON ((-10.283...| 1|\n",
- "|Malta ...|MULTIPOLYGON (((1...| 1|\n",
+ "|Peru ...|POLYGON ((-69.965...| 1|\n",
+ "|Honduras ...|MULTIPOLYGON (((-...| 1|\n",
"|Mali ...|POLYGON ((-11.389...| 1|\n",
+ "|Bermuda ...|POLYGON ((-64.730...| 1|\n",
+ "|Ireland ...|MULTIPOLYGON (((-...| 1|\n",
+ "|Democratic Republ...|POLYGON ((30.7511...| 2|\n",
+ "|Bangladesh ...|MULTIPOLYGON (((8...| 1|\n",
+ "|Serbia ...|POLYGON ((21.3600...| 1|\n",
"|Croatia ...|MULTIPOLYGON (((1...| 1|\n",
- "|Saudi Arabia ...|MULTIPOLYGON (((3...| 2|\n",
"|Kenya ...|MULTIPOLYGON (((4...| 2|\n",
- "|Yemen ...|MULTIPOLYGON (((5...| 2|\n",
- "|Niger ...|POLYGON ((13.6063...| 1|\n",
+ "|Malta ...|MULTIPOLYGON (((1...| 1|\n",
+ "|United Arab Emira...|MULTIPOLYGON (((5...| 1|\n",
+ "|Brazil ...|MULTIPOLYGON (((-...| 12|\n",
+ "|Israel ...|POLYGON ((35.8691...| 1|\n",
"|Lithuania ...|MULTIPOLYGON (((2...| 1|\n",
+ "|Japan ...|MULTIPOLYGON (((1...| 3|\n",
+ "|Bulgaria ...|POLYGON ((28.0144...| 1|\n",
+ "|Guinea ...|POLYGON ((-10.283...| 1|\n",
+ "|The Bahamas ...|MULTIPOLYGON (((-...| 1|\n",
+ "|Afghanistan ...|POLYGON ((66.5222...| 1|\n",
"+--------------------+--------------------+------------+\n",
"only showing top 20 rows\n",
"\n"
@@ -408,7 +408,7 @@
},
{
"cell_type": "code",
- "execution_count": 41,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -417,13 +417,13 @@
"<AxesSubplot:>"
]
},
- "execution_count": 41,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAACXCAYAAAAGX2ymAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAABIMUlEQVR4nO29eZQkZ3Xg+7sRkUvtVV1Vve+t1i4kpEZiNWDMarMNGLAZrHmPGcYe+9kev/E8sGeefWyPh/EZjx/zxscYPDzLDIMMGDDGDKtZLGzQgnYkpJbU6kW9d1d1bblF3PfH/SKXqsysrDUzq+N3TnZnRmZEfBkV+d3v7qKqJCQkJCQkLIbX7gEkJCQkJHQHicBISEhISGiJRGAkJCQkJLREIjASEhISEloiERgJCQkJCS0RtHsA1YyNjenevXvbPYyEhISEVee+++47p6rj9d67QkRnV3Dsk/AVVX3dCg7R [...]
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAACXCAYAAAAGX2ymAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAABIEUlEQVR4nO29eZQk6VXY+7sRudWStVfve0/PPpqtNTPakITQCtosIQlkMX5PtgyGB5hn/CSwHxzAWOYY8+RnDkLCegyyrEESkhBC1ooWRiDNotn3npmeXqb37qquNZeI+/64X+RSlZmVtWRlZnX8zslTmZEZEV9GRX73u7uoKjExMTExMUvhtXsAMTExMTHdQSwwYmJiYmKaIhYYMTExMTFNEQuMmJiYmJimiAVGTExMTExTJNo9gErGxsZ0z5497R5GTExMzJpz3333nVXV8VrvXSais6s49gn4mqq+YRWHaIqO [...]
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]