# (3) - QGIS Meets HERE Data Hub ### Introducing QGIS ###### QGIS official website:https://qgis.org/ QGIS is a free and open-sourced GIS (Geographic Information System) software. Commercial GIS softwares usually cost a lot, but QGIS won't charge you a cent to use which is super benefit for everyone. The major function of GIS is render, edit and calculate map data, QGIS is already good enough for general people, moreover, QGIS support multiple architectures, so you can run QGIS on Windows, Mac OS, Linux or even Android. QGIS has been improved during these years, it's 3.14 (Pi) when I'm writing this article, it might change when you read it. QGIS is now more stable and with richer functionalities. You can install plugins to add more capabilities, or using Python 3 programming language to develop your own plugin or run your code with QGIS. QGIS is too rich to introduce, we will only cover small part of it in this course. Download QGIS:https://qgis.org/zh-Hant/site/forusers/download.html ![](https://i.imgur.com/3qF58DA.png) I would recommend to choose "QGIS Standalone Installer Version 3.x (64 bit)", because it's easier, of course you can choose the installer with OSGeo4W, but it's more complicated than that. The process of installing QGIS is easy, but no need to install additional data sets. ![](https://i.imgur.com/RY3EIYG.gif) ### XYZ Hub Connector After installation is completed, we can run QGIS now. We are now going to install plugin, please press "Plugins" then "Manage and Install Plugins...". ![](https://i.imgur.com/8fQ9KBG.png) In the tab of "ALL" will list out the plugins you can install, please type "xyz hub" in the search bar, you will see "XYZ Hub Connector", press "Install Plugin" to install it. Close this window after installation finished. ![](https://i.imgur.com/MPYHQY6.png) After installing it, you will see 2 more buttons shows on the toolbar, press the left one. ![](https://i.imgur.com/VDbVVCQ.png) "XYZ Hub Connection" will show up, press "Setup", "Setup XYZ Hub Token" will show up, press "Add". ![](https://i.imgur.com/3VDiqko.gif) There will be text boxes, you can give a name in "Name", and input the "ALL of ALL" token in "Token", you can login HERE Data Hub Console again to check in case you forgot it already. Press "OK" while finished. ![](https://i.imgur.com/miQLLmn.png) Now you can see your token, press "OK". ![](https://i.imgur.com/6645aOe.png) Then press "Connect", you can see the Spaces you have. Now you can use QGIS to read the content of this Space, please choose the Space you are about to reead, choose "Static" of "Mode" on the bottom-right, then press "Load", QGIS will download the content of this Space from Data Hub, and render it on the map. You can use your left key of mouse to pan the map (choose the palm icon of toolbor), or use wheel to zoom in and out. Press the wheel to pan the map as well. ![](https://i.imgur.com/HNeOjZ9.gif) Furthermore, you can see "Layer" on the bottom-left, it shows the map data you loaded in QGIS as "Layers", you can customize the style of it and check the content. For example, please right-click on "scidm-maskdata_geo.csv", choose "Open Attribute Table". ![](https://i.imgur.com/wa1QepG.png) It will open a window shows a table just like what we uploaded, however HERE Data Hub added some columns, such as "xyz_id" and "color". Right-click on the table and choose "Zoom To Feature", the map will zoom to the feature you chose; press "Flash Feature" to flash it. ![](https://i.imgur.com/jIvX8Xx.gif) We can edit the attributes as well, press the yellow pencil button on the top-left to switch on editing mode. Then you can press on any one of column, you will find it's now editable. ![](https://i.imgur.com/DWxTADp.gif) Of course, each record can be deleted, let's go back to the map view, find "Add Point" on the toolbar, the cursor will become crosshairs, click on the map where you like, there will be a dialog shows up, you can input these attributes. Let's input something fake. ![](https://i.imgur.com/nyNtaCh.gif) Press "OK" after finished, there will be a new feature on the map. ![](https://i.imgur.com/7pfwXcK.png) It also shows in attribute table. ![](https://i.imgur.com/iNvjWEu.png) Then press the yellow pencil again, it will ask you to save or not, please "Save". ![](https://i.imgur.com/XDqEdA5.png) Back to the toolbar, find "XYZ Hub Connector", you will find the right button which was grayed out, now becomes green, press it. ![](https://i.imgur.com/W1V5EbG.png) Once you press it, XYZ Hub Connector will sync/upload the changes to Data Hub, message will popup once sync/upload is done. Now open the map you made with HERE Studio in the 1st lesson, you will see the fake feature you just added is shown on the map! ![](https://i.imgur.com/nbsKOvN.png) You can create, you can destroy as well. Enter attribute table then press the yellow pencil again, then find the feature you just added, press the line number on the left, then press the trash bin icon on the toolbar, the feature will be deleted. Don't forget to press yellow pencil again then choose "Save", finally sync/upload the change again, that's it. ![](https://i.imgur.com/K9N4JGU.png) If you made it right, you will no longer see the new feature after reopening the map. ![](https://i.imgur.com/JA6ptsZ.png) ### Basic of QGIS First of all, open this page: https://data.taipei/#/dataset/detail?id=a9c282c5-3a43-41ed-badc-f9c1bdf1cc34 ![](https://i.imgur.com/LiHt0Pr.png) Then press "預覽" on the right side of "禁停紅黃線", it will show up a link of Google Drive, open it. Or you can just open https://data.taipei/api/getDatasetInfo/downloadResource?id=a9c282c5-3a43-41ed-badc-f9c1bdf1cc34&rid=48d59dbf-7056-42e2-94b1-41f41169b886 . Download will begin shortly, it's a zip file, please extract to any location you like. You will find there are 3 files in it: cfg, dbf, prj, shp, shx, we call this structure of fils "Shapefile", which is commonly used for geographic data distributing. ![](https://i.imgur.com/0c9Q5K7.png) Back to QGIS, press the blank paper button to create a new project, choose "Discart" to not to save the existing one. ![](https://i.imgur.com/B2qeiNw.png) You will find a blank map, then please drag ".shp" file to it. ![](https://i.imgur.com/QfRbyAS.gif) After the file opened, you can pan and zoom, but they are still lines of single color. ![](https://i.imgur.com/LDtm6fI.png) We can add a background to have better understanding of where it is. Please double click "XYZ Tiles" on the left hand side, then double click "OpenStreetMap". ![](https://i.imgur.com/J2IxgA4.png) QGIS will create a new layer and render the map tiles of OpenStreetMap, however it's now covering the layer we added. ![](https://i.imgur.com/IeeLHYu.jpg) Now drag OpenStreenMap within Layers to the bottom, we can change the sequence of layers this way. ![](https://i.imgur.com/iGZ6ou9.gif) We are now clear of where we are. Now, we can use "Identify Features" to check the features on the map, please click the button on the toolbar: ![](https://i.imgur.com/fepR5wy.png) Now the cursor becomes black with letter "i", and click a feature (line) on the map, QGIS will show all the attributes on the right panel. ![](https://i.imgur.com/mv4u7Br.png) Even though there are many attributes, but we only need to focus on "PATYPE", if "PATYPE" is "02" which means yellow lines, others are red lines. We can set colors with this rule. What's the difference between yellow and red lines? Yellow means this section can be used for "kiss and ride", you can park for a while (less than 3 minutes), driver can't leave the car; but if it's red line, then you are not allowed to park at all, or you may get tickets. Please double click "noparkin_20XXXXXX" layer, properties will show, you can configure types of layer with "Symbology" tab, such as color, line width, patters, etc. The default style is only one single color, you can click "Color" to change it, and change "Width" to make it thicker or bolder. This setting will apply to all features of this layer. Of you want to use different color by your own rule, please click "Single symbol" on the top, there will be 5 options, choose the 3rd one "Categorized". ![](https://i.imgur.com/LCVl8sR.png) And press the little arrow on the right side of "Value", press "PATYPE". ![](https://i.imgur.com/cM0B7ao.png) Now press "Classify" on the bottom, now it will list out each value of "PATYPE", there are 01, 02, 06 and 11, they have their own colors as well. ![](https://i.imgur.com/H9jkzdn.png) Double click on the color lines, you can change its color, thickness and transparency. Please change 01, 06 and 11 to red; change 02 to yellow. ![](https://i.imgur.com/553IREn.gif) Press "OK" if finished. ![](https://i.imgur.com/xsebhsV.png) Back to the map view, the lines are now displaying with colors they are supposed to be. By the way, most of the lines are red, which it's very difficult to park your car in Taipei City. ![](https://i.imgur.com/HMmtKZP.jpg) ### Create Space with QGIS You can do the same thing with HERE Studio by giving different color according to different attribute. First, please open XYZ Hub Connection and press "Connect", press "Manage Spaces" if your spaces are loaded. Press "New" to create a new Space. ![](https://i.imgur.com/KZ9GLgI.gif) Now input title and description, then press "OK". ![](https://i.imgur.com/qIlFSsC.png) And you will see the new Space you've just created. ![](https://i.imgur.com/BQJzKtE.png) The next step is to upload "noparkin" layer to the new Space, because the format of this layer is Shapefile, can't be uploaded with HERE Studio website, so you have to use HERE CLI or QGIS to upload it. I would recommend to use QGIS in the beginning because with QGIS you can check the content of data, understand it's structure and attributes, which is more convenient for you to proceed. XYZ Hub Connection is a fine tool for you to manage your map data on your computer or HERE Data Hub without calling API or CLI. ### CRS transformation Although you can upload your Shapefile data with QGIS + XYZ Hub Connection, however you can't upload this "noparkin" layer because it's CRS (Coordinate Reference System) is not WGS84, but TM2 locally used in Taiwan, if you just upload it, you will get an error message. You can check this with QGIS, it shows this Shapefile data is with "TWD97/TM2" CRS. ![](https://i.imgur.com/TepmJLF.png) It's quite usual if you are dealing with Shapefile, take an example of Government of Taiwan, it could use CRS of TWD67/TM2, TWD97/TM2, TWD67 Lat/Lng or WGS84, if you can't specify correct CRS while processing, the display of features might shift or can't be processed, so please be careful with CRS. So we will convert this Shapefile to WGS84 which is supported by HERE Data Hub, please right click on "noparkin" layer, and press "Export, then press "Save Feature As...". ![](https://i.imgur.com/pizPwkj.png) Then, choose "GeoJSON" for Format, and choose the path and file name to save the output GeoJSON file. Choose "ESPG: 4326 - WGS 84" for CRS. You can choose the attributes you need or not, because now we only need "PATYPE" so you can cancel the others but leave "PATYPE" only. Press "OK" to save the file. ![](https://i.imgur.com/Y6hQ8HY.png) Wait for few seconds, QGIS will load the exported GeoJSON into this project and show on the map. You can check the attribute of the new layer by opening attribute table, you can see only "PATYPE" is there. ![](https://i.imgur.com/zIvsHM6.png) Back to XYZ Hub Connection, then press the new created Spacepress "Upload", choose the new GeoJSON layer you exported for Layer. You can leave some texts for Tags or leave it blank. Press "Upload" to upload this layer to HERE Data Hub. ![](https://i.imgur.com/FpmfNXd.png) Once "Upload" pressed, a dialog will show up, because the data will be processed after uploaded to Data Hub, and the output will be different, but it's not a problem for us. Just press "OK" to continue. ![](https://i.imgur.com/qYql4Qi.png) After pressing "OK", upload will start, you can press message button on the bottom-right to open Log Message, you can see some messages from XYZ Hub Connector. Since this data set has more features, it will take a while to upload. ![](https://i.imgur.com/vZFQj8a.png) A green box will show up on the top of map that tells you the upload is completed. ![](https://i.imgur.com/hHdiOMg.png) However if you wait for a while and no message shows, you can check the progress with XYZ Hub Connection, press "Connect" or "Ok!" to recheck the number of "feat_cnt". ![](https://i.imgur.com/lbMBsaU.gif) You can see the number of "feat_cnt" is 125766, then right click on the layer and choose "Show Feature Count", it will show the number of features of this layer. ![](https://i.imgur.com/3RfpSc1.png) If both numbers are matched, then the upload is done. ![](https://i.imgur.com/9aPv6P2.png) ### HERE Studio map making Open HERE Studio, login, then create a new project as you learned before. Press "+Data" to add the layer you uploaded to the map. ###### HERE Studio:https://studio.here.com/ ![](https://i.imgur.com/kaLq7Vq.png) Then we will now define colors for lines as we learned before, press the layer and press "Lines", but we won't set color directly but assign colors according to our own rules, so please press "+ Add new line style". ![](https://i.imgur.com/yXecJBT.png) Then follow the procedure below: 1. Give a name to "Style group name", like "Yellow Lines". 2. Choose "PATYPE" for "Property". 3. Chhose "Equals" fpr "Condition". 4. Input "02" to "Value", there could be warning, just press "Do not show this message again". ![](https://i.imgur.com/7j4LzUA.png) 5. Press "Confirm". ![](https://i.imgur.com/05skbul.png) Then you will see the style "Yellow Lines" shows up in the styles, then you can set the color, please give it yellow color. ![](https://i.imgur.com/OFth7vs.png) Then repeat the last step, but now we choose "Does not equal" for "Condition". ![](https://i.imgur.com/33dZgqF.png) The give it red color. ![](https://i.imgur.com/o7EYYnA.png) Then we are done with our parking regulation map. We can add the boundary of city for better visualization, the process is the same as you did for no-parking lines. ###### Boundary of Taipei City: https://data.taipei/#/dataset/detail?id=1601ef3a-c253-4988-b047-943d9e786143 Download this data set, unzip it, then drag .shp file into QGIS. But we have to set CRS first, because the source data has no CRS setting, which will cause failure while converting it. Open "G97_A_CADIST_P", right click on it, then choose "Set CRS", then choose "Set Layer CRS...". ![](https://i.imgur.com/Fxe31zs.png) Then input "twd97" in "Filter", then choose "TWD97 / TM2 zone 121" down below, the ID should be "ESPG:3826", then press "OK". ![](https://i.imgur.com/5u631fR.png) Then follow you learned in this course: 1. Convert to GeoJSON format with WGS84 CRS and save it. 2. Create a new Space with XYZ Hub Connection. 3. Upload the converted GeoJSON to this new Space. 4. Login HERE Studio, open the map of parking regulations. 5. Add this Space into the map, and set the style. Tricks: 1. Name of Style can be display in legends, so give it a good name. 2. "Default Line Style" is redundant, you can change "Width(px)" to "0" to hide it. Now we are done with a parking regulation map! ![](https://i.imgur.com/RLytKrl.jpg) --- ## Make a map of house safety We will use several open data in this project: * Map of dip slope (geojson): https://opendata.epa.gov.tw/Data/Details/SOIL00112 * Map of fault (kml): https://opendata.epa.gov.tw/Data/Details/SOIL00103 * Map of soil liquefaction (geojson): https://data.gov.tw/dataset/28691 For your convenience, I put theses files on Google Drive, you can download here: https://drive.google.com/file/d/1BDvK-Zahf-ONL9iwxNjDtTMxsuH6-bwI/view?usp=sharing Unzip it after downloading it. You need to put these data on Data Hub, you can try with HERE CLI, or using HERE Studio website, however HERE CLI and Studio doesn't support KML format, so you have to upload it with QGIS. First, we will try to read these files with QGIS, drag "活動斷層.kml" (map of fault) and "順向坡分布圖.json" (map of dip slope) into QGIS. Both data sets are with standard WGS84 CRS, so there is no need to set CRS again, you can use QGIS to browse and check if the data is correct. Of course you can open OpenStreetMap as the background as you did. ![](https://i.imgur.com/AxuTSmb.png) It's interesting when moving around, you might find some residential areas were built on dip slope, which might be a risk living it. ![](https://i.imgur.com/1AltZGz.png) And you can see a fault "山腳斷層 / Shanchiao fault" is crossing the northern part of Taipei which is the most populated area in Taiwan. ![](https://i.imgur.com/ikyTpLc.jpg) You can close the layers by right click on the layers and choose "Remove Layer...", there will be a dialog to ask you to confirm. ### Process your data with QGIS ![](https://i.imgur.com/BaPMd8j.png) Now we will deal with map of land liquefaction, after unzipping it you will see 3 folders, they are 土壤液化高潛勢 (highly potential), 土壤液化中潛勢 (middle potential), 土壤液化低潛勢 (low potential), there are dozens of .json files, they are GeoJSON format data, drag them all into QGIS. ![](https://i.imgur.com/7MFz6jR.png) There are 51 layers, but you will find some layers are looked different, that's because they are empty, so please remove them from the project. ![](https://i.imgur.com/7TZF9Q3.png) Now we will merge all layers into one, because we only need one to upload to Data Hub, please press the Toolbox button on the toolbar, or press CTRL+ALT+T to open toolbox. ![](https://i.imgur.com/7iVtFOo.png) After toolbox showed up, type "merge" in the text box on the top, then double click "Merge Vector Layers". ![](https://i.imgur.com/7d1dm6A.png) Then press "..." button on the right of "Input layers", then choose "Select All", then press "Run" to execute it. ![](https://i.imgur.com/S79Hw1z.gif) After that, you will see a "Merged" layer in Layers, save it to a new GeoJSON file and open it. You can remove the other layers that are not needed anymore. ![](https://i.imgur.com/U3006JU.png) Then we can do as we learned, using XYZ Hub Connection to build 3 new Spaces, then upload these 3 data sets, it only takes few minutes. ![](https://i.imgur.com/fivPinG.png) And you can make a map with HERE Studio, which also takes few minutes only. ![](https://i.imgur.com/V4iz5Lg.jpg) That's it, now you have a map can be shared on the internet, but there are still something needs to be improved, such as: 1. Can we integrate address search so we can input address to check if it's on a land liquefaction area or dip slope? 2. Can we change the background map? In the next course, I will show you how to make a web map with JavaScript and add such features, however it will need ability of coding in JavaScript, I will try to make it as easy as possible.