Raster data file format lists in GIS

This post will describe you about the Raster data file format lists in GIS. In Geographical information system there are only two methods which are used to store data for both kinds of mapping references i.e Raster and Vector Data GIS files. And in this post we are going to talk about the various Raster data file formats in GIS.  Raster data is  very useful for analysis. Raster data represents the world as a surface divided into regular grid of cells.

Raster data models are useful for storing data that varies continuously, as in an aerial photograph, a satellite image or an elevation surface. There are two types of raster data: continuous and discrete. Raster stores the data in the type of digital image represented by reducible and enlargeable grids and these grid of cells contains a value representing information, such as temperature, discrete data represents features such as land-use or soils data.

Raster data provides a matrix of cells with values representing a coordinate and sometimes linked to an attribute table and it is much simpler for many layers combinations. Raster data is very easy to modify or program due to simple data structure.

Now coming to the main question how many file formats does Raster data have?  and here we  are going to look for the answer as Raster data file format lists in GIS showing all the data format lists.

Popular Raster data file format lists in GIS

    • Portable Network Graphics (PNG)

      Provides a well-compressed, lossless compression for raster files. It supports a large range of bit depths from monochrome to 64-bit color. Its features include indexed color images of up to 256 colors and effective 100 percent lossless images of up to 16 bits per pixel.

      Single file—extension *.png
    • Joint Photographic Experts Group (JPEG2000)

      Open-source raster format. A compressed format, allows both lossy and lossless compression. JPEG 2000 is a non-proprietary image compression format based on ISO standards, and typically uses .jp2 as the file extension. It’s advantages are that it offers lossy and lossless compression, and world files (.j2w) can be used to georeference an image in GIS software. Compression ratios are similar to MrSID and ECW formats.

      Single file—extension *.jp2, *.j2c, *.j2k, or *.jpx
    • JPEG File Interchange Format (JFIF)

      A standard compression technique for storing full-color and grayscale images. Support for JPEG compression is provided through the JFIF file format.

      Single file—extension *.jpg, *.jpeg, *.jpc, or *.jpe
      World file—extension *.jgw

      ArcCatalog only recognizes the .jpg file extension by default. To add .jpeg or .jpe files to ArcMap without renaming them, add those file extensions to ArcCatalog or drag those files from Windows Explorer into your map.

    • Multi-resolution Seamless Image Database (MrSID)

      Multi-Resolution Seamless Image Database (by Lizardtech). A compressed wavelet format, allows both lossy and lossless compression. MrSID is a proprietary format of LizardTech’s GeoExpress software for imagery compression, and is commonly used on orthoimages. The MrSID file extension is .sid. A companion file with a .sdw extension and the same prefix name as the .sid is used as a world file for georeferencing a MrSID image.
      Most greyscale TIFF images are compressed with MrSID to 10:1 or 15:1. Color images are usually compressed to 30:1 or 40:1. GeoExpress is also commonly used to create image mosaics.
      Most recent GIS software, including ArcGIS, are able to read MrSID compressed images without any additional extensions. ArcView 3.x, however, requires a MrSID Extension for image access. Plugins for other software, such as AutoCAD and Photoshop, may or may not be required.
      Supports generations 2, 3, and 4.

      Single file—extension *.sid
      World file—extension *.sdw
    • Network Common Data Form (netCDF)

      netCDF file format with CF medata conventions for earth science data. Binary storage in open format with optional compression. Allows for direct web-access of subsets/aggregations of maps through OpeNDAP protocol.
      It is the machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.
      The netCDF libraries support multiple different binary formats for netCDF files:

      • The classic format was used in the first netCDF release, and is still the default format for file creation.
      • The 64-bit offset format was introduced in version 3.6.0, and it supports larger variable and file sizes.
      • The netCDF-4/HDF5 format was introduced in version 4.0; it is the HDF5 data format, with some restrictions.
      • The HDF4 SD format is supported for read-only access.
      • The CDF5 format is supported, in coordination with the parallel- netcdf project.
    • Digital raster graphic(DRG)

      Digital Raster Graphic is a raster file format. From scanning a paper USGS topographic map for use on a computer a digital image is created called DRGs. The DRGs which are created by USGS are typically scanned at 250 dpi and then the DRGs are saved as a TIFF file in the server. The Raster data image usually includes the original border information, referred to as the “map collar”. The raster map file is projected by UTM and georeferenced to the surface of the earth.

      • ARC Digitized Raster Graphic (ADRG)

        ARC Digitized Raster Graphics is a standard National Imagery and Mapping Agency (NIMA) digital product. ADRG is designed to support applications that require a raster map background display.
        ADRGs are the digitized maps and transformed charts and The intended exchange medium for ADRG is a compact disk (CD-ROM)
        The ADRG’s charts transformed into a specific georegistration framework and acccomplnied by ASCII encoded support files. ADRG is geographically referenced using the equal arc-second raster chart/map (ARC) system in which the globe is divided into 18 latitudinal bands, or zones. The data consists of raster images and other graphics generated by scanning source documents.

        Multiple files
        Data file—extension *.img or *.ovr
        Legend file—extension *.lgg
      • Enhanced Compressed ARC Raster Graphics (ECRG)

        Enhanced Compressed ARC Raster Graphics (ECRG) file is an Enhanced Compressed ARC Raster Graphics. ECRG is geographically referenced using the ARC system in which the globe is divided into 18 latitudinal bands, or zones. ECRG uses JPEG 2000 compression.
        Distributed by the NGA. CADRG/ECRG is geographically referenced using the ARC system. The data consists of raster images and other graphics generated by scanning source documents. CADRG achieves a nominal compression ratio of 55:1. ECRG uses JPEG 2000 compression using a compression ratio of 20:1

      • Compressed ARC Digitized Raster Graphics (CADRG)

        CADRG is a comprising computer-readable digital map and chart images. they are also the file formats of Raster data. CADRG files are usually physically formatted within a National Imagery Transmission Format (NITF) message. It supports various weapons, C3I theater battle management, mission planning, and digital moving map systems. CADRG data is derived directly from ADRG and other digital sources through downsampling, filtering, compression, and reformatting to the Raster Product Format (RPF) Standard.The CADRG Reader can read CADRG files with or without the NITF message wrapper. The CADRG Writer can create CADRG datasets with or without the NITF message wrapper.

        CADRG achieves a nominal compression ratio of 55:1. ECRG uses JPEG 2000 compression using a compression ratio of 20:1

        File extension is based on specific product. You can specify 	which products you want ArcGIS to recognize (Customize > ArcMap Options > Raster > File Formats).
    • Raster Product Format (RPF)

      Raster Product Format, military file format specified in MIL-STD-2411. RPF is a standard data structure developed in 1994 as a U.S. Military Standard for geospatial databases. RPF’s database is composed of rectangular arrays of pixel values (e.g. in digitized maps or images) in compressed or uncompressed form.
      It was designed as a adaptable format to encompass raster data products in compressed or uncompressed form. The intent was to enable application software to use the data in RPF format on computer readable interchange media (e.g. CD-ROM) directly without further manipulations or transformation.
      The underlying format of CADRG and CIB.
      Single file—no standard file extension

      1. Compressed ADRG – Compressed ADRG, developed by NGA, nominal compression of 55:1 over ADRG (type of Raster Product Format)
      2. CIB – Controlled Image Base, developed by NGA (type of Raster Product Format)

    • Binary file

      An unformatted file consisting of raster data written in one of several data types, where multiple band are stored in BSQ (band sequential), BIP (band interleaved by pixel) or BIL (band interleaved by line). Georeferencing and other metadata are stored one or more sidecar files.
      The Binary Terrain format was created by the Virtual Terrain Project (VTP) to store elevation data in a more flexible file format. The BT format is flexible in terms of file size and spatial reference system.

      Single file—extension *.bt
      Projection file—extension *.prj
      • Band Interleaved by Pixel (BIP), Band Interleaved by Line (BIL), Band Sequential (BSQ)
        This format provides a method for reading and displaying decompressed, BIL, BIP, and BSQ image data. By creating an ASCII description file that describes the layout of the image data, black-and- white, grayscale, pseudo color, and multiband image data can be displayed without translation into a proprietary format.
        BIP and BIL are formats produced by remote sensing systems. The primary difference among them is the technique used to store brightness values captured simultaneously in each of several colors or spectral bands.
        Multiple files

        Data file—extension *.bil, *.bip, or *.bsq
        Header file—extension *.hdr
        Color map file—extension *.clr
        Statistics file—extension *.stx
    • Enhanced Compressed Wavelet (ECW)

      A compressed wavelet format, often lossy. ECW is a proprietary format of ERMapper for imagery compression. It is a more recent format than MrSID, but is gaining popularity because of free compression utilities available from ER Mapper’s website. ECW is a propriatary format. It is a wavelet-based, lossy compression, similar to JPEG 2000.
      It is a proprietary wavelet compression image format optimized for aerial and satellite imagery.
      This format can be used for Desktop, but when publishing, you require the ECW for ArcGIS for Server extension license.

      Single file—extension *.ecw

      ESRI grid – proprietary binary and metadataless ASCII raster formats used by Esri. A proprietary Esriformat that supports 32-bit integer and 32-bit floating-point raster grids. Grids are useful for representing geographic phenomena that vary continuously over space and for performing spatial modeling and analysis of flows, trends, and surfaces such as hydrology.

      color map file—extension *.cl
    • Extensible N-Dimensional Data Format(NDF)

      Format used for storing data representing n-dimensional arrays of numbers, such as images. Uses container files (directories containing files and directories) to manage the data objects.

      Directory—extension *.sdf
    • GDAL Virtual Format (VRT)

      This is a file format created by the Geospatial Data Abstraction Library (GDAL). It allows a virtual dataset to be derived from other datasets that GDAL can read.

      Single file—extension *.vrt
    • Tagged Image File Formats (TIFF)

      This format is associated with scanners. It saves the scanned images and reads them. TIFF can use run length and other image compression schemes. It is not limited to 256 colors like a GIF. Widespread use in the desktop publishing world. It serves as an interface to several scanners and graphic arts packages. TIFF supports black-and-white, grayscale, pseudo color, and true color images, all of which can be stored in a compressed or decompressed format.
      BigTIFF is supported.

      Single file — possible file extensions *.tif, *.tiff, and 	*.tff
      World file — extension *.tfw

      ArcCatalog only recognizes the .tif file extension by default. To add .tiff or .tff files to ArcMap without renaming them, add those file extensions to ArcCatalog or drag those files from Windows Explorer into your map.

    • Geo Tagged Image File Formats (GeoTIFF)

      TIFF variant enriched with GIS relevant metadata, As part of a header in a TIFF format it puts Lat/Long at the edges of the pixels. GeoTIFF driver supports reading, creation and update of internal overviews. Internal overviews can be created on GeoTIFF files opened in update mode (with gdaladdo for instance). If the GeoTIFF file is opened as read only, the creation of overviews will be done in an external .ovr file. Overview are only updated on request with the BuildOverviews() method. The GeoTIFF format is fully compliant with TIFF 6.0, so software incapable of reading and interpreting the specialized metadata will still be able to open a GeoTIFF format file.

    • Graphic Interchange Format (GIF)

      Graphic Interchange Format. A file format for image files, commonly used on the Internet. It is well-suited for images with sharp edges and relatively few gradations of color. A bitmap image format generally used for small images.

      Single file—extension *.gif
      World file—extension *.gfw
    • Digital Elevation Model (DEM)

      The representation of continuous elevation values over a topographic surface by a regular array of z-values, referenced to a common vertical datum. DEM is sometimes used as a generic term for DSMs and DTMs, only when DEM representing height information without any further definition about the surface.
      A DEM can be represented as a raster data(a grid of squares, also known as a heightmap when representing elevation) or as a vector-based triangular irregular network (TIN). When you look at a Digital Elevation Model (DEM) on a map, you don’t see a cell matrix. Instead, you see a layer symbolized by a color ramp.

      • Digital Elevation Models or DEM have two types of displays
        The first is 30-meter elevation data from 1:24,000 seven-and-a-half minute quadrangle map. The second is the 1:250,000 3 arc-second digital terrain data. DEMs are produced by the National Mapping Division of USGS.
      • Spatial Data Transfer Standard (SDTS)  digital elevation model (DEM)
        The Spatial Data Transfer Standard (SDTS) was created by the USGS. The purpose of this format was to transfer digital geospatial data between various computer systems in a compatible format that would not lose any information.

        Multiple files—extension *.ddf

        The actual elevation file that ArcGIS reads is named *CATD.DDF.

      • United States Geological Survey (USGS) digital elevation model (DEM)
        This format consists of a raster grid of regularly spaced elevation values derived from the USGS topographic map series. In their native format, they are written as ANSI-standard ASCII characters in fixed-block format.

        Single file—extension *.dem (need to change .dat extension to .dem)
    • RS Landsat

      Landsat satellite imagery and BIL information are used in RS Landsat.  In one format, using BIL, pixel values from each band are pulled out and combined. Programs that use this kind of information include IDRISI, GRASS, and MapFactory. It is fairly easy to exchange information from within these raster formats.

    • ArcInfo Grid

      An ArcInfo Grid does not have an individual file extension. Instead it is composed of two folders within a “workspace” which each contain multiple files. One of the two folders carries the name of the grid, and contains a number of various .adf files. The other folder is an “info” folder, which typically contains .dat and .nit files for all the coverages and grids in the workspace. The best way to manage (copy, move, delete, rename) ArcInfo Grids is with ArcCatalog or ArcInfo Workstation (command line).

    • Airborne Synthetic Aperture Radar (AIRSAR) Polarimetric

      AIRSAR is an instrument designed and managed by NASA’s Jet Propulsion Laboratory (JPL). ArcGIS supports the polarimetric AIRSAR data (POLSAR).

      Multiple files with an L, C, or P in the file name followed 	by .dat. For example: mission_l.dat (L-Band) and 	mission_c.dat (C-Band).

 

  • Bitmap (BMP), device-independent bitmap (DIB) format, or Microsoft Windows bitmap

    BMP files are Windows bitmap images. They are usually used to store pictures or clip art that can be moved between different applications on Windows platforms.

    Single file—extension *.bmp
    World file—extension *.bpw
  • BSB

    This is a compressed raster format used in the distribution of raster nautical charts by MapTech and NOAA

    Multiple files—extensions *.bsb, *.cap, and *.kap
  • Controlled Image Base (CIB)

    Panchromatic (grayscale) images that have been georeferenced and corrected for distortion due to topographic relief distributed by NGA. Thus, they are similar to digital orthophoto quads and have similar applications, such as serving as a base or backdrop for other data or as a simple map.

    File extension is based on specific product. You can specify which products you want ArcGIS to recognize (Customize>ArcMap 	Options>Raster>File Formats)
  • Digital Geographic Information Exchange Standard (DIGEST)

    DIGEST datasets are digital replicas of graphic products designed for seamless worldwide coverage. ASRP data is transformed into the ARC system and divides the earth’s surface into latitudinal zones. USRP data is referenced to UTM or UPS coordinate systems. Both are based on the WGS84 datum.

    Multiple files
    Main raster image—extension *.img
    General information file—extension *.gen
    Georeference file—extension *.ger
    Source file—extension *.sou
    Quality file—extension *.qal
    Transmission header file—extension *.thf
  • File geodatabase

    The geodatabase is the native data structure for ArcGIS and is the primary data format for representing and managing geographic information, such as feature classes, raster datasets, and attributes.

    Raster datasets stored within *.gdb folder
  • ENVI Header

    When ENVI works with a raster dataset it creates a header file containing the information the software requires. This header file can be created for multiple raster file formats.

    Header file—extension *.hdr
    Multiple data files—extension *.raw, *.img, *.dat, *.bsq, 	etc.
  • Golden Software Grid (.grd)

    There are three types of Golden Software Grids that are supported: Golden Software ASCII GRID (GSAG), Golden Software Binary Grid (GSBG), and Golden Software Surfer 7 Binary Grid (GS7BG).

    Single file—extension *.grd
  • GRIB

    The gridded binary format is used for the storage, transmission, and manipulation of meteorological archived data and forecast data. The World Meteorological Organization (WMO) is responsible for the design and maintenance of this format standard.

    Single file—extension *.grb
  • Hierarchical Data Format (HDF) 4

    A self-defining file format used for storing arrays of multidimensional data.

    Single file—extension *.h4 or *.hdf
  • HGT

    Raw SRTM height files containing elevation measured in meters above sea level, in a geographic projection (latitude and longitude array), with voids indicated using -32768.

    Single file—extension *.hgt
  • High Resolution Elevation (HRE)

    HRE data is intended for a wide variety of National Geospatial- Intelligence Agency (NGA) and National System for Geospatial Intelligence (NSG) partners and members, and customers external to the NSG, to access and exploit standardized data products. HRE data replaces the current non-standard High Resolution Terrain Elevation/Information (HRTE/HRTI) products and also replaces non- standard products referred to as DTED level 3 thru 6.
    This data format is similar to NITF.

    Multiple files
    Raw image—extension *.hr*
    Metadata—extension *.xml
  • Integrated Software for Imagers and Spectrometers (ISIS)

    ISIS Cube format as created by the United States Geological Survey (USGS) for the mapping of planetary imagery. Versions 2 and 3 are supported.

    Single file—extension *.cub
  • Shuttle Radar Topography Mission (SRTM)

    The HGT format is used to store elevation data from the Shuttle Radar Topography Mission (SRTM). SRTM-3 and SRTM-1 v2 files can be displayed.

    Single file—extension *.hgt
    
  • Terragen terrain

    The Terragen Terrain file was created by Planetside Software. It stores elevation data.

    Single file—possible file extensions *.ter, *.terrain
    
  • MAP

    PCRaster’s raster format.

    Single file—extension *.map
    

QGIS Server – Configuration and Deploying QGIS Project

In our Previous Post QGIS Server – Installation we have talked about the installation process of QGIS Server in Ubuntu and it was easy. In previous post we get the XML file with GetCapabilities working in the browser. In the following sections, we will provide a sample configuration to set up a QGIS Server on Ubuntu with an exemplary QGIS project in QGIS project.
Let us start the process of Adding QGIS Server – Configuration and Deploying QGIS Project.

QGIS Server – Configuration and Deploying QGIS Project

To provide a new QGIS Server WMS, WFS or WCS, we have to create a QGIS project file with some data. Here, we use the ‘airport’ shapefile from the local dataset. and for adding the QGIS project with the server we go to the OWS server.

  • Import layer from Layer > Add Layer >Add Vector Layer.
  • Customize the layer, Define the colors and styles of the layers in QGIS and the project CRS, if not already defined.
  • Check the ‘Project Properties’ under the ‘Project’ menu, go to the ‘OWS server’ tab. Below is an example of of how I’ve set up mine.
    QGIS Server - Configuration and Deploying QGIS Projectand here is the bottom portion of the Properties page.
    QGIS Server - Configuration and Deploying QGIS Project
    Ensure under ‘Save Paths’ in the ‘General’ Tab it is set to ‘relative’. Note that the layers you are going to select for the WMS service are ticked under ‘Published’ in the WFS capabilities table.

Now for going ahead we need to repeat some steps from our previous post let’s have a look:

