Empty metadata while reading data from shape file or geojson file
XiaWuSharve opened this issue · 0 comments
XiaWuSharve commented
I want to load data from a shape file, the "metadata" column of the result dataframe contains all empty metadata like this:
+-----+--------+--------------------+--------+-----+
|point|polyline| polygon|metadata|valid|
+-----+--------+--------------------+--------+-----+
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
| null| null|magellan.Polygon@...| Map()| true|
+-----+--------+--------------------+--------+-----+
The shapefile: http://www.arcgis.com/home/item.html?id=b07a9393ecbd430795a6f6218443dccc
My code:
val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("SpatialQuery")
val spark: SparkSession = SparkSession.builder().config(conf).getOrCreate()
val path: String = "spatial-core/datas/"
val df: DataFrame = spark.read.format("magellan").load(path)
df.show()
Here is my project pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atguigu.spatial</groupId>
<artifactId>spatial-core</artifactId>
<version>1.0</version>
<repositories>
<!-- list of other repositories -->
<repository>
<id>SparkPackagesRepo</id>
<url>https://repos.spark-packages.org/</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<!-- list of dependencies -->
<dependency>
<groupId>harsha2010</groupId>
<artifactId>magellan</artifactId>
<version>1.0.5-s_2.11</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Is there any ways to load the metadata into dataframes? Thanks a lot.