3.25.2010

Creating GIS data: Importing from text files and other sources

Oftentimes we have some data begging to be included in our GIS but the file format just couldn't fit in. For example we have found the data over the internet and it is not in .dbf  or .gdb format. But as long as it has a coordinate system data (i.e. latitude, longitude) there is still a way to include that in our GIS project.

My latest GIS project is on including a delimited text layer in QGIS. QGIS supports the import of points only , while GRASS can accommodate all feature types in the GRASS vector model.

My GIS Project
What I have done is to map the location of all GPS campaign stations that our team has established since 1995. I have extracted the geographic location (latitude and longitude) information from the final coordinates file (FN*.crd) produced by Bernese 5.0 after post-processing the GPS data we have gathered on field. I have actually converted it from FILE format to .txt then imported the data in my GIS project.

The Steps
Firstly, I looked for a shapefile that covers the extent of the project. In my case, it's the entire Philippines. I have found a good site that offers free GIS data (shapefiles,.gdb, .kml etc.) and is documented in my past blog.  After loading the Philippine Administrative Boundaries layers in QGIS, my next step is to import the GPS stations data.

I have edited my GPSstations.txt file such that it will have a delimiter. I have used "|" as my delimiter. The header should include the labels for each  field:  Station |Longitude|Latitude (you can of course add some other fields if you wish to.)

In QGIS, just enable the "Add delimited text layer" in the Plugins menu.

Add your *.txt file then specify the Layer name. You should also state the delimiter. The default is \t.Specify if it is a regular expression or plain characters. In my case, "|" is a plain character. The X and Y fields are longitude and latitude respectively. Then press OK to load the layer.

In case you might want to use the delimited text layer for another project, you may opt to save the it as a shapefile by right clicking the layer in the legend choosing the "save as Shape File " option.


If you have for example some broken data where some fields or columns doesn't have any information in it, you may manually edit the blank field and include a "0" as its value. However if you know some programming, you may choose to run a script that does exactly the same task. You just have to do some tweaks on the code to enable it to fit in your delimited text layer's need. Here's a Ruby script that I have dug.


If there's no problem with the text layer that you have specified, QGIS will load it and will display a screen such as my final output below.  You may opt to save the result as an image through File< choose destination folder and type of image (*.png or *.jpg).

GPS CAMPAIGN STATIONS IN THE PHILIPPINES
The campaign stations are part of the "Active Fault Deformation Project along the Philippine Fault " hence our  GPS network is concentrated along the Philippine Fault Zone.

1 comment: