Merge Two Polygons in OpenLayers

In this post, we will merge two polygons in OpenLayers(polygons that intersect each other) into one polygon as shown in the above GIF image. The merging of two polygons is also known as the union of two polygons. In the last tutorial, we demonstrated how we can split a polygon by a line into two parts in OpenLayers using JSTS.

If you are a first-time reader of this blog, I would recommend going through the following tutorial on splitting polygon into two parts. It would make understanding this tutorial easy for you.

Before moving forward, we will have a quick…


Split a Polygon by Line in OpenLayers
Split a Polygon by Line in OpenLayers
Polygon Split by Line in OpenLayers

OpenLayers is an powerful map api to develop map based applications. But to perform complex spatial operations like splitting a polygon, merging two polygons etc., we need to find another way to accomplish these operations. OpenLayers can’t do these operations on its own.

Get the full code at the GitHub repo.

Check the live demo here.

In this tutorial, we are going to develop a Polygon Splitter tool that will split the polygon into two parts by a line.

We will use a JSTS JavaScript library by Björn Harrtell to split the polygon. This JSTS library provides many functions to…


Image Credit: https://automating-gis-processes.github.io/

OpenLayers is a great open source GIS library which is used to develop a rich featured GIS web applications. But sometime you need to implement advanced spatial/geometrical operations. For example, union of two geometry, creating buffers, creating hole in polygon, dividing a polygon in two parts by a line as shown in following images.


GIS Analysis using QGIS and PostGIS
GIS Analysis using QGIS and PostGIS

Prerequisite: You need to have beginner level knowledge of QGIS and PostGIS to understand this post.

QGIS and PostGIS are one of the most famous open source GIS tools in GIS community. QGIS is used for the visualisation and processing of GIS data where as PostGIS is an extension to PostgreSQL database to store GIS data such as vector and raster data. Combining these tools with each other can greatly improve the productivity of GIS Analysts/Developers.

Using PostGIS on top of QGIS gives us ability to analyse the GIS data using SQL statements and can directly visualise the sql result…


OpenLayers icon
OpenLayers icon

For Part-1, Click here

ol.View, ol.layer and ol.source are one of the foundations of OpenLayers application. You can not move ahead without understanding them. Let’s understand them with the help of following code.

  • ol.View: It is used to set the view of map. At line number 25 in above code snippet, our map object(defined at line number 18) accepts view property. The ol.View set the center and zoom level of map when it is loaded for the first time.
  • ol.layer: It is use to add layers(GIS data) to map. This is always used with ol.source. ol.layer defined at line…

OpenLayers is an open source mapping JavaScript library which allows developers to develop highly interactive GIS web application. It can displays map tiles(or image) and vector data.

OpenLayers icon
OpenLayers icon

In this post, we will create a simple GIS web app which will display OpenStreetMap on it. OpenStreet map is similar to Google Map. We will use a OpenStreetMap mapping API in our application.

You need to have basic to intermediate level of understanding of HTML, CSS and JavaScript in order to understand this post.

Our final result will look something like below image:


Projections or Map Projections are attempts to portray the 3D surface of the earth or a portion of the earth on flat surface like flat surface or XY plane or Cartesian Plane. The method by which 3D earth surface or curved surface is laid flat to a flat surface or XY plane is known as map projections.

In order to understand Map Projection, we need do understand Latitude and Longitude

Latitude and Longitude: Lets first discuss what is Equator and Prime Meridian. In the above figure, the earth is divided into parallel horizontal and vertical lines. The largest line that…


What is GIS ?

GIS stands for Geographical Information System(GIS). It is a system for gathering, storing and analysing GIS data. A GIS data is a data which has some location information associated with it.

GIS
GIS
Courtesy: Google Images

A very simple and popular example is GPS on your smart phone.

  • Through GPS and Satellite, we gather our live location data.
  • We store it on our smartphone
  • Our smartphone has Google Map on it and the captured live location data is displayed on google map telling us our whereabouts.

Pankaj Kumar

GeoSpatial Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store