top of page
Search
Writer's pictureTamara

QGIS: Where Should We Begin?

Blog #5 – QGIS: Where Should We Begin?


Today I continue my journey learning QGIS, an adventure I began last year in an effort to diversify my skills. I didn’t really follow through until now, I hit a couple of walls and I defaulted back to ArcGIS after one tutorial, and a couple of attempts to use QGIS for my work. The major issue I was having was that every once in a while when I would run a tool, I would get an error window pop up that had a lot of script in Python language, and it would cause me a bit of stress and confusion, and I would go back to Arc to try running it instead. Python is the major scripting language used to run both ArcGIS and QGIS, and I’ve dabbled in learning the syntax of it but never mastered it. I believe I could probably learn the basics fairly quickly by dedicating a week or so to it. But as it stands now, I’m not completely familiar or comfortable working with the language, mostly because I’ve become comfortable with other scripting languages instead.


My decision to pick up QGIS again began when thinking about the trajectory of my career. Knowing that there is a big chance that I will no longer have access to ArcGIS next year, and that I won’t be able to use it for commercial purposes as per the license agreement, I figured now is the time. In addition, I was catching up with a university friend from my Geology classes, and he encouraged me to pursue it so I could have more creative as well as commercial freedom. He told me that ArcGIS and QGIS run on different versions of Python, and that might have been the cause of the error windows that were popping up for me before. That is what I’m going to look into today: making sure that I have the right version of Python installed. After that, I’m going to try to recreate the first map made for the blog, the one at the top of the homepage.


The first step is Google, I need to figure out what version of Python my QGIS is running and I found this, which gave me some code I could plug into the Python console window in QGIS and see what version it’s running. The Python console is where Python language can by typed in to run any code or script you want, and you can find it in the Plugins dropdown menu in the QGIS window.


I ran the code and found that, in fact, QGIS is running the right version of Python: 3.7.0 as of this post. Which means that Python must have been installed properly when I downloaded QGIS, thank goodness. If this kind of problem persists, however, then I may look into the methods described here to ensure that the two versions of Python are not interfering with each other.


This is the part of computer related sciences that gives me a bit of headache and makes me wish that I took a computer science course at some point. For now, though, I’m reminding myself that it’s okay to ask for help from the people around me, of whom, there are a number who regularly work in QGIS and even R to make maps. Also, there are countless forums online where questions of all sorts are answered regularly, like the ones I went to at the beginning of this post.


I’ve got QGIS open on my computer now (which you can download here), and there’s nowhere to go but forward now, let’s make a map. Step by step, let’s follow the methods used in the first blog post:

As before, we have the populated places shapefile with all of the cities from Natural Earth, and I need to narrow it down to the Admin-0 capitals. This time, I’m not sure where the ‘Select by

Attributes’ button is… If we open the attribute table, there is an option to select features based on an expression (see figure), and if we write "featurecla" = 'Admin-0 capital', it will select all 202 cities that we had looked at before, and we can export them to a new shapefile in an almost identical way as we have in ArcGIS.


Alternatively, there is a Select by Attribute tool in the Vector Selection toolbox where we can use the user interface to do the exact same thing without typing any code.

Export the data with right click: Export: Save Selected Features As, and proceed as usual. Now we’ve got the 202 capital cities once again.

Not too bad so far! The hardest part of this process so far has been lack of familiarity, but I’m sure that will change over time with a bit of patience. Thank goodness for mouse-over information, amiright?


This next part might be a bit harder: setting the symbology to scale up with both size and colour.

I started by setting the colour in the symbology tab after going to the layer properties, same as before. I selected graduated symbology, chose pop_max as my symbology attribute, set the min and max values for each category (which was easier to do in QGIS I might add) and chose a colour ramp the same way as before. After clicking around for a bit, I discovered something amazing: a pick colour option, in which you can click somewhere on your screen and choose the colour that you click on to represent your symbology. My mind was blown, this is the best feature ever! I was able to go back to the previous map I made and click on all the same colours so I could match the map exactly. AMAZING, so happy.


Now comes the trouble of changing the size of each point, which was a whole other can of worms. I couldn’t see a multiple symbology option and I was beginning to think this might be a

bit of a struggle, but my Googling led me to a similar question, and it didn’t quite have the answer I was looking for, but it led me to the “Rule-based” symbology option. In here, I have significantly more control over the symbology, and there are a number of filters and rules I can set to do almost anything to it. By double clicking on each “rule” or row, I was able to explicitly set the size for each category.


That was way easier than I expected, and now when I put the legend into the final map, I won’t have to fudge around to make both symbologies appear in the legend. Setting the labels was easy enough, possibly even easier than before… So now, let’s make the map!

Finalizing the map is a little different in QGIS, I actually had to pull up the old tutorial PDF from over a year ago to remember how to do it. You have to open a separate window called a Print

Layout or a Print Composer where you can edit features of the map and save it. On the left, there are buttons that add a map (i.e. add the map open in QGIS), add legend, add scale bar, title, and all the things you need for a pretty map. I put everything on the map, and everything was going great, then I hit a wall when I added the scale bar. It was completely the wrong size, which I looked up, and it has something to do with the coordinate system or projection maybe, but nothing I tried was fixing the problem. I’m sure Australia is way wider than 20 km…



My attitude quickly changed from having fun, to being 100% a grump when I tried fixing the scale bar. I finagled for a good while, asked a friend for help, realized that my projection was way off and the cities weren’t even located properly on the map! I changed the projection, and it seemed to correct the scale bar, but something was still off. We found the source of the problem when she sent me a screenshot of her QGIS settings (find in Project: Properties) and I realized that my Ellipsoid setting was set to a WGS 84 coordinate system, effectively causing some wacky things to happen to any measurements being made on the map. I set it to None/Planimetric as it should be, and it worked!

You’ll notice a few differences between this map and the original map, notably the water is now blue instead of grey, and the north arrow is different (there are fewer default choices). Also, it looks like the location labels on the basemap (i.e. the layer with the continent boundaries) are included in the map, which I’m not sure how to change. The projection is also different, but I kind of like this layout. Next time, I’ll be more careful with the coordinate system I use, and double check my QGIS settings before making a map.


We did it! We managed to export a new layer and set the symbologies from the original dataset we used in the first blog post and recreated the map! It looks like I am going to be alright while working in the QGIS window, but I need quite a bit more practice in the Layout view. Let’s hope this gets easier with time and practice…

16 views0 comments

Recent Posts

See All

Comentários


bottom of page