#go to cgi-bin folder
cd /usr/lib/cgi-bin/
#create a new QGIS folder
sudo mkdir airport
cd airport
#symlink in both the 'wms_metadata.xml' and the 'qgis_mapserv.fcgi' into project folder
sudo ln -s ../qgis_mapserv.fcgi
sudo ln -s ../wms_metadata.xml
#as well as linking your 'airport.qgs' file  into the '/usr/lib/cgi-bin/airport' folder
sudo ln -s /home/ep10/Documents/airports.qgs /usr/lib/cgi-bin/airport/airports.qgs
    • Now we move on to Adding QGIS project to server and for that Now we go to add the WMS layer in the project to connect it to server, so go to “Layer > Add Layer >Add WMS/WMTS Layer”. Now create a new connection and add your parameters for URL must be like this:
      http://localhost:81/cgi-bin/airport/qgis_mapserv.fcgi?map=/home/ep10/Documents/airports.qgs&
      and tick ‘ignore GetMap/GetTile URI’ and ‘ignore GetFeatureInfo URI’ boxes are ticked then ‘OK’. In your ‘airport’ project folder under ‘cgi-bin’ (/usr/lib/cgi-bin/airport/airports.qgs)

      QGIS Server - Configuration and Deploying QGIS Project
      QGIS Server – Configuration and Deploying QGIS Project

      Ensure your url is pointing at ‘http://localhost:81/cgi-bin/airport/qgis_mapserv.fcgi?’it is better to specify the full path to the qgis project file which is stored (in my case) in a ‘airport’ folder inside the ‘cgi-bin’ folder along with any shapefiles used as the source of your wms, ‘qgis_mapserv.fcgi’ file and ‘wms_metadata.xml’ files.
      Now in ‘Add Layer’ dialog select the ‘image encoding’ to PNG as it the best format with much specific coordinates.
      QGIS Server - Configuration and Deploying QGIS Project

    • Before we do go back in your QGIS project check you can add your newly created WMS layers back into QGIS as with any other WMS from a different source. When you hit the ‘connect’ button you should see a list of layers you created earlier, if not go back and check from the beginning of this post.
    • Select a layer and click ‘Add’ and the layer(s) should appear in your layer panel as normal qgis layers.

      QGIS Server - Configuration and Deploying QGIS Project
      QGIS Server – Configuration and Deploying QGIS Project
    •  Right Click on your largest area WMS layer and go to ‘Properties’ and make a note of the bounding box co-ordinates or Layer extent.
      QGIS Server - Configuration and Deploying QGIS Project

We can now use these co-ordinates in the ‘GetMap’ part in the url:-

http://localhost:81/cgi-bin/airport/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&SRS=EPSG:4326&REQUEST=GetMap&map=/home/ep10/Documents/airports.qgs&BBOX=-175.1359999999999957,-53.7815000000000012,179.1949999999999932,78.2466000000000008&WIDTH=1500&HEIGHT=1200&LAYERS=ne_10m_airports&STYLES=,,&FORMAT=image/png

Write this above URL in your browser and then you will get a PNG image in your browser with all the attribute data that the shp file had, So the output format will be an PNG image.

QGIS Server - Configuration and Deploying QGIS Project
QGIS Server – Configuration and Deploying QGIS Project
http://localhost:81/cgi-bin/airport/qgis_mapserv.fcgi?

here in this part of the url locates the qgis-server executable on the apache2 host server.

SERVICE=WMS&VERSION=1.3.0&SRS=EPSG:4326&

This calls the WMS service, it’s version and the target spatial reference system as wwe are using ESPG:4326.

REQUEST=GetMap&map=/home/ep10/Documents/airports.qgs&

this REQUEST part is the request to get the ‘map’ from the source of the qgis project file that we saved after customization.

&BBOX=-175.135999,-53.781500,179.194999,78.246600&

this BBOX sets the size of the retrieved image boundary and the ‘WIDTH’ and ‘HEIGHT’ of the image area in the browser.

&LAYERS=ne_10m_airports&STYLES=,,&FORMAT=image/png

the final part is the description and display of the layers of the WMS. Note there is no ‘STYLES’ specified because it in specified the .qgs file. Finally, the output format is a png image.

We could also add more parameters and requests into the url in order to enhance the visual appearance like:
REQUEST=GetFeatureInfo – this request retrieves the underlying attributes and geometry values and pixel location.
GetLegendGraphic – this looks for the view legend information.
bgcolor – sets the background map colour.

This is how we are going to have complete process of how we are Adding QGIS Project to server and configure the server. There are many more formats in which we can get the output data which we will hope to show you in future posts.

Did you tried adding QGIS project file with QGIS server? If you are facing any issue, do let us know by commenting below with the solution.

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 PYTHONIOENCODING UTF-8
  FcgidInitialEnv LANG "en_US.UTF-8"
  FcgidInitialEnv QGIS_DEBUG 1
  FcgidInitialEnv QGIS_SERVER_LOG_FILE /tmp/qgis-000.log
  FcgidInitialEnv QGIS_SERVER_LOG_LEVEL 0
  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}]
  </IfModule>

  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
  </Directory>
 </VirtualHost>

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

http://localhost:81/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
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:

http://localhost:81/cgi-bin/myProject/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
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.

Thanks

Connection between PostGIS and QGIS

GIS applications are tools that allow users to create interactive queries (user-created searches), analyze spatial information, edit data in maps, and present the results of all these operations. Geographic information science is the science underlying geographic concepts, applications, and systems and What goes beyond a GIS is a spatial data infrastructure, a concept that has no such restrictive boundaries. For handling the spatial data infrastructure we use tools like PostGIS and QGIS. this post will help guides you about How can we establish a Connection between PostGIS and QGIS with the help of some GIS operations.

Connection between PostGIS and QGIS

PostGIS and QGIS are two major platforms used for handling GIS operations. PostGIS adds support for geographic objects allowing location queries to be run in SQL. As PostGIS is a spatial database extender for PostgreSQL object-relational database. In our previous post you can read about PostGIS and PostgreSQL.

Now we are going the discuss the details of how We can establish connection between PostGIS and QGIS and before that let’s just discuss some important topics in brief.

QGIS

QGIS is one of the most common open source application used by GIS analyst, Geographers, Civil Engineers and many other professionals. 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.

PostGIS

PostGIS is an open source software program that adds support for geographic objects to the PostgreSQL object-relational database. PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC).
Technically PostGIS was implemented as a PostgreSQL’s extension. And There are a large number of software products that can use PostGIS as a database backend.

PostgreSQL

PostgreSQL is an open source relational database management system ( DBMS ) developed by a worldwide team of volunteers. PostgreSQL is not controlled by any corporation or other private entity and the source code is available free of charge.
When we installed PostgreSQL database server, the PostgreSQL installer also installed some useful tools for working with the database server. You can connect to the PostgreSQL database server by using the psql or pgAdmin tool.
psql is an interactive terminal program provided by PostgreSQL. You can do a lot with psql tool e.g., execute SQL statements, manage database objects, etc. and The second way to connect to a database is using pgAdmin GUI application. By using pgAdmin GUI application, you can interact with PostgreSQL database server via an intuitive user interface.

Connection between PostGIS and QGIS

  • Import Shapefile into PostGIS

    Connection between PostGIS and QGIS
    Connection between PostGIS and QGIS

    We are going to import some Shapefiles into PostGIS for creating a table in PostgreSQL database. Importing shapefiles into PostGIs using psql is already discussed in our previous post “Import Shapefile in Postgresql – shp2pgsql”.
    Shapefile: The most popular geospatial vector data format. First developed by ESRI. Because of it’s open specification it is now predominantly used to share GIS data between open source and proprietary software.
    We can also do this import with pgShapeloader tool (also known as “PostGIS Shapefile Import/Export Manager” or “PostGIS Shapefile and DBF loader”). It provides another option for loading shapefiles into PostGIS database tables. It is the graphical user interface (GUI) equivalent of the command line shp2pgsql tool.
    The pgShapeloader tool combines the two data loading stages, converting data into SQL commands and running those commands against the target database, into one operation.
    On Linux pgShapeloader can be launched from the terminal with the shp2pgsql-gui command which generates this.

    now click View connection details and enter the connection information in the PostGIS Connection section.

    Click OK to return to the main application. The shapefile loader uses the supplied connection details to connect to the target database; the connection status is reported in the Log Window.
    Connection between PostGIS and QGIS

    To select your source files, click Add File to open the Select a Shape File dialog box. Navigate to the location of your shapefile, click the shapefile you wish to load, and click Open. Multiple files can also be added in the same way. and Once all import options have been added and configured, click OK and click Import to start the conversion.
    Connection between PostGIS and QGIS

    Now these shape files are added in the PostGIS databases as tables you can view them and their attributes in pgAdmin or psql.
    Connection between PostGIS and QGIS

  • Add and Modify PostGIS data files in QGIS

    Now we are going to add and modify the PostGIS database files in QGIS application.

    • Open QGIS application, you will see PostGIS option in Browser toolbar here.
      Connection between PostGIS and QGIS
    • Right click on the PostGIS option and click on the “New Connection” that will open a “Create a New PostGIS connection” toolbar.

      Connection between PostGIS and QGIS
      Connection between PostGIS and QGIS
    • Enter the Database Connection details and then click the “Test Connection” button. this button will open up an authentication form for server details. fill the authentication details and click Ok.
      Connection between PostGIS and QGIS
    • you will see a message on toolbar i.e connection to is successful. Now click OK and you have successfully connected your database with the QGIS. You can see the Database and the Shapefiles we imported in PostGIS below the PostGIS in browser window in QGIS.
      Connection between PostGIS and QGIS
    • Now for adding these Shapefile as layers in QGIS, Right click on the files and select “Add Selected layers to Canvas” then the file will show as a layer on canvas and in layers window in QGIS. you can also see the attributes of the Shapefile  by right-click on the filename in Layers window and selecting Open attribute table.
      Connection between PostGIS and QGIS
    • Now for Modifying the Shapefiles , I prefer you to go to Split Sub Divide polygon layer using QGIS – Shapefile, kml, GeoJson.
      There you can modify the Shapefile and we can see that as the polygon is Sub-divided It increases the attributes of the Shapefile.
  • Now as we can see that the attributes of Shapefile after modifying has increased compare to the attributes when the file was imported from PostGIS database.

When the Shapefile is saved after modification in QGIS by default the file is also saved in PostGIS database with the new and changed attributes it has before.

The connection between QGIS and PostGIS is proves that if any data file is altered in QGIS, the file also gets modified in the PostGIS database system.

Download free Shapefile Maps

This is how we can show the establishment of the Connection between PostGIS and QGIS.

Import OSM data in Postgis – OSM2pgsql

This article lets you know how to import data in postgresql.  Open Street map (OSM) is open and free data. Anyone one can download this data. It mainly contains point data, line data, polygon data and geometry information. Data contains much information and becomes heavy i.e. upto 30GB or more. Many compression techniques are applied to make it available to user in minimum size.

Install osm2pgsql- Import OSM data in Postgis

This utility can be installed using command prompt. Follow the command,

--> apt-get install osm2pgsql

Now you can see the options available with the command. Type osm2pgsql in command prompt. You will get the following result.

Import OSM data in Postgis- OSM2pgsql

We know that you import data in database we must create a database for storing tables. You can download and install postgresql with our previous tutorial Install PostGIS and PostgreSQL in Linux Ubuntu 16.4 

Here we have database ‘potsgres’ in Postgresql with a user. In the command we specify option -s is slim mode,Store temporary tables in database. This allows incremental updates using diff files also available at OSM data servers, and reduces memory usage at a cost in disk space and import time. This mode of operation is recommended.  The option -G Generate multi-geometry features in PostgreSQL tables. Option -U is user available in Postgresql, -W  prompts for password and in the last give file name.

As files are heavy in size so this process takes time.

Import OSM data in Postgis- OSM2pgsql
Import OSM data in Postgis

This Open street map data is also available in pbf format (Protocolbuffer Binary Format). This format is specially designed to compress data. This is much faster than gzipped and bzipped planet while reading files.

The data available is in data.osm.pbf format so we need to extract this data first. This can be done with osmconvert command. Type osmconvert in command prompt, if not available install this with given command.

–>sudo apt-get install osmctools

Now use the following command to convret data in osm,

–>osmconvert Input.pbf > output.osm

After this check for the OSM file in folder. Now use the command given for importing data in postgresql.

Import OSM data in Postgis- OSM2pgsql

Output

This output can be seen in postgresql available in table format.

Import OSM data in Postgis- OSM2pgsql
Import OSM data in Postgis

In this way you can also import shapefile data in postgresql. You can also try out conversion using GDAL utilities as shapefile to sql, shapefile to mif etc.

Please let us know if you need any help by commenting in given comment box.

Geographical Information System (GIS) FAQs – GIS Interview Question

Geographical Information System (GIS) is a computer-based tool that is designed to capture, store, manipulate, analyze, manage, and present spatial or Geographic data, usually in a map. GIS application is a tool that allows users to create user-created searches, integrate and analyze spatial information and present the results of all these operations. GIS describes any information system that integrates, edits, analyzes, shares, and displays geographic information. GIS technologies are using digital information, for which various digitized data creation methods are used. Here in this post we will check FAQs of Geographical Information System (GIS) and Common Question asked during Interview Question.

GIS Interview Question – Frequently Asked Question GIS

Que. What is GIS?
Ans. GIS is a blend of S/W and H/W used to collect, manipulate analyst and produce geographical data

Que. What is the difference between geo-coding and geo-referencing?
Ans. Geo-coding is when you associate a place name or an address with map coordinates. Geo-referencing is the process of associating plain digital images taken from a satellite or a plane with map coordinates so that they can be overlaid on street maps.

Que. Name the two data structures that have the capacity to hold spatial data.
Ans. The two data structures that can hold spatial data include raster and vector.

Que. Differentiate between GIS commands and tools?
Ans. Commands do not require interaction with the map, they just rely on surface. Tools on the other hand require interaction with the map canvas.

Que. Name applications of the Arc GIS desktop.
Ans. Arc Map, Arc catalog and Arc toolbox.

Que. Define remote sensing?
Ans. Remote sensing refers to detection and classification of objects on or in earth without physical contact, generally attained through aerial sensors.

Que. What is the role of GPS in GIS?
Ans. Competent decisions can only be rendered by reliable data and though GIS is an amazing data management tool, using it with GPS helps in validating the data analysis and results.

Que. What is a globe?
Ans. A sphere shaped model of the Earth

Que. What are the 7 large land massses found on a globe called?
Ans. Continents

Que. Name the 7 continents.
Ans. Asia, Africa, Europe, North America, South America, Antarctica, and Australia.

Que. Latitude and Longitude are measured in ____ .
Ans. Degrees

Que. What does the  scale on a map shows?
Ans. Where you are,How the size of the map relates to the size of a real place and direction as North,east,south,west.

Que. What does the legend or map key tell?
Ans. Direction, What the symbols on the map mean and The distance between the equator and a point north or south on the earth’s surface

Que. What is GPS ?
Ans. Global Positioning System(GPS) is a space based satellite navigation system that provides location and time information in all the weather conditions, anywhere on or near the earth.

Que. List the satellite navigation systems ?
Ans. The navigation systems are as follows:

  1. GLONASS(Globalnaya navigatsionnaya sputnikovaya sistema) : Russia’s global navigation system.
  2. IRNSS ( Indian Regional Navigational Satellite System),  COMPASS : People’s republic of china’s global system.

Que. Explain briefly the working principle of GPS ?
Ans. A Global Positioning System’s receiver calculates its position by precisely timing the signals sent by Global Positioning System satellite high above the earth. These distances and satellite location are used to compute the location of the receiver using the Navigation Equations. Although 4 satellites are required for normal operation, fewer apply in special cases.

Que. Explain the structure of GPS ?
Ans. The structure of GPS have three main segments. These are as follows: Page segment, Control segment and User segment

Que. Explain the space segment of GPS ?
Ans. Space segment is composed of 24 to 32 satellites in medium Earth orbit and also includes the payload adapter to the boosters required to launch them into orbit.

Que. Explain the control segment of GPS ?
Ans. Control segment is composed of a master control station , an alternate master control station, and a host of dedicated and shared ground antennas and monitor stations.

Que. Explain the user segment of GPS?
Ans. User segment is composed of thousands of U.S and allied military users of the secure GPS Precise positioning service and millions of civil and scientific users of the standard positioning service.

Que. What Is Gps Rollover?
Ans. This document contains information about GPS Week 1024 Rollover.

Que. What Is The Status Of Selective Availability (sa)?
Ans. Effective as of Midnight 01 May 2000, Selective Availability has been set to zero

Que. Explain Portable Gps?
Ans. Although any small global positioning system could be referred to as a portable GPS, the term generally refers to those units which give driving directions and are meant to be mounted in cars. Others, used for outdoor activities, are generally referred to as handheld GPS units. Still, there could be some times when the terms are confused and a portable GPS and handheld GPS are synonymous.

Que. What’s The Status Of The Gps?
Ans. The Global Positioning System reached full Operational Capability (FOC) on July 17, 1995

Que. What is a project (.mxd) file?
Ans. You can think of a project file as a database management tool. GIS users often must work on the same files for long periods of time, and the .mxd file is the management file that remembers which files you use, where they are located, the projection the file is stored in, the colors you have set, etc.

Que. What is a shapefile?
Ans. Shapefiles are computer files that produce images for users in a GIS environment. There are three basic types of shapefiles: line poin and polygon.

Que. How do I prepare spatial data for use with ArcGIS?
Ans. If you have data with spatial locators (e.g., census FIPS codes, zip codes, street addresses, etc.), you can link your data to shapefiles within a GIS environment. Furthermore, you can join tables in a GIS project.

Que. What are ArcMap, ArcCatalog and ArcToolbox?
Ans. ArcMap is the application in ArcGIS that you use to create, visualize, and manipulate maps, whereas ArcCatalog is the application in ArcGIS that you use for browsing and organizing data files. ArcToolbox is the application in ArcGIS that contains data management and conversion tools and wizards (e.g., projection tools).

Que. What are some of the functions of the Spatial Analyst extension?
Ans. The Spatial Analyst extension can help you find slopes and directions, least cost paths, and best locations for a new facility based on multiple criteria. This is useful for analyzing raster data as well as feature data.

Que. What are some of the functions of the Geostatistical Analyst extension?
Ans. The Geostatistical Analyst extension can help you with the production of statistical surfaces for exploratory spatial data analysis, structural analysis (calculating properties of neighboring areas), and surface prediction and results analysis.

Que. Is there any way to change or expand existing ArcGIS functionality?
Ans. ESRI makes a number of scripts and other downloads available for users. Scripts work with the existing software to extend functionality or to automate common tasks. The scripts on ESRI’s site come from both ESRI itself and from other ArcGIS users; you can even upload your own scripts for other people to download.

Que. How do you edit a project (.mxd) file? Why do you need to edit a project file?
Ans. Once you open your project file, editing is simple. The last saved version of your files will appear on your computer screen, and you can manipulate the existing settings to update the file. (Always remember to save it!) Project files must be edited in order for changes to be reflected in your work. You often work on GIS projects over long periods of time, and as you work, new data, shapefiles, etc. can be added to keep your project current.

