\n",
"
pyspark.sql.session.SparkSession
def __init__(sparkContext: SparkContext, jsparkSession: Optional[JavaObject]=None, options: Dict[str, Any]={})
/usr/local/lib/python3.10/dist-packages/pyspark/sql/session.pyThe entry point to programming Spark with the Dataset and DataFrame API.\n",
"\n",
"A SparkSession can be used to create :class:`DataFrame`, register :class:`DataFrame` as\n",
"tables, execute SQL over tables, cache tables, and read parquet files.\n",
"To create a :class:`SparkSession`, use the following builder pattern:\n",
"\n",
".. versionchanged:: 3.4.0\n",
" Supports Spark Connect.\n",
"\n",
".. autoattribute:: builder\n",
" :annotation:\n",
"\n",
"Examples\n",
"--------\n",
"Create a Spark session.\n",
"\n",
">>> spark = (\n",
"... SparkSession.builder\n",
"... .master("local")\n",
"... .appName("Word Count")\n",
"... .config("spark.some.config.option", "some-value")\n",
"... .getOrCreate()\n",
"... )\n",
"\n",
"Create a Spark session with Spark Connect.\n",
"\n",
">>> spark = (\n",
"... SparkSession.builder\n",
"... .remote("sc://localhost")\n",
"... .appName("Word Count")\n",
"... .config("spark.some.config.option", "some-value")\n",
"... .getOrCreate()\n",
"... ) # doctest: +SKIP
\n",
" \n",
"
"
]
},
"metadata": {},
"execution_count": 12
}
],
"source": [
"type(config)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "OdQM3oaYOjcO"
},
"source": [
"# Create SpatialRDD"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "X2umXxYfOjcO"
},
"source": [
"## Reading to PointRDD from CSV file"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "j8Rgv--0OjcP"
},
"source": [
"We now want load the CSV file into Apache Sedona PointRDD\n",
"```\n",
"testattribute0,-88.331492,32.324142,testattribute1,testattribute2\n",
"testattribute0,-88.175933,32.360763,testattribute1,testattribute2\n",
"testattribute0,-88.388954,32.357073,testattribute1,testattribute2\n",
"testattribute0,-88.221102,32.35078,testattribute1,testattribute2\n",
"testattribute0,-88.323995,32.950671,testattribute1,testattribute2\n",
"testattribute0,-88.231077,32.700812,testattribute1,testattribute2\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "a6pMS1VPxYx6",
"outputId": "8071a6be-01c2-45ac-ccb3-67cb0591beba"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"testattribute0,-88.331492,32.324142,testattribute1,testattribute2\r\n",
"testattribute0,-88.175933,32.360763,testattribute1,testattribute2\r\n",
"testattribute0,-88.388954,32.357073,testattribute1,testattribute2\r\n",
"testattribute0,-88.221102,32.35078,testattribute1,testattribute2\r\n",
"testattribute0,-88.323995,32.950671,testattribute1,testattribute2\r\n",
"testattribute0,-88.231077,32.700812,testattribute1,testattribute2\r\n",
"testattribute0,-88.349276,32.548266,testattribute1,testattribute2\r\n",
"testattribute0,-88.304259,32.488903,testattribute1,testattribute2\r\n",
"testattribute0,-88.182481,32.59966,testattribute1,testattribute2\r\n",
"testattribute0,-86.955186,32.617088,testattribute1,testattribute2\r\n"
]
}
],
"source": [
"!head data/arealm-small.csv"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"id": "gusbYu1fOjcP"
},
"outputs": [],
"source": [
"point_rdd = PointRDD(sc, \"data/arealm-small.csv\", 1, FileDataSplitter.CSV, True, 10)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Ykc5FwouOjcP",
"outputId": "d7af7db0-c274-41a5-9f3e-d238a00a028e"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"3000"
]
},
"metadata": {},
"execution_count": 15
}
],
"source": [
"## Getting approximate total count\n",
"point_rdd.approximateTotalCount"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 121
},
"id": "PdEjrrRHOjcP",
"outputId": "102de206-4006-4d41-f62c-638a199e5d46"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Envelope(-173.120769, -84.965961, 30.244859, 71.355134)"
],
"image/svg+xml": "