Skip to content

Use SpatialHadoop as an external library

Ahmed Eldawy edited this page May 10, 2016 · 1 revision

This page shows you how you can use SpatialHadoop as an external library in your existing Java project. This makes it easier to use the operations and data types that ship with SpatialHadoop. It also allows developers to add their own data types or operations in SpatialHadoop. This page only describes how to add SpatialHadoop as an external library. At the bottom of this page, there are some links on how to extend SpatialHadoop by adding new data types or operations.

This page describes how to add SpatialHadoop via Maven. However, if you prefer other project management or dependency management libraries, such as Ivy, you can also use them.

Create a new project

The first step is to create a new Java project using Maven. Use the following command to create the initial project direcotry. Customize it per your preference.

mvn archetype:generate -DgroupId=com.example -DartifactId=shadoop-example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

It should generate the project directory with pom.xml file.

Add SpatialHadoop as a dependency

Edit pom.xml file and add the following dependency to the dependencies section.

<dependency>
  <groupId>edu.umn.cs.spatialhadoop</groupId>
  <artifactId>spatialhadoop</artifactId>
  <version>2.4</version>
</dependency>

You can also find the right text to add if you use another dependency management tool at the SpatialHadoop Maven Repository Page.

Test

To make sure that everything works correctly, try to compile your project using the following command.

mvn compile

You should be good to go. Check at the bottom of this page for some tutorial to start with.

Virtual Machine

The virtual machine that is available on the SpatialHadoop web site ships with an example project that you can use as a reference.

Further Reads

Extending SpatialHadoop data types