Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty metadata while reading data from shape file or geojson file #246

Open
XiaWuSharve opened this issue Feb 8, 2024 · 0 comments
Open

Comments

@XiaWuSharve
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant