Starting with QGIS

Here are some quick start tips to getting started with qgis.

 

Projections

The first layer added determines the project projection. Qgis can convert projections automatically as you add layers but you have to tick `on the fly` under options. For occasional use this works ok, but for various reasons its ultimately better   to convert all your layers individually to the project projection. Keep copys of the original layer some place and make the new copy by first ensuring the layer has a srs specified under layer propertys, then doing a layer, save as, and specify the new srs. Dont be tempted by some useful sounding functions under vector tools, layer save as is all you need.

 

I find its useful to adopt a system wide local projection, and add any variants to the file name, so my nztm roads layer is roads.shp and a wgs84 version of the same data is called roads-wgs84.shp

Take care over decimal places, when transforming from one projection to another you end up with lots of dps. When in doubt leave them be. For final file production you can snap or gridify the vertices to a sensible number of decimal places. But that data is never as accurate as it was.

 

Storing data

Now is a good time to create a solid folder layout for the vast plethora of data files that qgis will make. Qgis doesnt of bundle up your layer shapefiles inside its mapfiles, just references your shape files, so you cant go moving them around. The mapfile and its layer shapefiles all   work as a package. Considering that each shapefile is already a number of files, and that all geoprocessing functions with few exceptions produce their results in additional new shapefiles, things can rapidly get seriously out of hand with badly named files all over your hard drive.

 

So create a strong folder hierarchy, early on, something like:

gis-stuff

      maps

             work

             home

      orig-data

             provider x

             provider y

      working-data

            roads

            water

            placenames

 

This allows you to keep a read only copy of the orig source layers unharmed by you. Before you edit any original layer, make a copy in the appropriate working folder, and then add it to the map and go ahead and edit it, never edit (or ideally even open) the original in qgis.

 

Importing data

Getting data in is an immediate need. In the vector world this will most often come in two forms. In spreadsheet/csv like form, or shapefiles and their ilk. The latter are easy, qgis understands a bewildering array of formats mapinfo tab, esri shapefile etc.

 

For the csvs, theres the delimited text plugin. Just bear in mind that this plugin can be a bit picky. Make sure that your file is NOT a csv, csv can confuse the importer with its use of delimiters in the fields, redundant columns, variable line endings etc. Put all foreign data sources though a good text editor, use a delimiter than you are 100% sure isnt in your data, and that each row has the same number of columns. The file MUST have a header row, with the names of the columns. Use x or y or lat or long for the coord columns, and qgis will pick that up right off. Anything that isnt one of the two coord columns will end up an attribute column. I repeat when the importer fails it will either give a cryptic error or worse appear to complete but silently   dropping off chunks of your data, so cast a critical eye over the results to make sure all records are present and accounted for.

 

After that be sure to specify an srs under layer propertys because material from the text importer has no idea what projection it is. Then use layer save as to create a proper shape file, so you arent tied to the original text file for all time.

 

There`s a third source of data that is worth throwing in here and thats traced data.   The quality of some of the major webmap providers satellite imagery is too good to turn down at times, and there is an easy way to get this into qgis as a temporary background layer in which to trace (aka digitise) in the form of the openlayers plugin. Of course theres other ways to do it, like screen printing, then using the georeferencer to add it as a raster layer. But even thats sort of unnecessary with the google layers plugin. Some map providers allow this use of their data others dont, so read the fine print. With any webmap sourced layer remember to first off set your project srs to spherical mercator.

 

Lastly for raster imports, if you have a scanned map, or aerial photo or some such you can use the georeferencer to   `georeference` it. Be aware theres a couple of gotchas with this tool. First the tool is quite sophisticated, and in some ways oversteps its mandate. Youd expect something that georeferences to calculate and specify the coords of the four corners of the map and not much else. However this tool will happily distort (or warp as its called) the raster to make it fit the current project srs. In some cases where you have no idea of the srs of the raster this is helpful. However if you know the srs, you are better not messing with the raster in the often arbitrary ways that georeferencer does if you set the method to anything but linear. If you know the srs of the map, first georeference the four corners using linear mode, then use raster, warp to do the warping properly according to known srs conversion methods rather than brute force used with georeferencers polynomial etc.

 

Workflow

Each layer is a shapefile. Only one feature type is allowed on each layer, eg point, polyline, polygon, or raster. Each layer has two sets of data, attributes and geometry. The geometry is what you see on the map. It has almost nothing to do with the attributes, the latter are accessed by doing layer, open attribute table, and stored in the separate dbf of the shapefile triplet. When toggle editing is on, you may edit both sets of data. Note that while the attributes table looks like a spreadsheet it isnt one, you may edit an individual cell, but thats the extent of it. You can reorder the columns   (temporarily) or select features (and find them on the map by clicking the show me button), but theres no fill down tool or forulas or such, if you want to bulk change attributes use the field calculator.

 

Remember that qgis is very much a work in progress, and it`s regular crashes are just something you have to learn to live with, rather much like word5 in the 90s. Save your layers regularly, remembering that there are two levels of save. File save saves the map/layers configuration,   while the save button next to the `toggle layer edit` button saves the actual layer shapefile. (In qgis layers open in read mode, you have to turn on and off editing for each layer, this protects your data). So turn on editing, make any attribute changes or feature position changes, hit layer save every 5 minutes, then toggle back to read mode when done   editing. Its a rhythm youll rapidly learn after losing the first hours work to a crash.

 

Geoprocessing

Most intrepid qgis learners are eager to manipulate their data and add value to it. This is called geoprocessing. qgis has a farily industry standard set of tools under vector, geoprocessing, geometry and data mannagement. Get to know these tools and their strengths and weaknesses. Most of them leave you guessing much of the time as to what its actually going to do. Which is the source and which the target?   Which attributes willl it keep, what about conflicting attributes. Questions often only solved by trial and error. I use a method of saving test runs with gibberish output filenames like asdfsd.shp, which are easy to clean up later. The ones i found i resorted to most are these:

 

  • research tools, select by location: selects features that are within features on another layer
  • geoprocessing, buffers : creates a larger polygon around shapes
  • geoprocessing, dissolve: blends features together.
  • geometry, centroids: makes a point for polygon   `centers`
  • geometry, multipart to single and reverse: these will split or merge layers as needed
  • data mgmt, join, and join by location: adds attributes from another source, either csv, or another shape layer, eg which admin district is this point. useful.
  • some quite good stuff in mmqgis plugin
  • table manager plugin, essential for tidying up attribute layout.
  • use layer, query to show partial layers, also save partial layers as new layers

 

Again critically examine the output from these tools to make sure there are no surprises. Eventually you may find these tools limiting and find yourself drawn into a vortex of having to learn to use postgis or spatial lite   layers.

 

Export

Print composer is a nice bit of kit, and from there you can export maps in many formats. Its one shortfall is failing to produce a world file for its raster renders. file, save as image makes a world file, but doesnt let you specify extent of scale, its just whats on the screen at the time.

 

A FAQ is how to get map data out of qgis into a form suitable for web mapping. Unfortunately theres no easy answer, heres the choices as i understand them:

 

1.   qgis has a command line tool to produce single zoom level renders complete with worldfiles.   qgis --snapshot general.png --width 13000 --height 13000   --extent 1100000,4750000,2080000,6100000 --project e:/gisdata/maps/project/roads.qgs I found this is about as big as it will go, pixel wise. You can then use maptiler or gdal2tiles to created tile pyramids.

 

2. Publish to web plugin. This makes a potable set of code that can be uplaoded to an ordinary webserver which will render a qgis map in vector format. This is pretty quick and easy but the limitation here is that it is therefore only good for siimpler shape data. Highly verticed shapes will grind most peoples browsers to a halt.

 

3. qgis mapserver. This is a sister project that resembles a cut down version of the full blown mapserver software. Its big upside is that the symbology and styling rules   are shared with qgis, so its going to give a pretty fair what you see is what you get. Its not actively maintained that i can see and like most mapservers not always easy to install.

 

4. mapserver/geoserver/mapnik etc. At the end of the day if you are serious about web mapping this is where you will end up. These packages are quite complex stacks of software, that in essence create tiles of your map at different zoom levers and deliver them on demand via a webserver. This is known in the industry as a WMS, and the term comes with a whole body of standards. Map-server is a bit of a misnomer in some ways because all a wms does is render maps, which are actually served by other tools, usually apache. One thing that apache isnt good at is delivering lots and lots of small files, so work arounds are used like fastcgi modules and tile caching to prevent rerendering the same tile repeatedly. Be prepared to invest some serious time learning to use wmss, but this is where its at, in combination with client software like openlayers, you can make your own google maps.

 

If you go mapnik try the quantamnik ggis plugin. For mapserver qgis has a native mapserver ruleset export. Not sure about geoserver. In all cases expect to have to learn each of their unique styling rulesets. Geoserver does however have a gui, but its java.

 

Thats about it, im not going to describe symbolising and labelling and such things, as thats all pretty self explanatory.

Admin login