From 78434a0a5a8ecb7483de90774861e28fc72e9ead Mon Sep 17 00:00:00 2001 From: ncclementi Date: Thu, 25 Jan 2024 10:19:52 -0500 Subject: [PATCH] docs(blog): update geospatial - no need to_array() --- docs/posts/ibis-duckdb-geospatial/index.qmd | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/posts/ibis-duckdb-geospatial/index.qmd b/docs/posts/ibis-duckdb-geospatial/index.qmd index b78f7764056a..575b25fdbd57 100644 --- a/docs/posts/ibis-duckdb-geospatial/index.qmd +++ b/docs/posts/ibis-duckdb-geospatial/index.qmd @@ -117,7 +117,7 @@ boroughs ``` ```{python} -boroughs.filter(boroughs.geom.intersects(broad_station.select(broad_station.geom).to_array())) +boroughs.filter(_.geom.intersects(broad_station.geom)) ``` ### `d_within` (ST_DWithin) @@ -133,15 +133,10 @@ streets Using the deferred API, we can check which streets are within `d=10` meters of distance. ```{python} -sts_near_broad = streets.filter(_.geom.d_within(broad_station.select(_.geom).to_array(), 10)) +sts_near_broad = streets.filter(_.geom.d_within(broad_station.geom, 10)) sts_near_broad ``` -::: {.callout-note} -In the previous query, `streets` and `broad_station` are different tables. We use [`to_array()`](../../reference/expression-tables.qmd#ibis.expr.types.relations.Table.to_array) to generate a -scalar subquery from a table with a single column (whose shape is scalar). -::: - To visualize the findings, we will convert the tables to GeoPandas DataFrames. ```{python} @@ -201,7 +196,7 @@ To find if there were any homicides in that area, we can find where the polygon 200 meters buffer to our "Broad St" station point intersects with the geometry column in our homicides table. ```{python} -h_near_broad = homicides.filter(_.geom.intersects(broad_station.select(_.geom.buffer(200)).to_array())) +h_near_broad = homicides.filter(_.geom.intersects(broad_station.geom.buffer(200))) h_near_broad ``` @@ -210,7 +205,7 @@ data we can't tell the street near which it happened. However, we can check if t distance of a street. ```{python} -h_street = streets.filter(_.geom.d_within(h_near_broad.select(_.geom).to_array(), 2)) +h_street = streets.filter(_.geom.d_within(h_near_broad.geom, 2)) h_street ```