Map in a Tiny Box : Geoserver with Raspberry Pi

Introduction

When Raspberry PI came out in early 2012, I had to get my hand on one. I didn’t know what I would do with it but the tiny size of that little computer made me have it. I bought one after waiting 6 weeks on back order. First thing I installed on that machine was Java and then Tomcat application server just to see if my favorite language and app server would run from a tiny thing. Well then years has passed and didn’t spend any time on it.Few days back I thought why not make a tiny map server out of Raspberry Pi. Here I’m inviting you on a tiny journey with me hoping that it would amazes you too to see how a tiny machine serves maps.

 

Sandbox

Raspberry Pi Model B

20141206_214144
Raspberry Pi Model B

First let me list out software and operating systems involved in this tiny lab.

  1. Operating System:RASPBIAN Debian Wheezy Version:September 2014
  2. Java:
  3. Java Servlet Server:Tomcat 7
  4. GIS Map Server:Geoserver
  5. A Client:A Windows 7 Laptop
  6. SSH Client:Putty on Windows

Steps

Install Operating System

For this lab I went with Raspbian Wheezy. It is a variant of Debian and one of the matured operating system made specially for Raspberry Pi. Download Raspbian from here. A detail instruction on how to install Rasbian image on a sd card also can be found here. Once you have the SD card you are all set to start Raspberry PI. Start Raspberry Pi.

 

Using Raspberry PI as Headless Server

For this lab we will use Raspberry PI in headless mode. Raspberry Pi can be run just like a regular computer using a monitor, keyboard and mouse. I’m choosing to run the little machine more like a remote server aka “headless mode”.

 

SSH to Raspberry Pi

We will use a laptop running Windows 7 to connect to our Raspberry Pi box. SSH protocol can be used to connect. In order to use SSH we will need to know the ip address that Raspberry Pi is running of off. We can find ip address in two different methods. Both of these methods are nicely describe here.

 

Using Router to find Raspberry’s IP

Log in to router’s web admin console. In my case the address to admin console was http://192.168.11.1. From the control panel find the list of connected devices to router. From the list figure out the ip address of Raspberry Pi and note it down. In my case the ip was 192.168.11.131.

2 Router

 

Using namp to find Raspberry’s IP

Download and install nmap. namap is a free networking utility to find ip and mac addresses inside a network. Running the following command will display all connected devices in network. Let us type up the following command to display a list of connected devices. In this lab our subnet is 192.168.11.xxx

 

nmap -sP 192.168.11.0/24

 

Here is sample console out. In this situation raspberrypi can be identified to have ip address of 192.168.11.131

1 nmap console

Using Putty to SSH

Install Putty if not installed already and start it up. Type in the IP address that was found in our previous step. Click open. SSH console would be displayed. Type in user as pi and provide appropriate password to login. You should be connected to Pi now.

3

Install Java Servlet Server

In recent versions of Raspbian image distribution Oracle Java 1.8 is already bundled.

4

In this lab we will install and use Tomcat version 7 as the servlet server. A servlet container is required to run Geoserver GIS map server which we intend to use as our spatial server. We would type the following command to install Tomcat 7.

 

sudo apt-get install tomcat7

 

Most likely the process will run into a JAVA_HOME not found problem as illustrated below whilte trying to start up tomcat instance.

5

This problem can be solved by adding JAVA_HOME to /etc/default/tomcat7 file. Add the following line to the file using a file editor like vi or vim.

 

JAVA_HOME=”/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt”

Let us now start Tomcat instance by typing the following command.

 

sudo service tomcat7 start

7

 

 

 

Let us test Tomcat7 installation by using a browser and connecting to the default landing page. Type up the following address in a browser where the IP address is pointing to the IP address of the Raspberry Pi.

 

http://192.168.11.131:8080

 

A successful Tomcat installation would present a page as displayed as follows.

50

Install Geoserver Map Server

Download Geoserver war zip

wget http://sourceforge.net/projects/geoserver/files/GeoServer/2.6.1/geoserver-2.6.1-war.zip

55

 

Now unzip the archive to extract WAR file by typing the following.

unzip geoserver-2.6.1-war.zip

56

 

 

Let us stop Tomcat server

sudo service tomcat7 stop

Now let us move the war to Tomcat’s webapps folder. The webapps folder is located under

/var/lib/tomcat7/webapps . Let us move the war by typing up the following.

sudo mv geoserver.war /var/lib/tomcat7/webapps

Start Tomcat7

sudo service tomcat7 start

57

Login to Geoserver admin console by typing

http://192.168.11.131:8080/geoserver/

 

You should be presented with the Geoserver login page. Now type in admin as user id and geoserver as password to log into Geoserver admin console. A successful login will present us with a page like as shown here.

60

 

 

Click on “Layer Preview” tab on the left to bring up layer preview page.

61

Now click on “OpenLayers” link for topp:states USA Population. We should be presented by a preview of USA States map as shown below.

raspiGeo_99

 

 

 

This will bring to an end of my Tiny Map server demo. In future I may present with more tutorial like this one if  I get enough interest. I wish to create a series on how to create web based Maps based on open source and commercial server and client products. Thanks for reading.

 

References:

Raspberry Pihttp://www.raspberrypi.org/

Tomcathttp://tomcat.apache.org/

Geoserverhttp://geoserver.org/

4 Comments

  1. chris January 24, 2015 Reply
  2. Linus April 4, 2015 Reply
  3. Ned May 3, 2015 Reply
  4. Hugh September 26, 2016 Reply

Add a Comment

Your email address will not be published. Required fields are marked *