WPS Split polygon on Geoserver Openlayers

WPS (Web Process Service) is an OGC service that allows you to publish geospatial processes. This is available as an extension on geoserver. To add this extension you must check the version for geoserver you are using.
Before downloading the extension you can check whether WPS is available in you local geoserver or not. For that go to demos section check for WPS request builder.

WPS Split polygon on Geoserver

WPS Split polygon on Geoserver

If not available please follow. To add this extension just download the extension and extract the file in WEB-INF/lib folder of your geoserver.
After extracting this, you can check WPS (Web Process service) with version in service capability section on right side of login page of geoserver.

WPS Split polygon on Geoserver

There are many processes available in WPS request builder. In this article will see the splitting of existing or newly created polygon using geo:splitPolygon process.

There are two options available to split a polygon in GeoServer.

1. Using WPS request builder option on geoserver, by providing the geometry for polygon and line string.
2. Creating a map with options to draw and split polygon interactively.

Execute Process on Geoserver with split polygon

For the first option you need to navigate to WPS Request builder option and choose the geo:spliPolygon process.

WPS Split polygon on Geoserver

Then provide the geometry of polygon to be split and geometry of line string, which will split the polygon.

WPS Split polygon on Geoserver

Then write values,

WPS Split polygon on Geoserver

The output can be collected as geometry WKT(well know text), Json (Javascript object notation) format or GML(Geography Markup Language). You can also check the generated XML with provided inputs.

WPS Split polygon on Geoserver

The execute button is available for executing the process. this will prompt you to download the geometry of spited polygon. In the result you can see the geometry collection will contain number of polygons.

WPS Split polygon on Geoserver

Execute Process by creating Map – WPS Split polygon on Geoserver

For visualization of splitting of polygon you can create a map with option to draw the polygon and spilt option. This article is created using OpenLayer JavaScript library with three radio buttons for draw polygon, splitting line and drag.

Use WPS on Geoserver To create map using OpenLayer library you need to add the openlayer script and to use splitPolygon process you need to split-poly javascript file in your document. In the given lines echo base_url() fucntion gives the project name on localhost. Instead of this you can give the folder path, where these files are kept

The requires a library of file which can be downloaded from https://github.com/openlayers/openlayers/tree/052be822882ef527dedb82d7d3cc19adc76d6371 link. The lib folder is required. As this contains various javascript file which are required while running this example. Now to add all these files in your document in tag, you can follow the given code.

Here we have taken all the file name in jsFiles variable.

if(!singleFile) {
  if (!jsFiles) {
  jsFiles = [
  ]; // etc. write all file name

After table created a script tag and using for loop inserted file names in src of script tag

 var scriptTags = new Array(jsFiles.length);
  var host = OpenLayers._getScriptLocation() + "lib/";
  for (var i=0, len=jsFiles.length; i";
  if (scriptTags.length > 0) {

The host name is the base path which is collected from _getScriptLocation function.

function() {
  var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile);
  // Relative path of this script.
  var scriptName = (!singleFile) ? "/var/www/html/PHP_pgrouting/lib/OpenLayers.js" : "OpenLayers.js";
  var jsFiles = window.OpenLayers;
  window.OpenLayers = {
  _getScriptLocation: (function() {
  var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)"),
  s = document.getElementsByTagName('script'),
  src, m, l = "";
  for(var i=0, len=s.length; i<len; i++) {
  src = s[i].getAttribute('src');
  if(src) {
  m = src.match(r);
  if(m) {
  l = m[1];
  return (function() { return 'http://localhost/PHP_pgrouting/'; });
  ImgPath : ''

After adding all required Js files in document you can create a view or HTML page to visualize your map.
Just create a div for map and three radio buttons for draw, split and drag options.

Use WPS on Geoserver

Now Split-poly.js file contains the function all draw, split and drag option. one of them is given below

var dragPoly = new OpenLayers.Control.DragFeature(map.layers[1]);

var dragToggle = document.getElementById("drag");
  var toggleDrag = dragToggle.onclick = function() {
  if (dragToggle.checked) {
  } else {

Similarly for all we can write functions. The split Function works as Take the drawn polygon and polyline features in variables. then check for intersection of polygon and polyline. If both intersects set hit variable a true. Check the intersections and execute split process.

function handleSplitDraw(event) {
  var splitter = event.feature;
  var features = map.layers[1].features;
  var candidates = OpenLayers.Array.filter(map.layers[1].features, function(feature) {
  var hit = false;
  if (feature.geometry.intersects(splitter.geometry)) {
  hit = true;
  return hit;
  var candidate;
  for (var i=0, ii=candidates.length; i<ii; ++i) {
  candidate = candidates[i];
  if (candidate.geometry.intersects(splitter.geometry)) {
  executeSplit(candidate, splitter);
  return false;

The execute process will take the data in variable. This data will contain the input/output identifier and mimetype.

 function executeSplit(poly, line) {

 var doc = this.wpsFormat.write({
  identifier: "geo:splitPolygon",
  dataInputs: [{
  identifier: "polygon",
  data: {
  complexData: {
  mimeType: "application/wkt",
  value: wktFormat.write(poly)
  }, {
  identifier: "line",
  data: {
  complexData: {
  mimeType: "application/wkt",
  value: wktFormat.write(line)
  responseForm: {
  rawDataOutput: {
  mimeType: "application/wkt",
  identifier: "result"

After this using post method of Openlayer we can send this data to geo:splitPolygon process and can collect the response. after collecting geometry as well known text we can render again this geometry on map.

  url: "http://localhost:8080/geoserver/ows?service=WPS&version=1.0.0&request=Execute&Identifier=geo:splitPolygon",
  data: doc,
  success: function(response) {
  handleSuccess(response, poly);

After writing code open the project on browser and draw a polygon using draw option.

WPS Split polygon on Geoserver

Now draw the splitting line using split option.

WPS Split polygon on Geoserver

As you finish the drawing part the executeSplit() function runs which splits the polygon which can be seen on map as

WPS Split polygon on Geoserver

Now to see, actually these polygons are splited or not. you can use drag option.

WPS Split polygon on Geoserver

In this way you can go for other processes available on geoserver. If you find any problem in implementing WPS Split polygon on Geoserver do comment below.

Install GeoServer for Ubuntu

Install GeoServer for Linux System. For producing any detail map, we need to have large detailed dataset. If it is about country level or world level analysis it may create huge problem with huge dataset. It can hang your system or slow down it. Even for browser it is dangerous because browser takes time or get in not responding mode. More than this you want to change or query data with rendering it on map, this will take much of your precise time.

To solve this problem we use some servers which can handle the dataset and provide us when required. For the map data we have one the great solution that is geoserver. What is geoserver and how it is helping us… geoserver is an open-source server written in Java that allows users to share, process and edit geospatial data. It helps us to display the information to the world. It has a great feature that using WMS (Web Map Services) standards it provides variety for output format.

Download and Install Geoserver in linux

To download and install Geoserver in Linux based system, please follow the content. First of all download the Geoserver zip folder. To download that navigate to http://geoserver.org/release/stable/ link and click the Platform Independent Binary link.

Now make sure that you have already installed Java Runtime Environment (JRE) in
your system. if not, please visit http://www.oracle.com/technetwork/java/javase/downloads/index.html website to download and install the JRE in your system. Currently Java 9 is not supported by geoserver so download JRE 8 from oracle.

Steps for installing GeoServer on Linux based operating system-

Step 1 for installing geoserver-

Extract the downloaded geoserver zip file. if you are not sure where to unzip it, navigate to usr/share folder and make a new folder name it as geoserver and unzip file in this folder.


Open the terminal in your system and add an environment variable to save the location of GeoServer by running given command
–> echo “export GEOSERVER_HOME=/usr/share/geoserver”

Step 3 for installing geoserver in ubuntu-

To make sure you are the owner of the geoserver folder, run the give command
–> sudo chown -R USER_NAME /usr/share/geoserver/
Here replace USER_NAME with your user name. The user name can be your system’s user name, then it will ask for the password so give your system password.

Step 4-

After this navigate yourself to the bin folder inside the unzip geoserver folder and run the startup.sh file.To run this file on terminal, look given command
–> sh startup.sh

Step 5 for installing geoserver-

Now your geoserver is installed successfully to check open the browser and run the given command

–> http://localhost:8080/geoserver

Give admin as username and geoserver as password. Create your workspace and datastores for various datasets and upload them on geoserver with various styles and icons.

To know how to publish and style vector and raster dataset on geoserver you can visit our previous tutorials as Publish style vector data on geoserver, Publish style raster data on geoserver or install geoserver in windows operating system.

If you have other query related to geoserver or publishing and styling dataset on geoserver, let us know via comments. We would definitely help you out.

QGIS Server – Installation in Ubuntu

QGIS Server is one of the best server for web map rendering and it can be also used as back end for the GIS logic. This post summarizes notes about QGIS Server – Installation in Ubuntu 16.04 LTS. As we know QGIS Server is a  FAst Common Gateway Interface application and it is written in C++ which works  smoothly with a web server like Apache, Lighttpd and etc.

QGIS is an open source server which implements excellent quality  cartographic features for mapping. QGIS uses cartographic rules as a configuration language, both for the server configuration and for the user-defined cartographic rules. QGIS is performant, scalable and reliable server which allows user customisation of maps. QGIS also allows printing pdf data and QGIS is so easy to use as It has Python plugin support which allows it for fast and efficient development and deployment of new features.

QGIS desktop and QGIS Server use the same visualization libraries, the maps that are published on the web look the same as in desktop GIS. QGIS is a Desktop based Geographic Information System (GIS) Application for creating maps, editing, viewing and analyzing Geospatial data. Quantum GIS is a cross platform, free and open source application. It can be run on multiple operating system like Mac OS X, Windows, Ubuntu, Linux and Unix.

Lets begin the process of QGIS Server – Installation in Ubuntu 16.04 LTS and we will also be installing the QGIS desktop application.

QGIS Server Installation

In this post we are going to give you a short and simple installation tutorial with the simplest execution here.

First, as my server runs “xenial”, lets add the following package sources to /etc/apt/sources.list.d/xenial-gis.list (as described  in the QGIS Installation Documentation)

deb http://qgis.org/debian xenial main
deb-src http://qgis.org/debian xenial main

Now We need to update the package list and for that we need to add the key for further installation and for that write these lines of code in the command line prompt.

sudo gpg --keyserver keyserver.ubuntu.com --recv-key 1F9ADD375CA44993

sudo gpg --export --armor 1F9ADD375CA44993 | sudo apt-key add -

#updating the package list
sudo apt-get update && sudo apt-get upgrade

Now we are almost ready for the QGIS Server – Installation, we just need to add one more package i.e Apache2. It’s better to remove and re-install apache2 web server so that we start from the same set up:-
To remove Apache2:-

sudo apt-get --purge remove apache2

sudo apt-get autoremove

To re-install Apache2:-

  sudo apt install apache2 

Now we can surely install the QGIS Server and the necessary Apache2 package.

sudo apt-get update

sudo apt-get install python-qgis qgis-server libapache2-mod-fcgid

In case you would like to install QGIS Desktop (note that it’s not a common practice to install both client and server applications on the same machine), type:

sudo apt-get update

sudo apt-get install qgis-server python-qgis

Install the Apache server in a separate virtual host listening on port 81. Enable the rewrite module to pass HTTP BASIC auth headers:

sudo a2enmod rewrite
#edit file qgis-server-port.conf and write Listen 81 and then save it
sudo gedit  /etc/apache2/conf-available/qgis-server-port.conf

sudo cat /etc/apache2/conf-available/qgis-server-port.conf
Listen 81

sudo a2enconf qgis-server-port

Now edit the virtual host configuration, type:

sudo gedit /etc/apache2/sites-available/qgis-server.conf

then edit this file by writing this configuration:

<VirtualHost *:81>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html

  ErrorLog ${APACHE_LOG_DIR}/qgis-server-error.log
  CustomLog ${APACHE_LOG_DIR}/qgis-server-access.log combined

  # Longer timeout for WPS... default = 40
  FcgidIOTimeout 120
  FcgidInitialEnv LC_ALL "en_US.UTF-8"
  FcgidInitialEnv LANG "en_US.UTF-8"
  FcgidInitialEnv QGIS_DEBUG 1
  FcgidInitialEnv QGIS_SERVER_LOG_FILE /tmp/qgis-000.log
  FcgidInitialEnv QGIS_PLUGINPATH "/opt/qgis-server/plugins"

  # Needed for QGIS HelloServer plugin HTTP BASIC auth
  <IfModule mod_fcgid.c>
      RewriteEngine on
      RewriteCond %{HTTP:Authorization} .
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
      AllowOverride All
      Options +ExecCGI -MultiViews +FollowSymLinks
      # for apache2 > 2.4
      Require all granted
      #Allow from all

now we have to enable the virtual host we just created and restart the Apache2 server

sudo a2ensite qgis-server
sudo service apache2 restart

we have finally completed the QGIS Server – Installation For Ubuntu 16.04 LTS.
Let’s test the installation before we proceed. The GetCapabilities request should already work, run this in your browser

QGIS Server Installation
QGIS Server Installation

You will get a result screen like this.

Congratulations! … We have Successfully created the QGIS server. Now create a QGIS project with some vector layers and save it in /home/username/file.qgs.

Adding a QGIS project file

It’s time to add a QGIS project to our server. To do that, we move to the QGIS Server folder

cd /usr/lib/cgi-bin

where you should find ‘qgis_mapserv.fcgi’ and ‘wms_metadata.xml’.
Now have one folder for each project file. Lets make the first project “myProject”.

sudo mkdir myProject
cd myProject

qgis_mapserv.fcgi and wms_metadata.xml can now be linked into this new folder

sudo ln -s ../qgis_mapserv.fcgi && sudo ln -s ../wms_metadata.xml 

The only thing that is missing anymore is a QGIS project file. Which we will be linking into the folder. After restarting Apache, we should be good to go.

sudo ln -s /home/username/file.qgs  /usr/lib/cgi-bin/myProject/file.qgs

Now update the Apache2 Server again

sudo service apache2 restart

Your ‘GetCapabilities’ request should now include the added ‘myProject’ folder:

QGIS Server Installation
QGIS Server Installation

which gives a output like:

QGIS Server can serve as many project files as you want. There are different ways to organize your server but I would simply add a new folder (like the “myProject” folder in this example) and link in the executable and project file.


Install Geoserver – Windows OS – Step by Step

GeoServer is an open source server for sharing geospatial data in both vector and raster format. It is designed to host major data sources, which can easily render on maps.

Download stable version of GeoServer to Install:

Google out http://geoserver.org/ link.

Install Geoserver in windows

Hit the Download tab and install the stable version of geoserver. In this tutorial we have downloaded GeoServer 2.12.0. Before installation make sure that you already have JRE installed. If you have not installed that please visit


to download JRE (Java runtime environment) and install it.

To install GeoServer follow the steps given below,

Step 1:

First of all download the GeoServer application file and keep in drive, where you want to install it.

Step 2 to install geoserver:

Double click the application file and start installation.

Install Geoserver in windows

Click next button.

Step 3:

Select I agree option and set the path to drive, where you want to install this application.

Install Geoserver in windows

Click I agree.

Install Geoserver in windows

Before choosing the install location check space available in drive. Then provide installation location and click next.

Install Geoserver in windows

Here click next button.

Install Geoserver in windows

Give the path where you have installed the JRE.

Install Geoserver in windows

Click next button.

Step 4 to install geoserver:

You can change the Username and password.

Install Geoserver in windows

Set the Username and password and click next button.

Install Geoserver in windows

Click next button.

Install Geoserver in windows

Click next button.

Install Geoserver in windows

Check the details provided and click install button. After installation click finish button. You will find the GeoServer folder in the directory.

Step 5 to install geoserver:

After installation search Start GeoServer application, it will run in command prompt then in web browser search localhost:8080/geoserver/web link.

You can also visit articles on Publish and style Vector data, Publish and style Raster data, Install geoserver in linux operating system etc.

Feel free to comment in provided comment box for any other queries and problem.