Displaying text and image in a map tip in QGIS 3.6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'm going to show you how to take survey data where you've collected GPS locations and images at those locations and display those points in huge US and make it so that on hovering your cursor over the points it displays the image taken at the location I've downloaded my data and placed it in a project folder in this case labeled map tip example and you can see here I have both the X OS X spreadsheet data and also a folder of attachment called attachments that contains the image files first thing I'm gonna do is I'm going to open the excel file and I'm going to save it as a CSV file so I'm going to go to file save as from the file format drop-down select comma delimited CSV and save it into the same project folder that I already created I couldn't close that out if I look in the attachments folder that's downloaded from Kobo toolbox you can see that it has placed the images within a folder hierarchy based on the submissions that they came in on I want all of those images in a single folder so I'm going to do is I'm going to create that new folder I'm gonna call it images all lowercase you name it whatever you want and then I'm going to go into the attachments folder and on Mac OS X I can search within that folder for anything with the dot jpg extension I can copy those images that show up go back to my project folder into the images folder and paste those items into there and now I have a single folder in my project folder with all of those images I'm gonna go ahead and clean up and remove the unnecessary now attachments folder and originally downloaded data now I'm ready to open up QGIS I'm going to start a new project and I'm going to add OpenStreetMap base tiles so I can get an idea of where in the world I am once I start adding data and have that background layer just to have a reference OpenStreetMap data can be quickly added if you have the browser panel open if you here on the left is where it should be if you don't see it go up to view panels and there's a browser option click that and then this option here should appear and if you scroll down in there you can see XYZ tiles and it should already have Open Street Map in there by default you can double-click and it will add it that's in the background there now I want to add the point data from my survey I'll go up to layer add layer and you can see there's a add delimited text layer option I'm going to click that and the options that come up I'm going over here next to the file name field and click the Browse option I'm here in my map tip example folder and I'll select the CSV file that I saved earlier opening that it will detect or might have to tell it that it's a comma delimited and then you can see it's already auto detected that the pony coordinates are held in the fields longitude and latitude so I can then click determine the geometry and other fields sample data looks good click Add and close this dialog you can see they are now appearing hard at the map I want to save the CSV out as a geo file so I'm going to right click it's in the layers menu go to export and save features as choose in the format ESRI shapefile and next to file name clicking browse making sure I'm in my project folder and in this case shape files have multiple files associated with each one so in order to keep my project folder clean I'm gonna go ahead and create another folder call it geo and save my point data within that folder and clicking ok you're gonna see it added to the map I'm going to remove the CSV layer so I'm remaining all the good points shapefile and here you can see the geo that that single shape house actually six files that you need to keep those all named the same in in the same folder so that they can be opened correctly going back into QGIS I'm gonna quickly change the style on my points so they're a little bit bigger and easier to see right-clicking or double left-click going then going to properties and I can choose symbology and change my markers I'm gonna double the size and change the color to a nice bright red so they're a little bit bigger any easier to see here I can zoom in to the ones in this case we're collected at the Bangladesh Red Crescent training center where the offices are next step I want to add something called a map tip actually let's go ahead and save our project first I'm gonna go to file save and make sure I'm in my map tip example project folder and I'm going to call my project also map to example and save it there also now another thing that we want to set is under project and then properties I want to set the project home this will allow me to reference the folder containing the images more easily and also be able to move that project folder to a different computer or a different location and still have the links work correctly so I'm going to go over here to browse to set the project path make sure I'm within the map tip example folder and just click open and you'll see then that path will appear here project home and I want to say make sure that save paths is relative that's what lets me move that project folder and hit OK save my project so now Hugh just has this really cool option map tips you can make sure that it's armed by seeing that this icon here in the menu bar it has a this great box around it show map tip so you can also go to to view scroll down you'll see show map tips here should have a check next to it so that that means it's enabled I can right click and go to properties my points there or I can also double left click it to open up the layer properties now we're going to go to display with this yellow speech well next to it and here we can set the parameters for our HTML nav tip we can pull out attributes from features using particular syntax square brackets with percentage signs inside and then the field name surrounded by quotation marks so we have a field called photo that contains the file names of the images collected in each survey so let's just type that here into the age to learn map tip and hit OK going back to the map and see what happens if we hover over one of our points we can see that that filename from that field is pulled out and will display in the map tip here opening back up and going back to our HTML map tip we can use HTML code to style and add more Advanced Options into this map tip so we can use insert an image using an HTML image tag IMG to start after the carrot there and then it asks are see is the attribute that defines the path to the image source and QGIS this needs to start with file colon slash slash slash slash and then we set project home and we can use that as a shortcut to help the computer know where to locate images and that will automatically populate with the system file path to our project folder then we have our images folder named images all lowercase and inside of that we will have the files with the names from this photo attribute and then we want to close our image tag and we hit OK now if we hover over one of these we can see that the image itself is appearing but there's a problem the image is too large for the maximum size of the map tip so we can do we can go back into our layer properties and we can add another attribute in digit in addition to source we can add for instance a width attribute and set a value and this is going to be a number of pixels and hit OK and now if we go back to our point and hope over it hover over it we can see that the image is shrunk down so there's only 450 pixels wide you can easily pull in additional attributes as well we are going to add in a value from a remarks field that exists in our data and will add in a line break so that the remarks appears and then the photos will appear on the next line and that in HTML is a slash and then BR and if we hit OK now we can see that that text is appearing above the image and we can continue to play with HTML to to style this housing 1 in this case we're going to wrap it in a the text and a span and the span allows us to add in attributes that then style this so we can add a style attribute and inside that define things like color red and font weight we're gonna make folder and if you search from Google you can go to like I think sort of HTML primer and in the HTML tutorial they'll teach you how to use these different attributes in different it smell features too to add things to this map tip now we're gonna go hit ok and we can see that yes indeed our text is now red and older there we go quickly adding in points to your map and then being able to preview the images or other attributes from those features kind of saved my project and I can close the stop moping it back up later
Info
Channel: Dan Joseph
Views: 14,961
Rating: undefined out of 5
Keywords: QGIS, GIS, KoBoToolbox, maps, mobile data collection, ODK, ODK Collect
Id: 6HYqDCdpJko
Channel Id: undefined
Length: 12min 42sec (762 seconds)
Published: Tue Apr 09 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.