{"id":1058,"date":"2025-03-16T14:24:22","date_gmt":"2025-03-16T14:24:22","guid":{"rendered":"https:\/\/commons.mtholyoke.edu\/emarcano\/?page_id=1058"},"modified":"2026-04-01T17:45:27","modified_gmt":"2026-04-01T17:45:27","slug":"geog-210-geocoding-qgis","status":"publish","type":"page","link":"https:\/\/commons.mtholyoke.edu\/emarcano\/gismhc\/geog210\/geog-210-geocoding-qgis\/","title":{"rendered":"Geog 210 \u2013 Exercise 10b &#8211; Geocoding with QGIS"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#top\">Return to top<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/commons.mtholyoke.edu\/emarcano\/geog210\/\">Return to Geog 210 page<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"part2\">Part 2: Geocoding (with QGIS)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In exercise 6, you used a point layer containing crimes in the city of Worcester in 2014. Now, you will learn how to create this layer of the locations of crimes using street addresses, a process called <strong>geocoding. <\/strong>Crime data were obtained from <em>crimereports.com<\/em> (deadlink). In addition to the table of addresses, we\u2019ll use an \u201cAddress Locator\u201d (more on this later) provided by <a href=\"http:\/\/www.openstreetmap.org\">OpenStreetMap<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The address locator requires a vector street layer containing house numbers for each street segment. Since houses are arranged as odd\/even numbers on different sides of the street, the vector layer must have house numbers on both, left and right sides of the street. Fortunately this information has been compiled by the US census bureau in the street TIGER files. See the image for a look at one section of streets between South Hadley and Chicopee.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The figure below shows columns of the TIGER file for Massachusetts (from MassGIS). Notice the street name column: there are multiple line segments for the same street. The rest of the columns indicate the range of house numbers found on the left and on the right for each segment:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"742\" height=\"295\" src=\"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-content\/uploads\/sites\/965\/2025\/02\/ex9-fig18.jpg\" alt=\"address locator table\" class=\"wp-image-822\" srcset=\"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-content\/uploads\/sites\/965\/2025\/02\/ex9-fig18.jpg 742w, https:\/\/commons.mtholyoke.edu\/emarcano\/wp-content\/uploads\/sites\/965\/2025\/02\/ex9-fig18-300x119.jpg 300w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>LFROMADD \u2013 contains the house number that starts the segment on the left side (left from address).&nbsp; Same for RFROMADD for the right side.<\/li>\n\n\n\n<li>LTOADD \u2013 is the last house number found in the street segment on the left address (left to address).&nbsp; Same for RTOADD for the right side.<\/li>\n\n\n\n<li>ZIPL and ZIPR \u2013 these are the zip codes that can be found either on the left or right side of the street segment.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Be aware that this business of geocoding street addresses will vary enormously from country to country depending on the quality of the data and the situation of the addresses on each street in each country.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new project in QGIS<\/li>\n\n\n\n<li>Add the table with crime data in your working folder <strong>(X:ex9),<\/strong> <em>Crimes_Worcester_2014.csv <\/em>and examine its contents.&nbsp; (in the Data Source manager, you can use the Browser tab to find it)<\/li>\n<\/ol>\n\n\n\n<p class=\"has-yellow-background-color has-background wp-block-paragraph\"><em>Question 3. How many records are there?<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Notice the column called \u201cWeb_Address\u201d. This is how <em>crimereports.com <\/em>gave you the address.&nbsp; Obviously, it\u2019s a degraded address. I edited those addresses (removed the word \u201cBlock\u201d) and created a column called \u201cAddress\u201d.&nbsp; The result of this operation is that all the crimes that happened in one particular block will be geocoded to the first address of the block.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The procedure we are going to use takes a long time, so we are going to get only a subset of the crimes in Worcester. For our purposes, we\u2019ll only study the Drug related crimes.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Select only \u201cDrugs\u201d from <em>Crimes_Worcester_2014.csv<\/em><\/li>\n<\/ol>\n\n\n\n<ol style=\"list-style-type:lower-alpha\" class=\"wp-block-list\">\n<li>Get the properties of the table in the Layers pane\n<ul class=\"wp-block-list\">\n<li>In the Source tab click on Query Builder<\/li>\n\n\n\n<li>Enter the expression Crime_type = Drugs (after choosing \u201cCrime_Type\u201d on the left window, push \u201cAll\u201d button under the Values window to pick \u201cDrugs\u201d<\/li>\n\n\n\n<li>Click OK<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" style=\"list-style-type:lower-alpha\" class=\"wp-block-list\">\n<li>Export the <strong>selected records<\/strong> (302 records) as a Comma Separated Value (CSV) file (NOT a shapefile) and save it in your working folder.<\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we\u2019ll use a QGIS plugin. This is an external program that provides extra functionality to QGIS.<\/p>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>In the top menu PluginsManage and Install Plugins&#8230;<\/li>\n\n\n\n<li>Select All, on the left, then type &#8220;MMQGIS&#8221; in the search box, it\u2019ll be listed in the center pane, select it and click install in the lower-right corner of the window. Close the Plugins dialog. Notice a new menu MMQGIS added to the menu bar on top.<\/li>\n\n\n\n<li>From the MMQGIS menu select GeocodeGeocode CSV with Web Service<\/li>\n<\/ol>\n\n\n\n<ol style=\"list-style-type:lower-alpha\" class=\"wp-block-list\">\n<li>Provide the csv file with the <strong>drug<\/strong> crimes as input<\/li>\n\n\n\n<li>The address fields should be populated correctly (address, city, and state). Make sure selections are correct<\/li>\n\n\n\n<li>Web server: OpenStreetMap\/Nominatim (this is going to use an OSM server, make sure you have internet access for this)<\/li>\n\n\n\n<li>Enter output shapefile (SHP) and Not Found output list (<strong>CSV<\/strong>) in your <strong>working folder. Make sure this last one is in the right format (CSV).<\/strong><\/li>\n\n\n\n<li>Click Apply and wait until finished (~5mins)<\/li>\n<\/ol>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>When the program finishes geocoding you can see the shapefile with the geocoded addresses. There will be some obvious errors (outside the city of Worcester).&nbsp; You can add the outline of Worcester from ex6<em>Worcester.gdb<\/em>. Those outliers need to be extracted, verified, and run again (we won\u2019t do that here).<\/li>\n\n\n\n<li>Check the Not Found table. These addresses didn\u2019t get \u201cmatched\u201d to a street address, maybe a misspelled or wrong address.&nbsp; Depending on the importance of the job, you should try to fix those addresses and geocode them until there are no more unmatched addresses.<\/li>\n<\/ol>\n\n\n\n<p class=\"has-yellow-background-color has-background wp-block-paragraph\"><em>Question 4.&nbsp; How many unmatched addresses in the Not Found output csv file did you get?&nbsp; _____________ (It should be a very low number, hopefully)<\/em> <\/p>\n\n\n\n<ol start=\"9\" class=\"wp-block-list\">\n<li>Open the table of the new geocoded layer and notice the new columns that have been created. These include a new address field (DISPLAY_NA) and LatLong among others.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"#top\">Return to top<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/commons.mtholyoke.edu\/emarcano\/geog210\/\">Return to Geog 210 page<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n","protected":false},"excerpt":{"rendered":"<p>Return to top Return to Geog 210 page Part 2: Geocoding (with QGIS) In exercise 6, you used a point layer containing crimes in the city of Worcester in 2014. Now, you will learn how to create this layer of the locations of crimes using street addresses, a process called [&hellip;]<\/p>\n","protected":false},"author":793,"featured_media":859,"parent":204,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"class_list":["post-1058","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/pages\/1058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/users\/793"}],"replies":[{"embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/comments?post=1058"}],"version-history":[{"count":2,"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/pages\/1058\/revisions"}],"predecessor-version":[{"id":1949,"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/pages\/1058\/revisions\/1949"}],"up":[{"embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/pages\/204"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/media\/859"}],"wp:attachment":[{"href":"https:\/\/commons.mtholyoke.edu\/emarcano\/wp-json\/wp\/v2\/media?parent=1058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}