Blog

Connect QGIS to oracle spatial – Quantum GIS

How to connect QGIS to oracle spatial. QGIS can now connects to oracle to view spatial data and process it, great news for an open source software believers. As a newbie to QGIS user, i can just give a way, that i connected to it.

How to connect QGIS to oracle spatial :

1.) Firstly you should have downloaded QGIS with GDAL/OGR required oracle library for bridging oracle connectivity and must have installed oracle  on your machine. If oracle library is not installed, see the following post : Install QGIS for oracle connection via OSGeo4w.

2.) After starting the QGIS application,  select Add Vector Layer as shown below:

Connect QGIS to oracle spatial
Connect QGIS to oracle spatial

3.) A new window will pop up on clicking the above, now select Database Radio button as appeared in Source. Now in Database Type drop down box, select Oracle Spatial. If you have properly installed QGIS with the requirement stated above Oracle spatial would be present.

Connect QGIS to oracle spatial
Connect QGIS to oracle spatial

4.) In the same Add Vector Layer window, select new button under connection label. This will open up a simple form with following Connection information to be filled, i.e, Type, Name, Host, Database, Port, Username and Password.

Here is the way to fill up the information :

a.) Type : In type select oracle spatial from drop down  box.

  Type : Oracle Spatial

Connect QGIS to oracle spatial
Connect QGIS to oracle spatial

b.) Name : Type in any desired name you wish to give to connection

c.) Host : For finding your host name, make a query in your oracle sql plus application as written below:

SELECT UTL_INADDR.GET_HOST_ADDRESS FROM DUAL;

This will return the 32 bit address as shown below in figure:

Connect QGIS to oracle spatial
Connect QGIS to oracle spatial

d.) Database : Write database name, i.e the name you have given while installing oracle software.

e.) Port : Enter port number i.e 1521

f.) Username : Enter username

g.) Password : Enter corresponding password of username

Connect QGIS to oracle spatial
Connect QGIS to oracle spatial

Now select Test Connection button. This will pop up another window which gives you an information of your successful connection, as shown below.

Connect QGIS to oracle spatial
Note the string url connection to connect QGIS to oracle spatial and click OK.

5.)  Again in the vector data layer window, select the connection that you made named as Demo and click on Open button.

6.) Now select the coordinate system for your database, which will be prompted after proceeding from step 5.

Connect QGIS to oracle spatial
Connect QGIS to oracle spatial

7.) If all steps are successfully done, you can see your spatial table, with your vector data spatial view as shown below:

Connect QGIS to oracle spatial

Feel free to comment below, if you are having any problem to connect Oracle Spatial to QGIS Quantum GIS (Geographic information System) or if you want to discuss for the same topic. You can also see QGIS tutorial further. And yes, don’t forget to subscribe and follow on twitter for getting updates related to GIS post.

Download and Install quantum GIS – QGIS with oracle connectivity

Download and Install quantum GIS – QGIS with oracle connectivity. Quantum GIS is an open source cross platform software for developing GIS (Geographic information System) solutions. QGIS connects to large set of spatial database and supports many data file formats, which enable us to visualize data, analyze data, edit data and generate a final map. QGIS is a best alternative to ESRI ARCGIS Desktop and is available for free under GNU General Public License. You can download and install Quantum GIS from either of the two way, i.e by standalone installer software or you can install it with OSGeo4w installer. OSGeo stands for open source geospatial foundation which include many open source projects, geospatial libraries, desktop application and web mapping.

While QGIS can be installed by one click with QGIS standalone installer, but it is better to install QGIS with OSGeo4w software as it helps you to install  many libraries and packages with QGIS. As this post topic is  concentrating for QGIS with oracle connectivity, so, for that reason we need to install GDAL/ORG library with QGIS , and it would be easy for you to install with support of OSGeo4w installer.

You might be interested in looking at QGIS tutorial.

If you have already done with this, you can see post to connect qgis with oracle :  QGIS connect with oracle.

Download and Install quantum GIS – QGIS with oracle connectivity:

1.) Download osgeo4w installer, from the link provided http://trac.osgeo.org/osgeo4w/.

 

a.)Run the installer and select “advanced Install” and select “Next”.

b.)Choose Install from internet when choose download source appears, as shown below.

Download and Install quantum GIS - QGIS with oracle connectivity
Download and Install quantum GIS – QGIS with oracle connectivity

c.)Select root directory, then next and select package directory and select next. Choose your internet connection. Default installation directory will be, C:\OSGeo4W. If you want to change the directory you can choose and select the same, as shown below.

Download and Install quantum GIS - QGIS with oracle connectivity
Download and Install quantum GIS – QGIS with oracle connectivity

2.) Select package to install will be prompted on the same window, Wait, don’t select next. You need to select the desire packages from the following open source utilities, enlisted below:

Download and Install quantum GIS - QGIS with oracle connectivity
Download and Install quantum GIS – QGIS with oracle connectivity

a.) Command line utilities: Dont need to select any utitlies from this for our above aim.

b.) Desktop utilities: Here, select the following libraries:

i.)  grass : Geographic Resource Analysis Support System

ii.) qgis : Quantum GIS (desktop)

iii.) qgis-dev : Quantum GIS rightly build of the master

Download and Install quantum GIS - QGIS with oracle connectivity
Download and Install quantum GIS – QGIS with oracle connectivity

c.)Libs (Library): By selecting above desktop utitlies, some libraries which are connected with above desktop utilites will get selected by default. Let it be selected and dont make any change in that. For getting oracle connection, some of libraries you need to select by clicking and making cross across that. This libraries are as follows:

i.) gdal : The GDAL/OGR library and command line tools

ii.) gdal-ffegdb : OGR fileGDB driver

iii.) gdal-oracle : OGR OCI and GDAL GeoRaster Plugins for Oracle

iv.) gdal-oracle 10g: Oracle 10g Plugin for GDAL(OGR)

v.) gdal 16-oracle : OGR OCI and GDAL Geo Raster Plugins for Oracle

Download and Install quantum GIS - QGIS with oracle connectivity
Download and Install quantum GIS – QGIS with oracle connectivity

d.)Web and Web application.

2.) After selecting all libraries, click on next. This step will connect you to internet and install all the library and utilities that you have selected. This may take some time to download  and install.

Download and Install quantum GIS - QGIS with oracle connectivity
Download and Install quantum GIS – QGIS with oracle connectivity

3.) All done. Now Open Quantum GIS and select add vector layer. Now select database in vector layer window and see if oracle spatial is on the list or not.

Download and Install quantum GIS - QGIS with oracle connectivity

If every thing is perfect, You can now move this post for connecting qgis with oracle:  How to connect to Qunatum GIS with oracle.

Check  : Create Web Maps using QGIS2WEB

 

If you are having any problem to Download and Install quantum GIS – QGIS with oracle connectivity, comment on below. As i am also a newbie to QGIS, we will discuss and make out some proper solution.

Merge more than two Shapefile in QGIS

Merge more than two Shapefile in QGIS. Do you want to merge two or more than two Shapefile? Do all the Shapefile are of same shape type i.e the Shapefile which can be merged with each other should have an identical shape, i.e either  “Point”, “Line” or “Polygon”? Do Shapefile all 3 files i.e .shx, .shp and .dbf are available? Then let us move to QGIS (Quantum GIS), an Open source Geographic information System Software. If not installed in your system, one of the way to install QGIS, with OSGeo4W provides or either you can install QGIS with standalone software. Let us move to Merge more than two Shapefile:

You may also find how to merge two or more than two features in shapefile.  Also you may read more tutorials in QGIS.

Merge more than two Shapefile in QGIS

1.) Take and copy all Shapefiles to a common folder which you want to merge.

2.) Open up QGIS desktop and select the following from the menu :

  • Vector -> Data Management tools -> merge shapefile to one, which will open up new window “Merge Shapefiles”, as shown below.
Merge more than two Shapefile in QGIS
Merge more than two Shapefile in QGIS

3.) Now select the browse input directory to the folder you created which include all Shapefile that you need to copy. Also browse the Output directory for getting the new merged Shapefile, and name the output file, as shown below:

Merge more than two Shapefile in QGIS
Merge more than two Shapefile in QGIS

4.) Press Ok. It will process your all shapefile and merge it to one. Finished.

  • Note: New .dbf file will contain sum of column of two shapfefile minus common column.

Here you can see the output of two merged Shapefile of Road and Rail Route of India.

1.) Road Shapefile of india

Merge more than two Shapefile in QGIS
India Road – Merge more than two Shapefile in QGIS

2.) Rail Route Shapefile

India Rail - Merge more than two Shapefile in QGIS
India Rail – Merge more than two Shapefile in QGIS

3.) Final Output : Merged Shapefile :

Merge more than two Shapefile in QGIS
Merge more than two Shapefile in QGIS

Hope this helps you to merge two or more shapefile with the help of QGIS tool. You can also find QGIS operation to convert Shapefile to GeoJSONconvert kml to Shapefile and Shapefile to KML. If you find any problem on implementing the above steps do comment below. Your suggestions are always welcome as comment.

Pan-sharpening images using ArcGIS

Pan-sharpening images using ArcGIS. Pansharpening is the process which makes use of panchromatic image and some bands of multispectral image to result in a high resolution image. Pansharpening stands for panchromatic sharpening. Here sharpening basic refers to increase the spatial resolution of multisprectral image or color image. This technique of increasing resolution has been used by various organisations that provide satellite imagery of high resolution like Google images etc.

A multi spectral image is captured with high spectral resolution as it is displayed in different colors while the panachromatic image is captured with high spatial resolution and provides a cluster of red, green and blue pixels resulting in a gray scale image.Now the question is how we get a pan-sharpened image? The possible answer by an ArcGIS user can be it’s just a tool to run. But is it that easy? No. Both the images has to be pre-processed before applying this tool which comes out to be a tough process if you have  a number of tiles for your area of interest.

Pan-sharpening images using ArcGIS

  • First of all start with the multispectral image let’s say a cartosat image with a resolution of 1 arc sec. Start with stacking of different bands(either all even or all odd number) in Erdas imagine. Perform Geo-referencing of each tile making one tile static.
  • Then mosaicing of tiles in ArcGIS using Mosaic tool of data management tool set. The panchromatic image will be a single band image say panchromatic band of lansat image with 15 m resolution so it does not need to be stacked. So just mosaic all the tiles of panchromatic image. Geo-reference both multispectral and panchromatic image accordingly so that they both are same spatial location without any spatial difference.
  • Now apply tool create pan-sharpened raster data-set of data management tool-set.

Thus a multispectral image with high spatial resolution is obtained. As panchromatic image possess high spatial information and multispectral image possess good color information. Fusion of the two brings out a colored image of high resolution which can be used as a product for any client who want an detailed view of his area of interest.

c++ program to read shapefile header

c++ program to read shapefile header. Shapefile can be read if you know the format of Shapefile files i.e of .shp, .shx, and .dbf file. ESRI provided technical description of the Shapefile files which describes very clearly about the format of storage of data in all three formats i.e .shp, .shx and .dbf. You can also interpret and take the advantage to make simple GIS tool which can read and edit Shapefile properly. Here is the link of the Shapefile technical descrption :
ESRI Technical Discription. This program reads only Shapefile .shp header, which includes file code, length, version, bounding box coordinates and the type of shape Shapefile you loaded. You can also find simple program that just reads about bounding box of that shapefile. The code is explained with the comments provided in all function that you found.

c++ program to read shapefile header:

#include<iostream>
#include<stdio.h>
#include<conio.h>

using namespace std;

class ByteConverter
{
    public:
        //Convert 32 bits which is stored in BigEndian format to integer. This is performed with the help of bit operation i.e left shifting and operating or.
    static int32_t bigEndianIntRead(char *fileBuf, int startIndex)
    {
        return (((fileBuf[startIndex + 0] & 0xff) << 24) | ((fileBuf[ + 1] & 0xff) << 16)| ((fileBuf[startIndex + 2] & 0xff) << 8) | ((fileBuf[startIndex + 3] & 0xff)));
    }
    //Convert 32 bits which is stored in BigEndian format to integer. This is performed with the help of bit operation i.e left shifting and operating or.
    static int32_t littleEndianIntRead(char *fileBuf, int startIndex)
    {
        return (((fileBuf[startIndex + 3] & 0xff) << 24) | ((fileBuf[startIndex + 2] & 0xff) << 16) | ((fileBuf[startIndex + 1] & 0xff) << 8) | ((fileBuf[startIndex + 0] & 0xff)));
    }
    //Convert 64 bits or 8 Byte which is stored in BigEndian format to integer. This is performed with the help of bit operation i.e left shifting and operating or.
    static double littleEndianDoubleRead(char *fileBuf,int startIndex)
    {
        double convert;
        char *add;
        int j;
        add = new char();
        j=-1;
        for(int i=startIndex; i<startIndex+8; i++)
        {
            j++;
            add[j] = fileBuf[i];
        }
        convert = *reinterpret_cast<double * const>(add);
        return convert;
    }
};