Que. What is the MSD file and can I edit it?
Ans. The map service definition (MSD) file is a new file used by the fast map service drawing engine introduced at ArcGIS Server 9.3.1. The MSD file always starts with an MXD map document. You use the Map Service Publishing Toolbar to analyze your MXD in ArcMap. Once you’ve addressed issues returned by the analysis, you use the same toolbar to either publish the service or save the MSD file.

Que. How does GPS device work?
Ans. The orbits are arranged so that at any time, anywhere on Earth, there are at least four satellites “visible” in the sky. A GPS receiver’s job is to locate four or more of these satellites, figure out the distance to each, and use this information to deduce its own location.

Que. What is Selective Availability (SA)?
Ans. SA was a technique implemented by the DOD to intentionally degrade a user’s navigation solution. The single largest source of error for SPS users was SA. The net result of SA was about a five-fold increase in positioning error. DOD achieved signal degradation by altering (also known as dithering) the satellite clock. Another means designed by DOD to degrade GPS performance was to broadcast less accurate ephemeris parameters.

Que. Why was SA Necessary?
Ans. SA was used to protect the security interests of the U.S. and its allies by globally denying the full accuracy of the civil system to potential adversaries.

Que. Will SA ever be turned back on?
Ans. It is not the intent of the U.S. to ever use SA again. To ensure that potential adversaries to do not use GPS, the military is dedicated to the development and deployment of regional denial capabilities in lieu of global degradation through SA.

Que. What kind of orbits are the GPS satellites in?
Ans. The GPS satellites operate in circular 10,900nm (20,200km) 12-hour orbits at an inclination of 55 degrees. They are not in geo-stationary orbit.
How vulnerable are GPS satellites to jamming and interference?
GPS satellite signals, like any other navigation signals, are subject to some form of interference. The FAA is actively working with the U.S. Department of Defense and other U.S. Government Agencies to detect and mitigate these effects and make sure that the GPS and any related augmentation systems are available for safe aviation operations. As with all navigation aids, interference, whether intentional or unintentional, is always a concern.

Que. Is the basic GPS signal sufficient to meet all the needs of civil aviation?
Ans. This is not a simple yes/no answer. The answer is that it depends on the service requirements of each user or aviation authority. For many countries, GPS supplies a better capability than the existing ground-based systems or lack thereof. Yet for other countries with large infrastructures, the GPS signal does not meet the accuracy, integrity, availability, and continuity requirements critical to safety of flight. Enhancements to the Global Positioning System (GPS) such as the Wide Area Augmentation System (WAAS) and Ground Based Augmentation System (GBAS) provide the necessary corrections for meeting safety-of-life flight requirements.

Que. What is Differential GPS (DGPS)?
Ans. In the basic form of DGPS, the position of a reference receiver at a monitoring or reference station is surveyed in, that is, its position is known accurately. The user receiver should be no more than about 300 miles away from the reference receiver which makes pseudorange measurements, just as any user receiver would. However, because the reference receiver knows its position accurately, it can determine “biases” in its pseudorange measurements. For each satellite in view of the reference receiver, these biases are computed by differencing the pseudorange measurement and the satellite-to-reference receiver geometric range. These biases incurred in the pseudorange measurement process include errors arising from ionospheric delay, tropospheric delay, and satellite clock offset from GPS time. For real-time applications, the reference station transmits these biases, called differential corrections, to all users in the coverage area of the reference station. Users incorporate these corrections to improve the accuracy of their position solution.

Que. Will the GPS tracking system make the fleet management easier?
Ans. Fleet management involves managing vehicles and personnel available. It also constitutes route planning, route optimization, personnel management, asset tracking, vehicle maintenance, report generation, fuel management, etc.

Que. What are the gains of implementing student GPS tracking system?
Ans. You need to be clear about the potential gains of installing a vehicle tracker in the school buses before you start out on a GPS tracking system. Is it truly worth the cost and effort? Does it provide what it promises to offer? You should also consider getting a detailed demo run so that you will be able to understand the functioning of the system.

Que. Do you need a cost effective solution for vehicle fleet management?
Ans. The budget for each school to implement an effective solution would definitely vary. For this reason, you should consider the number of vehicles, data base needed (e.g. up to street level), additional facilities required, such SMS or PUSH notification facilities, etc. It should be decided whether all the features offered in a system is actually useful for you. There are advanced systems which even offer guided voice directions to make school bus trips less cumbersome for bus drivers and attendants.

Que. What is the potential for a gap in GPS service?
Ans. The Air Force is confident GPS will continue to meet existing service commitments. Several years ago, the Air Force recognized the potential for an availability gap and took action to institutionalize procedures and processes to mitigate the potential gap or minimize any impact. Air Force Space Command developed key processes within the operational community as well as the acquisition community to extend the life of on-orbit assets and to ensure capability is delivered in a timely manner. Users can employ GPS with confidence today and continue to do so in the future. As identified by the General Accounting Office (GAO) in testimony to Congress, “There have been times before where people have worried about gaps and the Air Force has managed them quite successfully.”

Que. Is GPS under U.S. military control?
Ans. Though acquired and operated by the Department of Defense, GPS is a multi-use system owned by the United States Government and paid for by the U.S. taxpayer. The outstanding performance of GPS over decades has earned the confidence of millions of civil and military users worldwide. The management structure and modernization efforts directed by U.S. policy continue this support for multi-user applications. Any misperceptions will be overcome as they have in the past, by a demonstrated record of service and performance to all users.

Que. What are the benefits of GPS tracking?
Ans. GPS tracking tells you which employees are on the clock and where they’re located. You’ll be able to see who is closest to a customer when scheduling a new job on the fly, more effectively manage employees at various locations, identify inefficiencies in workloads and routes, and build trust by adding accountability safeguards that benefit everyone.

Que. How accurate is the GPS location data from the GPS device?
Ans. Different GPS devices offer differing levels of accuracy so always ask the question. AVS GPS devices have a high level of GPS accuracy of between 5 and 10 metres or better with clear skies.

Que. What is a GPS locator?
Ans. A GPS locator does not record regular position updates, it will only log its position on command. Simply send a TXT to the tracker and it will TXT back its’ location. Some GPS locators will send GPS co-ordinates (Latitude and Longitude) which can then be entered into Google to bring up a map.

Que. What are the limitations of GPS tracking?
Ans. GPS tracking is not invincible and no GPS hardware will be able to guarantee position logs 100% of the time. GPS devices rely on being able to communicate with the satellites in space and so in highly built up areas or underground carparks reception can be blocked.

Que. What is GPS tracking?
Ans. GPS tracking is a way of determining the location of a vehicle, person or other asset. A GPS device is attached to, or installed into, the asset you wish to track. The device then uses the Global Positioning System to record the position of the asset at regular intervals.

Que. what is trilateration?
Ans. A GPS receiver uses trilateration (a more complex version of triangulation) to determine its position on the surface of the earth by timing signals from three satellites in the Global Positioning System.

Que. What is the difference between triangulation and Trilateration?
Ans. As GPS satellites broadcast their location and time, trilateration measure distances to pinpoint their exact position on Earth. While triangulation is associated with surveying, no angles are actually involved in GPS positioning. Surveyors usetriangulation to measure distant points – not GPS receivers.

I hope this Question answer might have helped you in understanding Geographical information system and in clearing the Basics interview question of Geographical information system. Let us know if you have any other list of questions answer available in Geographical information system by commenting below in the space provided.

Geoserver FAQs – Geoserver Interview Question

GeoServer is one of the open source GIS Server, which serves Vector and Raster GIS files for instance, Shapefile, GML, KML, NetCDF, GeoTiff, GRIB, HDF5, PostGIS database etc. GeoServer is written in Java, which allows user to process, share, and edit the geospatial data. Here in this post we will check FAQs of Geoserver and Common Question asked during Interview Question.

Geoserver Interview Question – Frequently Asked Question GeoServer

Que. What is GeoServer?
Ans. GeoServer is an open source server for sharing geospatial data.

Que. What are map services?
Ans. Map services are the standard for generating maps on the web, and it is the primary interface to request map products from GeoServer.

Que. What is web server?
Ans. A web server is a program that serves content (web pages, images, files, data, etc.) using HTTP (Hypertext Transfer Protocol). When you use your browser to connect to a website, you contact a web server. The web server takes the request, interprets it, and returns a response, which the browser renders on the screen.

Que. What is web mapping servers?
Ans. A web mapping server is a specialized subset of web server. Like a web server, requests are sent to the server which are interpreted and responded. But the requests and responses are designed specifically toward the transfer of geographic information.

Que. Data sources read by geoserver?
Ans. “Files
Shapefile
GeoTIFF
ArcGrid
JPEG2000
GDAL formats
MrSID
Databases
PostGIS
ArcSDE
Oracle Spatial
DB2
SQL Server” and few more which can be extended by installing extensions.

Que. What you mean by OGC protocols?
Ans. GeoServer implements standard open web protocols established by the Open GeoSpatial Consortium (OGC), a standards organisation. GeoServer is the reference implementation of the OGC Web Feature Service (WFS) and Web Coverage Service (WCS) standards, and contains as well a high performance certified compliant Web Map Service (WMS). It is through these protocols that GeoServer can serve data and maps in an efficient and powerful way.

Que. Name some web mapping servers?
Ans. arcGIS server, geoserver, Mapserver, Mapnik etc.

Que. What is WMS in Geoserver?
Ans. A fundamental component of the web map (and probably the simplest to understand) is the map image. The Web Map Service (WMS) is a standard protocol for serving georeferenced map images generated by a map server. In short, WMS is a way for a client to request map tiles from a server. The client sends a request to a map server, then the map server generates an image based on parameters passed to the server in the request and finally returns an image.

Que. What is WFS in Geoserver?
Ans. A web mapping server can also (when allowed) return the actual geographic data that comprise the map images. One can think of the geographic data as the “source code” of the map. This allows users to create their own maps and applications from the data, convert data between certain formats, and be able to do raw geographic analysis of data. The protocol used to return geographic feature data is called Web Feature Service (WFS).

Que. What is SLD in GeoServer?
Ans. It defines an encoding that extends the WMS standard to allow user-defined symbolisation and coloring of geographic feature and coverage data.

Que. What is OGC?
Ans. The OGC (Open Geospatial Consortium) is an international not for profit organization committed to making quality open standards for the global geospatial community.

Que. Explain OGC filter.
Ans. The OGC Filter Encoding specification provides a generic concept of a filter function. Filters are used to select features or other objects from the context in which they are evaluated. They are similar in functionality to the SQL “WHERE” clause.

Que. Name OGC filter?
Ans. “,”and “.” There are many more, to know visit http://docs.geoserver.org/latest/en/user/filter/filter_reference.html

Que. What is spatial operator?
Ans. Spatial operators are used to specify conditions on the geometric attributes of a feature.

Que. What are the steps to publish data on geoserver?
Ans. Build workspace and add spatial data (Shape file or raster geoTiff) store after that publish the file by providing SRS information.

Que. How can we style data on geoserver?
Ans. To style data in geoserver you can visit style tab in data section.

Que. What is layer preview?
Ans. Layer preview in a section under data heading, which gives the details of published layer.

Que. Name format in which we can see layer in layer preview section.
Ans. KML, shapefile, CSV, geojson, GML etc.

Que. Name some vector data sources available on geoserver store.
Ans. ESRI shape file, postGIS, geoPackage, java property, and web feature server.

Que. Name some raster data sources available on geoserver store.
Ans. ArcGrid, geoTiff, gtopo30, Imagemosaic, worldImage, Netcdf and Grib with extension.

Que. What is caching defaults?
Ans. Caching Defaults page shows the global configuration options for the tile caching functionality in GeoServer

Que. What is geoWebCache?
Ans. Maps are often static. As most mapping clients render WMS (Web Map Service) data every time they are queried, this can result in unnecessary processing and increased wait times. GeoWebCache optimizes this experience by saving (caching) map images, or tiles, as they are requested, in effect acting as a proxy between client (such as OpenLayers or Google Maps) and server (such as GeoServer, or any WMS-compliant server). As new maps and tiles are requested, GeoWebCache intercepts these calls and returns pre-rendered tiles if stored, or calls the server to render new tiles as necessary. Thus, once tiles are stored, the speed of map rendering increases by many times, creating a much improved user experience.

Que. What are the data format which Can be styled on geoserver?
Ans. point, line, polygon and raster

Que. Can we replace point markers by icons?
Ans. yes, we Can. By using styling option and giving icon name in element.

Que. What is worldImage?
Ans. A world file is a plain text file used to georeference raster map images. This file (often with an extension of .jgw or .tfw) accompanies an associated image file (.jpg or .tif). Together, the world file and the corresponding image file is known as a WorldImage in GeoServer.

Que. What id Image Mosiac?
Ans. Imaging mosaicing is being doen in this project such that images taken by normal camera Can be used to create a larger field of view using a image mosaicing program. The program is basically a tools which help you to find out the corresponding camera angles that you used to take the image.

Que. What is arcGrid?
Ans. ESRI ArcInfo Grid (ESRI_grid), also known as ArcGrid, is a raster file format developed by ESRI to contain information about geographic space in a grid.

Que. What is PostGIS?
Ans. PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL.

Que. What is Gtopo30?
Ans. GTOPO30 is a global digital elevation model (DEM) with a horizontal grid spacing of 30 arc seconds (approximately 1 kilometer). GTOPO30 was derived from several raster and vector sources of topographic information.

Que. What is tile Layer in geoserver?
Ans. It shows a listing of all of the layers known to the integrated GeoWebCache. It is similar to the Layer Preview for GeoWebCache.

Que. What is SRS in GeoServer?
Ans. A spatial reference system (SRS) or coordinate reference system (CRS) is a coordinate-based local, regional or global system used to locate geographical entities. A spatial reference system defines a specific map projection, as well as transformations between different spatial reference systems.

Que. What is Raster image?
Ans. A raster consists of a matrix of cells (or pixels) organized into rows and columns (or a grid) where each cell contains a value representing information, such as temperature. Rasters are digital aerial photographs, imagery from satellites, digital pictures, or even sCanned maps.

Que. What is vector?
Ans. A representation of the world using points, lines, and polygons. Vector models are useful for storing data that has discrete boundaries, such as country borders, land parcels, and streets.

Que. Why geoserver is used?
Ans. With suitable preparation of data it excels at handling very large datasets, both raster and vector. It produces high quality rendering of maps and Can handle hundreds to thousands of map layers easily.

Que. Can geoserver provide faster acces for vector data.
Ans. yes.

Que. What is web administration interface?
Ans. the Web administration interface is a web-based tool for configuring all aspects of GeoServer, from adding data to changing service settings. In a default GeoServer installation, this interface is accessed via a web browser at http://localhost:8080/geoserver/web.

Que. What is granule?
Ans. In image mosiac, each individual image is commonly referred to as a granule.

Que. What is store in Geoserver?
Ans. A store connects to a data source that contains raster or vector data. A data source Can be a file or group of files, a table in a database, a single raster file, or a directory (for example, a Vector Product Format library). The store construct allows connection parameters to be defined once, rather than for each data-set in a source.

Que. What layer mean in Geoserver?
Ans. In GeoServer, the term “layer” refers to a raster or vector dataset that represents a collection of geographic features. Vector layers are analogous to “featureTypes” and raster layers are analogous to “coverages”.

Que. What is native SRS?
Ans. Specifies the coordinate system the layer is stored in.

Que. Explain layer group in geoserver.
Ans. A layer group is a container in which layers and other layer groups Can be organized in a hierarchical structure. A layer group Can be referred to by a single name in WMS requests. This allows simpler requests, as one layer Can be specified instead of multiple individual layers. A layer group also provides a consistent, fixed ordering of the layers it contains, and Can specify alternate (non-default) styles for layers.

Que. What is GML?
Ans. Geographic Markup Language (GML) is a XML based format for representing vector based spatial data.

Que. Explain geotiff format.
Ans. GeoTIFF is a public domain metadata standard which allows georeferencing information to be embedded within a TIFF file. The potential additional information includes map projection, coordinate systems, ellipsoids, datums, and everything else necessary to establish the exact spatial reference for the file.

Que. Why TFW format is used?
Ans. The TFW file extension is used for plain text files that store X and Y pixel size, rotational information, and world coordinates for a map that is stored as a TIFF image in a GIS application. A GIS (geographic information system) enables you to envision the geographic aspects of a body of data.

I hope this Question answer might have helped you in understanding Geoserver and in clearing the Basics interview question of Geoserver. Let us know if you have any other list of questions answer available in Geoserver by commenting below in the space provided.

Install PostGIS and PostgreSQL in Linux Ubuntu 16.4

In this post we are going to talk about How to install PostGIS and PostgreSQL in ubuntu 16.4 (LTS) or Linux system. As we know geographic information system (GIS) is a system designed to capture, store, manipulate, manage, and present spatial or geographic data. And PostGIS adds support for geographic objects allowing location queries to be run in SQL database. As PostGIS is a spatial database extender for PostgreSQL object-relational database. So without wasting time, Let’s start the post to know How to install PostGIS and PostgreSQL in your system.

Intro to PostGIS and PostgreSQL – Install

What is PostGIS?

PostGIS is an open source software program that adds support for geographic objects to the PostgreSQL object-relational database. PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC).

Technically PostGIS was implemented as a PostgreSQL’s extension. And There are a large number of software products that can use PostGIS as a database backend.

The PostGIS implementation is based on “light-weight” geometries and indexes optimized to reduce disk and memory footprint. Using light-weight geometries helps servers increase the amount of data migrated up from physical disk storage into RAM, improving query performance substantially.

PostGIS is registered as “implements the specified standard” for “Simple Features for SQL” by the OGC. PostGIS has not been certified as compliant by the OGC.

What is PostgreSQL?

PostgreSQL, often simply Postgres, is an object-relational database management system (ORDBMS) with an emphasis on extensibility and standards compliance. As a database server, its primary functions are to store data securely and return that data in response to requests from other software applications. It can handle workloads ranging from small single-machine applications to large Internet-facing applications (or for data warehousing) with many concurrent users; on macOS Server, PostgreSQL is the default database and it is also available for Microsoft Windows and Linux (supplied in most distributions). PostgreSQL is a powerful, open source object-relational database system and It runs on all major operating systems.

It is fully ACID compliant, has full support for foreign keys, joins, views, triggers, and stored procedures (in multiple languages)
PostgreSQL supports compound, unique, partial, and functional indexes which can use any of its B-tree, R-tree, hash, or GiST storage methods. GiST(Generalized Search Tree) serves as a foundation for many public projects that use PostgreSQL such a OpenFTS and PostGIS. And as I described above PostGIS is a project which adds support for geographic objects in PostgreSQL, allowing it to be used as a spatial database for geographic information systems (GIS), much like ESRI’s SDE or Oracle’s Spatial extension.

Install PostGIS and PostgreSQL

