This is an automated email from the ASF dual-hosted git repository. jiayu pushed a commit to branch prepare-1.7.2 in repository https://gitbox.apache.org/repos/asf/sedona.git
commit 5cae18cd35d58ec50d58e0adb4eff4c6c82cfb18 Author: John Bampton <[email protected]> AuthorDate: Fri Mar 28 14:58:42 2025 +1000 [DOCS] Format Python Markdown codeblocks with black (#1881) --- docs/tutorial/concepts/spatial-joins.md | 6 ++++-- docs/tutorial/files/geojson-sedona-spark.md | 14 ++++++++------ docs/tutorial/files/geopackage-sedona-spark.md | 12 ++++++------ docs/tutorial/files/geoparquet-sedona-spark.md | 21 +++++++++++++-------- docs/tutorial/files/shapefiles-sedona-spark.md | 20 ++++++++++++-------- 5 files changed, 43 insertions(+), 30 deletions(-) diff --git a/docs/tutorial/concepts/spatial-joins.md b/docs/tutorial/concepts/spatial-joins.md index b63efdf5d2..e58f30ee3e 100644 --- a/docs/tutorial/concepts/spatial-joins.md +++ b/docs/tutorial/concepts/spatial-joins.md @@ -164,13 +164,15 @@ Here is the content of the lines table: Here’s a join that matches any touching values: ```python -sedona.sql(""" +sedona.sql( + """ SELECT lines.id as line_id, polygons.id as polygon_id FROM lines LEFT JOIN polygons ON ST_Touches(lines.geometry, polygons.geometry); -""").show() +""" +).show() ``` Here’s the result of the join: diff --git a/docs/tutorial/files/geojson-sedona-spark.md b/docs/tutorial/files/geojson-sedona-spark.md index 56d4816efc..9b60859a1f 100644 --- a/docs/tutorial/files/geojson-sedona-spark.md +++ b/docs/tutorial/files/geojson-sedona-spark.md @@ -40,10 +40,14 @@ Here’s how to read a multiline GeoJSON file with Sedona: ```python df = ( - sedona.read.format("geojson").option("multiLine", "true").load("data/multiline_geojson.json") + sedona.read.format("geojson") + .option("multiLine", "true") + .load("data/multiline_geojson.json") .selectExpr("explode(features) as features") .select("features.*") - .withColumn("prop0", expr("properties['prop0']")).drop("properties").drop("type") + .withColumn("prop0", expr("properties['prop0']")) + .drop("properties") + .drop("type") ) df.show(truncate=False) ``` @@ -112,9 +116,7 @@ Here's how you can read many GeoJSON files: ```python df = ( - sedona.read.format("geojson") - .option("multiLine", "true") - .load("data/many_geojsons") + sedona.read.format("geojson").option("multiLine", "true").load("data/many_geojsons") ) ``` @@ -132,7 +134,7 @@ df = ( .load("data/singleline_geojson.json") .withColumn("prop0", expr("properties['prop0']")) .drop("properties") - .drop("type") + .drop("type") ) df.show(truncate=False) ``` diff --git a/docs/tutorial/files/geopackage-sedona-spark.md b/docs/tutorial/files/geopackage-sedona-spark.md index aeeb94c5c0..107f8ffa5b 100644 --- a/docs/tutorial/files/geopackage-sedona-spark.md +++ b/docs/tutorial/files/geopackage-sedona-spark.md @@ -113,11 +113,7 @@ gpkgs/ Here’s how you can read all the files: ```python -df = ( - sedona.read.format("geopackage") - .option("tableName", "my_layer") - .load("/tmp/gpkgs") -) +df = sedona.read.format("geopackage").option("tableName", "my_layer").load("/tmp/gpkgs") df.show() ``` @@ -143,7 +139,11 @@ Sedona is an excellent option for analyzing many GeoPackage files because it can You can also load data from raster tables in the GeoPackage file. To load raster data, you can use the following code. ```python -df = sedona.read.format("geopackage").option("tableName", "raster_table").load("/path/to/geopackage") +df = ( + sedona.read.format("geopackage") + .option("tableName", "raster_table") + .load("/path/to/geopackage") +) ``` Here are the contents of the DataFrame: diff --git a/docs/tutorial/files/geoparquet-sedona-spark.md b/docs/tutorial/files/geoparquet-sedona-spark.md index 11d95d9c6d..d5412cdff8 100644 --- a/docs/tutorial/files/geoparquet-sedona-spark.md +++ b/docs/tutorial/files/geoparquet-sedona-spark.md @@ -37,11 +37,14 @@ Let's see how to write a Sedona DataFrame to GeoParquet files. Start by creating a Sedona DataFrame: ```python -df = sedona.createDataFrame([ - ("a", 'LINESTRING(2.0 5.0,6.0 1.0)'), - ("b", 'LINESTRING(7.0 4.0,9.0 2.0)'), - ("c", 'LINESTRING(1.0 3.0,3.0 1.0)'), -], ["id", "geometry"]) +df = sedona.createDataFrame( + [ + ("a", "LINESTRING(2.0 5.0,6.0 1.0)"), + ("b", "LINESTRING(7.0 4.0,9.0 2.0)"), + ("c", "LINESTRING(1.0 3.0,3.0 1.0)"), + ], + ["id", "geometry"], +) df = df.withColumn("geometry", ST_GeomFromText(col("geometry"))) ``` @@ -258,13 +261,15 @@ Now, let’s apply a spatial filter to read points within a particular area: Here is the query: ```python -my_shape = 'POLYGON((4.0 3.5, 4.0 6.0, 8.0 6.0, 8.0 4.5, 4.0 3.5))' +my_shape = "POLYGON((4.0 3.5, 4.0 6.0, 8.0 6.0, 8.0 4.5, 4.0 3.5))" -res = sedona.sql(f''' +res = sedona.sql( + f""" select * from points where st_intersects(geometry, ST_GeomFromWKT('{my_shape}')) -''') +""" +) res.show(truncate=False) ``` diff --git a/docs/tutorial/files/shapefiles-sedona-spark.md b/docs/tutorial/files/shapefiles-sedona-spark.md index a7df23c521..dff3209162 100644 --- a/docs/tutorial/files/shapefiles-sedona-spark.md +++ b/docs/tutorial/files/shapefiles-sedona-spark.md @@ -38,13 +38,9 @@ from shapely.geometry import Point point1 = Point(0, 0) point2 = Point(1, 1) -data = { - 'name': ['Point A', 'Point B'], - 'value': [10, 20], - 'geometry': [point1, point2] -} +data = {"name": ["Point A", "Point B"], "value": [10, 20], "geometry": [point1, point2]} -gdf = gpd.GeoDataFrame(data, geometry='geometry') +gdf = gpd.GeoDataFrame(data, geometry="geometry") gdf.to_file("/tmp/my_geodata.shp") ``` @@ -98,7 +94,11 @@ df = ( The name of the geometry column is geometry by default. You can change the name of the geometry column using the `geometry.name` option. Suppose one of the non-spatial attributes is named "geometry", `geometry.name` must be configured to avoid conflict. ```python -df = sedona.read.format("shapefile").option("geometry.name", "geom").load("/path/to/shapefile") +df = ( + sedona.read.format("shapefile") + .option("geometry.name", "geom") + .load("/path/to/shapefile") +) ``` The character encoding of string attributes are inferred from the `.cpg` file. If you see garbled values in string fields, you can manually specify the correct charset using the `charset` option. For example: @@ -118,7 +118,11 @@ The character encoding of string attributes are inferred from the `.cpg` file. I === "Python" ```python - df = sedona.read.format("shapefile").option("charset", "UTF-8").load("/path/to/shapefile") + df = ( + sedona.read.format("shapefile") + .option("charset", "UTF-8") + .load("/path/to/shapefile") + ) ``` Let’s see how to load many Shapefiles into a Sedona DataFrame.