//Class HeaderShapefile have all funtion implemented to desribe every field of shapefile header file.
class HeaderShapefile
{
    public:
        //filecode describes the code of .shp file. As described in Shapefile Technical description of ESRI, filecode
        //value is always constant and should have 9994 value.
    static int32_t fileCode(char*fileBuf, int startIndex)
    {
        return ByteConverter::bigEndianIntRead(fileBuf,startIndex);
    }

        //File length contains Length of the file field
    static int32_t fileLength(char*fileBuf, int startIndex)
    {
       return ByteConverter::bigEndianIntRead(fileBuf,startIndex);
    }
        //Version function
    static int32_t version(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianIntRead(fileBuf,startIndex);
    }
        //Function shapeType describes the type of the shape. It returns an 32 bit integer
        //value. This integer is then matched with the cooresponding shape as described in ESRI shapefile pdf
    static int32_t shapeType(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianIntRead(fileBuf,startIndex);
    }

    //This remaning funtion of the class will calculate the bounding box coordinates of the shapefile.
    //Following values i.e x and y minimum and maximum values also with z and m minimum
    // and maximum values are obtained.


    static double dimensionXMin(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf,startIndex);
    }

    static double dimensionYmin(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionXmax(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionYmax(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionZmin(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionZmax(char*fileBuf, int startIndex)
    {
       return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionMmin(char*fileBuf, int startIndex)
    {
       return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionMmax(char*fileBuf, int startIndex)
    {
       return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }
};

class SizeOfFile
{
    public:
        //This function finds the size of file in Byte
    static long sizeOfFiles(FILE *file)
    {
            long l, e;
            l = ftell(file);
            fseek(file, 0, 2);
            e = ftell(file);
            fseek(file, l, 0);
            return e;
    }
};

int main()
{
    int32_t filecodes, fileLengths, shapeTypes, versions;
    double xmin, ymin, xmax, ymax, mmin, mmax, zmin, zmax;
    string shape;
    char *filePath = "map.shp";
	char*fileBuf;			// Pointer to our buffered data
	FILE *file = NULL;		// File pointer
	// Open the file in binary mode using the "rb" format string
	// This also checks if the file exists and/or can be opened for reading correctly
	if ((file = fopen(filePath, "rb")) == NULL)
		cout << "Could not open specified file" << endl;
	else
		cout << "File opened successfully" << endl;

	// Get the size of the file in bytes
	long fileSize = SizeOfFile::sizeOfFiles(file);

	// Allocate space in the buffer for the whole file
	fileBuf = new char[fileSize];

	// Read the file in to the buffer
	fread(fileBuf, fileSize, 1, file);

	// Now that we have the entire file buffered, we can take a look at some binary infomation

	cout<<"File size = " <<fileSize;
	cout<<"File size get = "<<fileBuf;

    filecodes = HeaderShapefile::fileCode(fileBuf,0);
    fileLengths = HeaderShapefile::fileLength(fileBuf,24);
    versions = HeaderShapefile::version(fileBuf,28);
    shapeTypes = HeaderShapefile::shapeType(fileBuf,32);
    xmin = HeaderShapefile::dimensionXMin(fileBuf,36);
    ymin = HeaderShapefile::dimensionYmin(fileBuf,44);
    xmax = HeaderShapefile::dimensionXmax(fileBuf,52);
    ymax = HeaderShapefile::dimensionYmax(fileBuf,60);
    zmin = HeaderShapefile::dimensionZmin(fileBuf,68);
    zmax = HeaderShapefile::dimensionZmax(fileBuf,76);
    mmin = HeaderShapefile::dimensionMmin(fileBuf,84);
    mmax = HeaderShapefile::dimensionMmax(fileBuf,92);

    /*****************HEADER SHAPEFILE DETAIL*********************/

    cout<<endl<<"/*****************HEADER SHAPEFILE DETAIL*********************/";

    cout<<endl<<"File code = "<<filecodes<<endl;
    cout<<"File Length = "<<fileLengths<<endl;
    cout<<"Version = "<<versions<<endl;

    //This shapefile shapetypes can be found in the technical discription.
    switch(shapeTypes)
    {
        case 0:
            shape = "Null Shape";
            break;
        case 1:
            shape = "Point";
            break;
        case 3:
            shape = "Poly Line";
            break;
        case 5:
            shape = "Polygon";
            break;
        case 8:
            shape = "MultiPoint";
            break;
        case 11:
            shape = "PointZ";
            break;
        case 13:
            shape = "PolyLineZ";
            break;
        case 15:
            shape = "PolygonZ";
            break;
        case 18:
            shape = "MultiPointZ";
            break;
        case 21:
            shape = "PointM";
            break;
        case 23:
            shape = "PolyLineM";
            break;
        case 25:
            shape = "PolygonM";
            break;
        case 28:
            shape = "MultiPointM";
            break;
        case 31:
            shape = "MultiPatch";
            break;
        default:
            shape = "Wrong match found";
            break;
    }
    cout<<"Shape Type = "<<shape<<endl;

    cout<<endl<<"************* Bounding Box **************"<<endl;
    cout<<"X minimum = "<<xmin<<endl;
    cout<<"Y minimum = "<<ymin<<endl;
    cout<<"X maximum = "<<xmax<<endl;
    cout<<"Y maximum = "<<ymax<<endl;
    cout<<"Z minimum = "<<zmin<<endl;
    cout<<"Z maximum = "<<zmax<<endl;
    cout<<"M minimum = "<<mmin<<endl;
    cout<<"M maximum = "<<mmax<<endl;

	cin.get();
	delete[]fileBuf;
        fclose(file);   // Almost forgot this
	return 0;
}

Output of c++ program to read shapefile header:

c++ program to read shapefile header
c++ program to read shapefile header

Get minimum Bounding box of shapefile c++ program

Get minimum Bounding box of shapefile c++ program. This program not only reads shapefile, but makes you aware to read other files, i.e files which have .dbf, .exe, .png etc format without having software. Before that you should know about bits, byte order, and conversion of bytes to other data types and most importantly the format of the files that you want to read.

A shapefile stores non topological geometry. ESRI shapfile mainly contains 3 files, i.e .shp, .shx and .dbf files. To get bounding box details of shapefile, we need to concern about .shp file format. You can find all the technical discription of shapefile, provided by esri in their website.

Shapefile .shp has 3 parts, i.e file header, record header and record contents. File header stores the bounding box of shapefile. You can also see c++ program to read shapefile header. Here is the program:

Get minimum Bounding box of shapefile c++ program

#include<iostream>
#include<stdio.h>
#include<conio.h>

using namespace std;

class ByteConverter
{
    public:
        //Convert 32 bits which is stored in BigEndian format to integer. This is performed with the help of bit operation i.e left shifting and operating or.
    static int32_t bigEndianIntRead(char *fileBuf, int startIndex)
    {
        return (((fileBuf[startIndex + 0] & 0xff) << 24) | ((fileBuf[ + 1] & 0xff) << 16)| ((fileBuf[startIndex + 2] & 0xff) << 8) | ((fileBuf[startIndex + 3] & 0xff)));
    }
    //Convert 32 bits which is stored in BigEndian format to integer. This is performed with the help of bit operation i.e left shifting and operating or.
    static int32_t littleEndianIntRead(char *fileBuf, int startIndex)
    {
        return (((fileBuf[startIndex + 3] & 0xff) << 24) | ((fileBuf[startIndex + 2] & 0xff) << 16) | ((fileBuf[startIndex + 1] & 0xff) << 8) | ((fileBuf[startIndex + 0] & 0xff)));
    }
    //Convert 64 bits or 8 Byte which is stored in BigEndian format to integer. This is performed with the help of bit operation i.e left shifting and operating or.
    static double littleEndianDoubleRead(char *fileBuf,int startIndex)
    {
        double convert;
        char *add;
        int j;
        add = new char();
        j=-1;
        for(int i=startIndex; i<startIndex+8; i++)
        {
            j++;
            add[j] = fileBuf[i];
        }
        convert = *reinterpret_cast<double * const>(add);
        return convert;
    }
};

//Class HeaderShapefile have all funtion implemented to desribe every field of shapefile header file.
class HeaderShapefile
{
    public:

    //This funtion of the class will calculate the bounding box coordinates of the shapefile.
    //Following values i.e x and y minimum and maximum values also with z and m minimum
    // and maximum values are obtained.


    static double dimensionXMin(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf,startIndex);
    }

    static double dimensionYmin(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionXmax(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }

    static double dimensionYmax(char*fileBuf, int startIndex)
    {
        return ByteConverter::littleEndianDoubleRead(fileBuf, startIndex);
    }
};

class SizeOfFile
{
    public:
        //This function finds the size of file in Byte
    static long sizeOfFiles(FILE *file)
    {
            long l, e;
            l = ftell(file);
            fseek(file, 0, 2);
            e = ftell(file);
            fseek(file, l, 0);
            return e;
    }
};

int main()
{
    int32_t filecodes, fileLengths, shapeTypes, versions;
    double xmin, ymin, xmax, ymax, mmin, mmax, zmin, zmax;
    string shape;
    char *filePath = "map.shp";
	char*fileBuf;			// Pointer to our buffered data
	FILE *file = NULL;		// File pointer
	// Open the file in binary mode using the "rb" format string
	// This also checks if the file exists and/or can be opened for reading correctly
	if ((file = fopen(filePath, "rb")) == NULL)
		cout << "Could not open specified file" << endl;
	else
		cout << "File opened successfully" << endl;

	// Get the size of the file in bytes
	long fileSize = SizeOfFile::sizeOfFiles(file);

	// Allocate space in the buffer for the whole file
	fileBuf = new char[fileSize];

	// Read the file in to the buffer
	fread(fileBuf, fileSize, 1, file);

	// Now that we have the entire file buffered, we can take a look at some binary infomation

	cout<<"File size = " <<fileSize;

    xmin = HeaderShapefile::dimensionXMin(fileBuf,36);
    ymin = HeaderShapefile::dimensionYmin(fileBuf,44);
    xmax = HeaderShapefile::dimensionXmax(fileBuf,52);
    ymax = HeaderShapefile::dimensionYmax(fileBuf,60);

    /*****************MINIMUM BOUNDING BOX OF SHAPEFILE DETAIL*********************/

    cout<<endl<<"\n/*****************MINIMUM BOUNDING BOX SHAPEFILE DETAIL*********************/\n\n";

    cout<<"X minimum = "<<xmin<<endl;
    cout<<"Y minimum = "<<ymin<<endl;
    cout<<"X maximum = "<<xmax<<endl;
    cout<<"Y maximum = "<<ymax<<endl;

	cin.get();
	delete[]fileBuf;
        fclose(file);   // Almost forgot this
	return 0;
}

Output of Get minimum Bounding box of shapefile c++ program

Get minimum Bounding box of shapefile c++ program
Get minimum Bounding box of shapefile c++ program

What is GIS | Geographic Information System

What is GIS | Geographic Information System? GIS is an Abbreviation of Geographical Information System or Geo-spatial Information Systems or Geologic Information Systems (also Geo-spatial database management). As the name suggest ‘GIS’ is related to geographical information. But before explaining what is GIS?, we should know about what Geographic information means? Geographic information is knowledge of where something is. It defines the spatial reference of the element or matter present on earth surface.

As it is said “a picture is worth a thousand words”, Maps plays a lead role in defining geographical information. We control map to guide someone to know the actual  route, exact destination, its distance, its elevation, its surroundings etc. Geographical information is needed to Government, Industries, Business markets, Tourism and services sector,  Education, Agriculture, Health, Disaster Management,  Transportation and also to a common people. It makes us easy to locate an area of industries, day care center, restaurant, mall, head quarter or any other specific place.  It solves everyday issues. What is the shortest route to get to work? How can i get to hotel? Where is the location of my new office? So, Geographical information is part of our lives. But how can we get geographic information and What is GIS?

Geographic Information System
Geographic Information System

What is GIS | Geographic Information System?

GIS is a tool to acquire geographic data and produce Geographic information. Generally Information about those features are stored in tabular formGIS can be defined as a “computer information system that can input, store, manipulate, analyze, and display geographically referenced (spatial) data to support decision making processes”.
GIS enables us to connect dynamic relations between spatial data (geo referenced) & relational data (attribute of features in tabular forms). It enable us to make models of reality, of the ground and to answer question such as what is where? Main component of Geographic information system are: Hardware, Software, Data and People.

You may also be interested in knowing GIS Uses and Application in different industries.

Geographic Information System
Geographic Information System
Some organizations defined GIS – Geographical Information System as :

A geographic information system (GIS) is a computer-based tool for mapping and analyzing things that exist and events that happen on earth. GIS technology integrates common database operations such as query and statistical analysis with the unique visualization and geographic analysis benefits offered by maps.” ~ ESRI

“GIS is an integrated system of computer hardware, software, and trained personnel linking topographic, demographic, utility, facility, image and other resource data that is geographically referenced.” ~ NASA 

Google Map can be considered as an Example of GIS tool. You can have a look over 35+ Google Tips and tricks.

The demand for GIS tools is continuously growing. One of such tool is QGIS(Quantum GIS), and is a cross platform, free open source desktop application. From a citizen to an organization, every body needs Geographic information. You can find here advantage of GIS and Why GIS. I hope that reading this post will make you to learn more about Geographic information System. I would appreciate your comment, if you like to share more ideas related to the same topic.

Convert Shapefile to kml by QGIS

Convert Shapefile to kml by QGIS. Shapefile is ESRI based Vector file, While KML or Keyhole Markup Language is file which models and stores geographic features for display in Google Earth or Google maps. Many times you may require to convert the required shapefile to KML file, so that you can deploy the same over Google Earth for some reason. QGIS (Quantum GIS) is an open source GIS (Geographic Information System) tool, which let you upload the Shapefile and convert the same to KML file. Similarly ogr2ogr is also an open source tool, which let you to convert between GIS data formats. Look over shp to kml convert using ogr2ogr tool which can be marked as an alternative to this article. You can also see to convert Kml to Shapefile and also Shapefile to GeoJSON in QGIS.

You can also try Online conversion instead of QGIS MAPOG Online converter tool

You can also go through other tutorial in QGIS.

Free SHP to KML conversion using GIS Converter Tool in one click.

Here are the steps to convert shapefile to kml:

Convert Shapefile to kml in QGIS

Convert Shapefile to kml by QGIS
Convert Shapefile to kml by QGIS

Convert Shapefile to kml in QGIS:

1.) Open up the installed QGIS.
2.) In the menu bar, select Layer and press Add Vector Layer. Now select the source type in the pop up window opened as File and browse the source Shapefile(Note:Your shapefile .shp, .dbf and .shx file should be in same folder). Press open.

Convert Shapefile to kml by QGIS
Convert Shapefile to kml by QGIS

Select the coordinate reference type system if coordinate reference window appears and press ok.

3.) Right click on the name of Shapefile layer Appearing in the Left upper side and select save as:
or
You can select layer from the menu, and click on save as. (Image below provide demonstrate both the options with the indicator displayed)

Convert Shapefile to kml by QGIS
Convert Shapefile to kml by QGIS

4.) In the Save vector layer as window, Select the format from the drop down box as Keyhole Markup Language(KML) and browse the folder in which you want to save the KML file . Name it and Press OK.

Convert Shapefile to kml by QGIS
Convert Shapefile to kml by QGIS

Your KML file will be Exported in the directed folder. You can Verify the generated KML file for its validity by uploading the generated KML file to QGIS or uploading KML file in Google map. You may soon find the tool and the coding for the same on this site.

You may check in converting Geojson to Topojson and Shapefile to TopoJSON file. Hope this may help you in converting Shapefile to KML file easily. If you still find problem in converting the file, do let me know by commenting below.

Introduction of QGIS 3.2.1

Convert KML to Shapefile in QGIS

Convert KML to Shapefile in QGIS. KML or Keyhole markup language file which store and models geographic features for displaying in Google earth or Google maps, which is not common in use for Map makers and GIS programmers. ESRI made a standard Vector file i.e Shapefile which is most commonly adopted in the field of GIS (Geographic Information System), and this made me to convert KML to shapefile, created for learning purpose from Google map. QGIS (Qunatum GIS) is an open source GIS tool, which provide you a function to convert the KML file to Shapefile, and Vice versa i.e Shapefile to kml file.

You might be looking for converting KML to shapefile when you get the data from third party or from website which download free GIS map data but in different formats which can also be converted to.

If you still don’t prefer using QGIS or GDAL utility to convert the file from kml to shp, then you should also look for KML to Shapefile Conversion using Online Tool.

Convert KML to Shapefile in QGIS
Convert KML to Shapefile in QGIS

You might be interested in seeing QGIS tutorials.

Instead of QGIS you can also try Online Converter tool here MAPOG Online converter tool

Convert KML to Shapefile in QGIS:

1.) Open up the installed QGIS.
2.) Select Layer in the menu bar and press Add Vector Layer or select the shortcut icon. Browse the KML file, in the Source DataSet type, in the pop up window opened.(While browsing, select either all files or Key Hole Markup language in file type). And press Open.