Installation of PostGIS and PostgreSQL is much simpler then you think. PostgreSQL is available in all Ubuntu versions by default. However, Ubuntu “snapshots” a specific version of PostgreSQL that is then supported throughout the lifetime of that Ubuntu version. Other versions of PostgreSQL are available through the PostgreSQL apt repository.
The PostgreSQL apt repository supports LTS versions of Ubuntu (14.04 and 16.04) on amd64, i386 and ppc64el architectures as well as select non-LTS versions(17.04). While not fully supported, the packages often work on other non-LTS versions as well, by using the closest LTS version available.
The following describes how to install Postgresql 9.6, PostGIS 2.3, pgRouting 2.3, PGAdmin on Ubuntu version 16.04. It is assumed to also work on Linux Mint, Lubuntu, and Xubuntu.
Run these in terminal:

  • Verifying version of ubuntu
    sudo lsb_release -a
  • Add Repository to sources.list

    For xenial (16.4.2 LTS)

    sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt xenial-pgdg main" >> /etc/apt/sources.list'
  • Adding keys
    wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - 
    sudo apt-get update
  • Installation

    The following will install postgresql 9.6, PostGIS 2.3, PGAdmin4, pgRouting 2.3 and additional supplied modules including the adminpack extension:

    sudo apt-get install postgresql-9.6
    
    sudo apt-get install postgresql-9.6-postgis-2.3 postgresql-contrib-9.6
    
    postgresql-9.6-postgis-scripts
    
    #to get the commandline tools shp2pgsql, raster2pgsql you need to do this
    sudo apt-get install postgis
  • To get pgRouting
    # Install pgRouting 2.3 package
    sudo apt-get install postgresql-9.6-pgrouting

Now we have successfully installed PostgreSQL and PostGIS into the system and pgAdmin lets you create everything using user interface. You don’t need to remember queries to create tables sequence etc. But I am still showing how to create the database from command line .

You may look over full pgRouting postgresql post in detail.

  • Enable Adminpack

    While in terminal, log in to the psql console as postgres user:

    sudo -u postgres psql
    CREATE EXTENSION adminpack;

    Never install PostGIS in the postgres database, create a user database You can also enable the PostGIS extension here (or with the GUI as described below):

    sudo -u postgres psql
    CREATE DATABASE gisdb;\connect gisdb;
    
    CREATE SCHEMA postgis;
    
    ALTER DATABASE gisdb SET search_path=public, postgis, contrib;
    
    \connect gisdb; 
     -- this is to force new search path to take effect
    
    CREATE EXTENSION postgis SCHEMA postgis;
    
    SELECT postgis_full_version();

    should give you output something like this:

                           postgis_full_version
    -----------------------------------------------------------------------
    POSTGIS="2.4.3 r16312" PGSQL="96" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.11.99" LIBPROTOBUF="1.2.1" RASTER
    (1 row)
  • Install pgRouting – postgis and postgresql

    CREATE  EXTENSION pgrouting;
    SELECT * FROM pgr_version();

    should give you:

    version |  tag   |   hash    | branch | boost
    --------+--------+-----------+--------+--------
      2.5.2 | v2.5.2 | 60585f1f7 | master | 1.58.0
    (1 row)
  • Exit the psql console:
    \q

    This is how we can make database and create schema in command line .

Now let’s see how we can do it in pgAdmin :

PgAdmin – Install PostGIS and PostgreSQL

PostgreSQL has a number of administrative front-ends. The primary one is psql a command-line tool for entering SQL queries. Another popular PostgreSQL front-end is the free and open source graphical to pgAdmin. All queries done in pgAdmin can also be done on the command line with psql.

  • Find pgAdmin and start it up.

    Install PostGIS and PostgreSQL
    Install PostGIS and PostgreSQL
  • If this is the first time you have run pgAdmin, you should have a server entry for PostGIS (localhost:5432) already configured in pgAdmin. Double click the entry, and enter anything you like at the password prompt to connect to the database.
    The PostGIS database has been installed with unrestricted access for local users (users connecting from the same machine as the database is running). That means that it will accept any word you provide. If you need to connect from a remote computer, the password for the PostgreSQL user has been set to PostgreSQL.

Creating a Database

  •  Open the Databases tree item and have a look at the available databases. The PostgreSQL database is the user database for the default PostgreSQL user and is not too interesting to us.
  • Right-click on the Databases item and select New Database.
    Install PostGIS and PostgreSQL
  • Fill in the New Database form as shown below and click OK.
     Name   |  nyc     |
     -------+----------+
     Owner  | postgres |

    Install PostGIS and PostgreSQL
    Install PostGIS and PostgreSQL
  • Select the new nyc database and open it up to display the tree of objects. You’ll see the public schema.
    Install PostGIS and PostgreSQL
  • Click on the SQL query button indicated below (or go to Tools > Query Tool).Install PostGIS and PostgreSQL
  • Enter the following query into the query text field to load the PostGIS spatial extension:
    CREATE EXTENSION postgis;
  • Click the Play button in the toolbar (or press F5) to “Execute the query.”
  • Now confirm that PostGIS is installed by running a PostGIS function:
    SELECT postgis_full_version();

You have successfully created a PostgreSQL database with PostGIS!! Let us know by commenting below if you have faced any problem in Install PostGIS and PostgreSQL. Or comment below with the trick you have applied to install postgis.

PGrouting PostGIS Postgresql – No need for Google routing

Do you have all road data with you and want to creating routing from that according to your algorithm? Needs an alternative to Google Map API, when having your own road datasets? PGrouting with PostGresSql can help you out by doing that. Here in this post we will look for PGRouting PostGreSql implementation steps by steps and finding the direction with PGRouting. Connection between PostGres and QGIS and query data and see the result in QGIS Desktop.

Prerequisite for PGrouting PostGIS Postgresql:

  • Installed QGIS and installed PostGreSql
  • Basic Knowledge of PostGreSQL
  • Basic knowledge with QGIS Desktop
  • Road Map Shapefile

Here we will consider Road Map Shapefile, on which we will query and get the routing. In this article we will see how we can query the road network shapefile to find out the shortest path. The results can be seen in QGIS Desktop software. Here postGIS is used to generate road network. In this tutorial we have id of each route, which is used to query the shortest route. You will understand more easily once you read this article throughly. Here PGrouting has used to find out the shortest path.

Install Postgresql PostGIS PGRouting:

Its installation is simple process include few steps (written an article for linux based system). Here are few points for installing postgresql PGRouting:

# Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository

--> sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ CODENAME-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

The codename can find by using given command

 --> lsb_release -cs

Output:

 Codename xanial

Then replace this codename in command.

# Import the repository key, update the package lists

--> sudo apt-get install wget ca-certificates
 --> wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
 --> sudo apt-get update

# Install PGrouting based on your postgresql Installation:

--> sudo apt-get install postgresql-9.6-pgrouting

To be up to date with changes and improvements follow the given command

--> sudo apt-get update & sudo apt-get upgrade

PGRouting PostGreSql PostGIS Shortest Path Steps:

In this article we are using postgres 9.6, PostGIS 2.4.2 and Pgrouting 2.5.2. It is better to check versions for all required software as query syntax change with version. Firstly create a database.

1. Create database in PostGreSql for PGRouting:

You can create a database in Ubuntu terminal. For that you need to follow the given command-

 --> sudo -u postgres createdb -O DATABASE_USER DATABASE_NAME

where -U username, Createdb is command which create new postgresql database, -O output file name, last two options are Database user-name and name for database. For more option in psql visit https://www.postgresql.org/docs/9.0/static/app-psql.html link.

2. Add shape file in postgresql pgrouting database:

If you are using pgAdmin3 then you can open the database by providing user name and password.

In Database you can add shapefile by clicking option PostGIS shape file and DBF loader. Here first off define the user-name with proper password and database name. Then add shape file and import it.

You can use this link to import or upload Shapefile in PostGreSql database.

Now refresh the database and expand public-> tables option you see the shape file’s attribute table.

3. Add Source and target column in attribute table:

The given command will add column in attribute table, named as source and target with integer data type. Here roads_table is the attribute table or imported shape file.

--> ALTER TABLE roads_table ADD COLUMN "source" integer;
--> ALTER TABLE roads_table ADD COLUMN "target" integer;

4. Create topology – PGRouting:

Here you must be aware of what is topology when working with spatial system. Topology is a set of rules and behaviours that model how points, lines, and polygons share coincident geometry.

Here creating topology means attaching nodes to every end point of route. This is done using method from pgrouting that is pgr_createTopology().
This takes table name, tolerance, geom field name and id as inputs.

--> SELECT pgr_createTopology('roads_table', 0.001, 'the_geom', 'id')

More detailed explanation is given below:

The topology creation function accepts the following parameters:

-> edge_table:

Text Network table name. (may contain the schema name AS well)

-> tolerance:

Float8 Snapping tolerance of disconnected edges. (in projection unit)

-> the_geom:

Text Geometry column name of the network table. Default value is the_geom.

-> Id:

Text Primary key column name of the network table. Default value is id.

-> Source:

Text Source column name of the network table. Default value is source.

-> Target:

Text Target column name of the network table. Default value is target.

-> rows_where:

Text Condition to SELECT a subset or rows. Default value is true to indicate all rows that where source or target have a null value, otherwise the condition is used.

-> Clean:

Boolean Clean any previous topology. Default value is false.

For more details: http://docs.pgrouting.org/2.2/en/src/topology/doc/pgr_createTopology.html

5. Create network table – PGrouting PostGIS Postgresql:

This table contains all information such as gid, length of routes, name of roads, source and target. Here source and target is taken from node table where as other information from attribute table. For this first we need to create node table.

In node table you have source as a start_id and target as end_id.

CREATE TABLE node AS
 SELECT row_number() OVER (ORDER BY foo.p)::integer AS id,
 foo.p AS the_geom
 FROM (
 SELECT DISTINCT roads_table.source AS p FROM roads_table
 UNION
 SELECT DISTINCT roads_table.target AS p FROM roads_table
 ) foo
 GROUP BY foo.p;

This explains that distinct values of source and target from roads_table table is selected and union operation has performed. Then number of rows are selected from this union table and saved them in node table.

CREATE TABLE network AS
 SELECT a.*, b.id as start_id, c.id as end_id
 FROM roads_table AS a
 JOIN node AS b ON a.source = b.the_geom
 JOIN node AS c ON a.target = c.the_geom;

This query explains that in network table b.id is named as start_id and c.id as end_id.

Now we will use pgr_dijkstra method from PGrouting PostGIS Postgresql

The minimal syntax is given

pgr_dijkstra(TEXT edges_sql, BIGINT start_vid, BIGINT end_vid)
 RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost) or EMPTY SET

This returns seq, path sequence, node, edge, cost, agg_cost fields.

Select seq, node, edge,cost, geom from pgr_dijkstra(
 'Select gid as id, source, target, st_length(geom) as cost from network', 3566,20051, false) as di
 JOIN network pt
 ON di.edge = pt.gid ;

Here we have joined network table to select geometry field. This all command would be running in SQL window in DB manager option in QGIS.

You can create a shape file as a result for query. For that you need to click on load as new layer option then provide geom as geometry option and edge as column with unique values and click load. The result layer will be added to canvas of QGIS.

PgRouting PostGIS PostGreSql using Latitude Longitude for source and destination:

You just need to change the last command in SQL window of QGIS software.

Select seq, node, edge,cost, geom, agg_cost from pgr_dijkstra(
 'Select gid as id, source, target, st_length(geom::geography)/1000 as cost from network',(SELECT source FROM network
 ORDER BY geom <-> ST_SetSRID(ST_Point
 (74.862413,24.476381),4326) LIMIT 1),
 (SELECT source FROM network
 ORDER BY geom <-> ST_SetSRID(ST_Point
 (75.857734,22.719588),4326) limit 1), false) as di
 JOIN network pt
 ON (di.edge = pt.gid);

This query explains that we are using pgr_dijkstra from pgrouting which takes sql_text,integer start_id, integer end_id and boolean type for directed route. If route is directed, give input as true otherwise false. Here in this article we have undirected route. As now in place of we want to give latitude and longitude so for that given query has executed.

SELECT source FROM network ORDER BY geom <-> ST_SetSRID(ST_Point (75.857734,22.719588),4326) limit 1

This part is little interesting, first of all we need to understand that always we provide latitude longitude of point(place), not of any line (road). So this point can be restaurant, stops, hotels or hospitals etc.

Now the very first task is to find out the nearest path from these points. For that we used <-> from postgis.

<-> — Returns the distance between two points.

Now we may have 2 or more path from selected point. So the shortest one should be selected from these path, For that we used order by command which arranges these path in ascending order and after that limit 1 command selects top most 1 row, which his nothing but the shortest path from source to path. Similar concept is applied on end point also.

Syntax of postgresql:

double precision <->( geometry A , geometry B );

The <-> operator returns the 2D distance between two geometries. Used in the “ORDER BY” clause provides index-assisted nearest-neighbor result sets. For PostgreSQL below 9.5 only gives centroid distance of bounding boxes and for PostgreSQL 9.5+, does true KNN (K nearest neighbor) distance search giving true distance between geometries, and distance sphere for geographies.

Syntax of postgresql:

geometry ST_SetSRID(geometry geom, integer srid); 
geometry ST_Point(float x_lon, float y_lat);

In ST_Point we give source and destination latitude longitude. Using ST_SetSRID Set the SRID on a geometry to a particular integer value. Here EPSG 4326 is used which is WGS84 datum. EPSG stands for European Petroleum Survey Group, They publish a database of coordinate system information. SELECT source FROM network this returns source id. Similarly got source id of end point. Then cost is set as length of route in kilometers. All these provided to pgr_dijsktra method and join network table to take geometry as output to show result in QGIS.

Output of PGrouting PostGIS Postgresql – No need for Google routing

Here is the output of route which is rendered with QGIS Desktop, where green color indicates the road network and red color display the shortest distance we get from A and B.

PGrouting PostGIS Postgresql - No need for Google routing
PGrouting PostGIS Postgresql – No need for Google routing

We got good results as distance from A to B is calculated as 368Km and on Google map it is 361 km. Similarly many points have tested and result vary from 6 to 8Km.

Did you tried PGRouting postgis postgresql? If you are facing any issue, do let us know by commenting below with the solution.

KML to GML – Convert Keyhole to Geography

Sometimes we need to convert KML to GML where the software supports GML language. But before converting Keyhole markup language to Geography markup language, you should know the basic structure of KML and GML. So that if the file is corrupted then before converting it you can correct it manually and process the same in any GIS converter software to work properly. If you already know structure of this files, then you can directly navigate to the main topic i.e kml to gml conversion of this page.

Here is the Online Converter Tool from KML To GML 

Know KML and GML data structure before converting kml to gml

WHAT IS KML (Keyhole Markup Language)? – KML (Keyhole Markup Language), is an XML grammar and file format for modeling and storing geographic features such as points, lines,images, and polygons for display in the Google Earth client.KML is based on GML, although it doesn’t formally import GML schemas. KML language is used by a variety of GIS and mapping applications and the specifications are freely available to the public and available to the user community without charge or restriction. The Google Earth client supports a number of display features for rich presentation of GIS data. All of the features supported by the Google Earth client are described in KML. The Google Earth client supports a number of two-dimensional geometric shapes for display in the 3D viewer.

<Schema name="roads" id="roads">
 <SimpleField name="MED_DESCRI" type="string"></SimpleField>
 <SimpleField name="RTT_DESCRI" type="string"></SimpleField>
 <SimpleField name="F_CODE_DES" type="string"></SimpleField>
 <SimpleField name="ISO" type="string"></SimpleField>
 <SimpleField name="ISOCOUNTRY" type="string"></SimpleField>
 <SimpleField name="Length_km" type="float"></SimpleField>
 <SimpleField name="Latitude" type="string"></SimpleField>
 </Schema>
 <Folder><name>roads</name>
 <Placemark>
 <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
 <ExtendedData><SchemaData schemaUrl="#roads">
 <SimpleData name="MED_DESCRI">Without Median</SimpleData>
 <SimpleData name="RTT_DESCRI">Secondary Route</SimpleData>
 <SimpleData name="F_CODE_DES">Road</SimpleData>
 <SimpleData name="ISO">IND</SimpleData>
 <SimpleData name="ISOCOUNTRY">US</SimpleData>
 <SimpleData name="Length_km">0.3</SimpleData>
 </SchemaData></ExtendedData>
 <LineString><coordinates>77.8277403975188,35.5012774951028 77.8257523065223,35.4995003281062</coordinates></LineString>
 </Placemark>

WHAT IS GML (Geography Markup Language)? GML (Geography Markup Language) is only concerned with the representation of the geographic data content. While GML is an effective means for transporting geographic information from one place to another we expect that it will also become an important means of storing geographic information as well.

<gml:boundedBy>
 <gml:Box>
 <gml:coord><gml:X>-164404.6900820375</gml:X><gml:Y>893749.1179630321</gml:Y></gml:coord>
 <gml:coord><gml:X>2727970.187011702</gml:X><gml:Y>3932312.865004988</gml:Y></gml:coord>
 </gml:Box>
 </gml:boundedBy>
 <gml:featureMember>
 <ogr:raods fid="raods.0">
 <ogr:geometryProperty><gml:LineString srsName="EPSG:32643"><gml:coordinates>756486.657418272,3932312.4133327 756311.93383727,3932110.06520674</gml:coordinates></gml:LineString></ogr:geometryProperty>
 <ogr:MED_DESCRI>Without Median</ogr:MED_DESCRI>
 <ogr:RTT_DESCRI>Secondary Route</ogr:RTT_DESCRI>
 <ogr:F_CODE_DES>Road</ogr:F_CODE_DES>
 <ogr:ISO>IND</ogr:ISO>
 <ogr:ISOCOUNTRY>US</ogr:ISOCOUNTRY>
 <ogr:Length_km>0.3</ogr:Length_km>
 <ogr:Latitude xsi:nil="true"/>
 </ogr:USraods>
 </gml:featureMember>
 <gml:featureMember>

Convert KML to GML using Ogr2ogr utility-

For using this utility you need to install GDAL OGR2OGR in your system. To  install this you can follow the given commands.

KML to GML - Convert Keyhole to Geography
KML to GML – Convert Keyhole to Geography

If you have already install ogr2ogr utility you can check by typing ogr2ogr in terminal.

KML to GML - Convert Keyhole to Geography

Now run the given command to convert from KML to GML-

--- ogr2ogr -f 'GML' Output_GML.gml Input_KML.kml

Changing Coordinate System of Output File kml to gml-

Sometimes we need different coordinate system. So to get different coordinate system from input you can follow this given command.

--- ogr2ogr -f 'GML' -t_srs EPSG:32643 -s_srs EPSG:4326 Output_GML.gml Input_KML.kml

Convert KML (KeyHole Markup Language) to GML (Geography Markup Language) Using PHP Code-

If you want the conversion using programing or don’t want to use terminal then this can also be done using PHP. You can create a function that defined this command as string and can give this string in shell_exec() method to execute. Shell_exec() actually execute the command and returns output as string.

public function kmltogml($kmlfilepath,$output,$srsno,$srsold){
 $query="ogr2ogr -f GML -t_srs EPSG:$srsno -s_srs EPSG:$srsold $output.gml $kmlfilepath";
 shell_exec($query);
 }

Generated output of kml to gml –

KML to GML - Convert Keyhole to Geography
KML to GML – Convert Keyhole to Geography

If you have any problem regrading this tutorial, please let us know via comments  in provided comments box.