Introduction to Mapping & QGIS¶
Friday, December 9, 2016, 10am - 3pm
What is Mapping?
Our Views on Maps:¶
Mapping can be defined in so many different ways, there is no easy answer to these questions. In fact, your campaigns can determine how you design and develop parameters for your map. Below are a few examples of just how multifaceted mapping can be for any community, and how the digital can help scope and develop innovative approaches to research and resistance. How then might your project utilize these tools?
Your views on maps¶
Question: “What is a map? What is in a map? How do you map?” Is this a map?¶
While mapping is increasingly being used for entertainment, there are strong implications for mapping as a resistance tool too.
Question: “What does this map show? And what does it avoid?”¶
Source:Dakota Access Pipeline Route Map by Energy Transfer Partners
Question: “What does this map show? Is it different from the previous map?”¶
Source: Carl Sackhttp://www.huffingtonpost.com/entry/a-nodapl-map_us_581a0623e4b014443087af35
Distortions¶
“Everything is related to everything else, but near things are more related than distant things.” -Waldo Tobler Waldo Tobler’s statement defines the first law of geography, in stating a connection between objects. This lays the foundation behind spatial relationships.
Source: Jacques Goldstyn, 1983.
Maps are a 3D projection onto a 2D surface, so what results is a SADD distortion based on the following:
- Shape - The way something looks in relation to another
- Area - The total content of something in relation to another
- Distance - How far something is in relation to another
- Direction - Where something is in relation to another
Exercise: Think of some examples for each distortion.¶
To preserve one of these elements with highest accuracy, all other elements are to be sacrificed to some degree.
https://en.wikipedia.org/wiki/Mercator_projection#/media/File:Mercator_projection_SW.jpg
Impact of map projections. Source: https://www.flickr.com/photos/internetarchivebookimages/14762351614/
Question: Check outhttp://thetruesize.com/and try to see what is the implication of representing places as smaller than reality?¶
Introduction to QGIS¶
What is GIS?
Simply put, Geographic Information Systems (GIS) is digital mapping. In GIS data is layered upon one another like slices on a pizza or layers of a pie.
Download QGIS if you do not have it installed: http://www.qgis.org/en/site/forusers/download.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python Download (get 3.6.9 for the QGIS extended release)
https://www.python.org/downloads/
https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.6.pkg(mac)
https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe(win)
LA Times Data Sets
http://boundaries.latimes.com/1.0/boundary-set/la-county-neighborhoods-v5/?format=shp
http://sandbox.idre.ucla.edu/mapshare/data/usa/census/Los_Angeles_ZipCodes.zip
Boundaries from the Los Angeles Times:http://boundaries.latimes.com/sets/
Datasets hosted by UCLA:http://gis.ucla.edu/geodata/
Data from Los Angeles County:http://egis3.lacounty.gov/dataportal/
Most GIS files (also called shapefiles) will be in a zipped format, so be sure to unzip them!
Mac Example:https://asmand.files.wordpress.com/2015/09/unzip-mac.gif
PC Example:https://www.youtube.com/watch?v=ZQOYqzGHiDY
How to add vector data¶
Working with layers:¶
- It appears on top of the La county neighborhood (v5) layer which masks it from view.
- Let’s click on “Open Attribute Table”:
- Both in the table and map, the yellow rows are what is less than 10 square miles:
Working with styles¶
- Click “Ok” to apply your changes.
- Your map should now be different.
Visualizing Categories (not numbers)¶
Visualizing numbers (not categories)¶
- Re-add the Los_Angeles_ZipCode layer.
- Go to layer properties of the Los_Angeles_ZipCode layer and then “Style”.
- As you can tell, this type of data visualization can be useful when working with population, number of arrests, etc.
- When you are done selecting and noticing how the numbers change, feel free to hit “Ok”
- You map should look like the following:
Taking data out of QGIS¶
Sometimes you want to take data out of QGIS to manipulate it in other software, such as Excel. You can do so, by opening the layer properties and clicking save as:
You can now choose a file type and name, make sure to select “CSV”:
Data Management with Excel¶
Lets go ahead and open another CSV file, you are welcome to open the neighborhoods.csv file too though.
How to open CSV files
- Go to File -> Open
Before going forward, lets make sure our data columns are in good order:
ARST_DATE should be a date field, and ARST_TM should be a Time Field.
- Select the columns:
2. Select dropdown box near the top:
- Then choose “Short Date”:
- For ARST_TM choose “Time”:
5.Do the same for BKG_DT and BKG_TM as well.
Formulas¶
Excel is a spreadsheet program, which means it is made up of rows and columns: one giant table. One of the most powerful tools is formulas, which means starting a cell with an “=”
Go ahead and find an empty cell so we can start our formula:
S2 looks like a good spot.
The most basic formula we will use is to combine columns together:
=A1 & B1
Every Excel formula relies on using the cells of a table in order to work. For example A1 is the very first cell in the spreadsheet. If you want to combine the contents in the first cell together with the second column, then you can use “=A1&B1”
Question: Whats the formula to combine the Lat(Q2) and Long(R2) columns into one?
=A1&“ “&B1
You will notice that the “ “symbols acts as a seperator. You can go ahead and put anything in between those symbols and it will appear in between the result.
Question: Whats the formula to combine the Lat(Q2) and Long(R2) columns into one with a comma in between?
Sorting¶
In the top part of the menu you can select “Sort”:
A dropdown arrow will now be shown next to the first row (also known as the header)
When clicking it, you can choose to sort the information in different ways:
We will sort the data from highest to lowest arrest date:
Feel free to explore sorting the data!
Filtering¶
You can also filter the data by using the Checkboxes or the Filter By box below the Sort options:
Different data types will have different filter options, feel free to try it out and answer this question:
Question: How many arrests were there on January 1st?¶
Back to QGIS for a moment!¶
Sometimes you want to summarize data up, for example you want to see the number of arrests by zipcodes or neighborhoods. To do this, you need to do what is called a spatial join.
Add a CSV file in QGIS¶
After finding the file, a new dialogue box will show up. Be sure to have Lat and Long selected for the X and Y values [X is always Longitude and Y is always Latitude]:
Spatial Joining Data¶
1. Make sure you have the two layers you want to join together, in this case the LAPD_arrests_2015_january.csv and the Los_Angeles_ZipCodes.
- The target layer should be the layer you want the data to go
towards, the join layer is the layer you are taking the information from. So in this case, the Target is the Los Angeles ZipCodes, while the Join is the LAPD_arrests_2015_january.
- Make sure to choose “Intersects” for the Gemetric Predicate.
- Be sure to select “Take a summary of Intersecting Features” and you
only need “sum” and “mean” for the Statistics field.
- Click “Run” to run the join.
- Go ahead and open the attribute table and see if the “sum” worked!
- Try and visualize the data like so:
Exporting a map¶
QGIS has a tool called “Print Composer” to take care of all your map printing needs. You can find it by going to “File” then “New Print Composer”
After opening a new print composer, you should add a map, which can by done by going to “Layout” then “Add new map”:
You can also add text, shapes and other content.
When you are done using QGIS, you can save your project as a QGIS file:
Extra Topics!¶
Georeferencing¶
http://www.findlatitudeandlongitude.com/batch-geocode/(down)