Convert KML to Shapefile in QGIS
Convert KML to Shapefile in QGIS

Select the coordinate reference type system if coordinate reference window pop ups and press ok.

3.) In the Layer file appearing in the left upper side, right click on it, and select save as:

or

you can either select layer from the menu and click on save as.

Convert KML to Shapefile in QGIS`
Convert KML to Shapefile in QGIS

4.) In the Save vector layer as window, Select the format from the drop down box as ESRI Shapefile(OGR) and browse the folder in which you want to save the shapefile. Name it and Press OK.

Convert KML to Shapefile in QGIS
Convert KML to Shapefile in QGIS

Try our tool for conversion: MAPOG Online converter tool

Your Shapefile i.e .shp, .shx and .dbf file will be created in the directed folder. Upload your KML file in your map browser tool, or try our tool, to verify whether the tool preserves all attributes and elements or not. You may also see how to merge two shapefile in QGIS. Or if you are looking to convert that shapefile to kml to Topojson then you can look for GeoJSON to Topojson and Shapefile to GeoJSON and shapefile to TopoJSON. Do comment below if you are getting any problem in converting the file.

QGIS 3.2.1 for Beginners 

How to remove gaps from a polygon layer file in ArcGIS?

How to remove gaps from a polygon layer file in ArcGIS? While preparing polygon layer file following various stages of layer preparation like

This is what making it suitable to be used by a web application as an input. While layer file should be accurate with minimum error before deploying or issuing the same to the client, which requires lots of time to make.  Obviously no client for project submission will tolerate the delay and so this task time is to be reduced. So this blog post will deal with, how reduce time duration of preparing a layer file?

If you are new to ArcGIS, I recommend you to Look for  FAQ  and Interview of ArcGIS Tutorial.

Remove gaps from a polygon layer file in ArcGIS:

This is quite possible by using ArcGIS inbuilt tools and this can be accomplished by understanding the need and using appropriate tool. A number of errors are generated at various stages of layer preparation like gap in a feature, overlap with other feature, self over and many more. These errors can be detected by selection tool or by running topology rules for every layer. But the question is removal of these errors. If there are just a hundred of polygons in layer one can remove it manually zooming on to every gap and overlap. But if there are a million or more number of polygons in a layer for example if a village has 1000 parcel on an average in a district of 600 villages, the total number of parcel in a district comes out to be 6 lakh. It takes almost equal time in preparing an error free file as much time used for preparing the layer file.

For this one task i.e. removal of gaps in a feature can be made easy and can be performed in less time by the use of a tool named Eliminate present in the Data Management toolset of ArcGIS.

Steps to remove gaps from a polygon layer file in ArcGIS

remove gaps from a polygon layer file in ArcGIS
Detection of Gaps in the polygon File

 

1.) First all gaps in a layer file should be converted to polygons using auto complete polygon tool from the editor bar.

remove gaps from a polygon layer file in ArcGIS: Forming polygons from gaps using Auto-complete tool
Forming polygons from gaps using Auto-complete tool

2.) Then these polygons should be copied to layer file.

remove gaps from a polygon layer file in ArcGIS: Copying gap polygon to main file.
Copying gap polygon to main file.

3.) Selecting all gaps in the form of polygon apply eliminate tool from data management toolset on the layer file.

remove gaps from a polygon layer file in ArcGIS: Applying Eliminate tool on the polygon file to remove gaps.
Applying Eliminate tool on the polygon file to remove gaps.

4.) The gaps are merged with the neighboring polygon having larger area or longer shared border.

In this way the work of one month can be reduced to one week or lesser. This tool should be used for removal of small gaps only. As for larger gaps the decision of merging the gap polygon in which neighboring polygon should be done by visual interpretation and analytically perspective.

If you are dealing with Raster files with ArcGIS and with multispectral band files, you may look for Pan-sharpening image using ArcGIS.

Hope this tutorial would help you to remove gaps from a layer file in ArcGIS.  While I always works in Open Source tool in GIS, I would like to make you check the QGIS and QGIS tutorials.

If you are facing any problem related to the above, then do comment below, we would look for the problem and suggestion for the same.