{"id":3761,"date":"2020-07-15T08:18:49","date_gmt":"2020-07-15T12:18:49","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/?p=3761"},"modified":"2020-09-11T10:25:24","modified_gmt":"2020-09-11T14:25:24","slug":"displaying-fault-lines-on-a-geographic-globe-using-mapping-toolbox","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2020\/07\/15\/displaying-fault-lines-on-a-geographic-globe-using-mapping-toolbox\/","title":{"rendered":"Displaying Fault Lines on a Geographic Globe using Mapping Toolbox"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p>Guest blogger, Kelly Luetkemeyer, who is a senior software developer at MathWorks, returns with an article on displaying fault lines on a geographic globe. Kelly's previous articles included <a href=\"http:\/\/blogs.mathworks.com\/loren\/2011\/01\/20\/tracking-a-hurricane-using-web-map-service-wms\/\">Tracking a Hurricane using Web Map Service<\/a>, <a href=\"http:\/\/blogs.mathworks.com\/loren\/2010\/05\/06\/oilslick\/\">Visualizing the Gulf of Mexico Oil Slick using Web Map Service<\/a> and <a href=\"https:\/\/blogs.mathworks.com\/loren\/2014\/12\/31\/using-restful-web-service-interface-in-r2014b-matlab\/\">Using RESTful Web Service Interface in R2014b MATLAB<\/a>.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#a53245ab-37a4-484a-a0dd-34aa352f7cb3\">Introduction<\/a><\/li><li><a href=\"#91d45588-d6ec-42fe-a15b-52b8a8a7dad2\">Obtain Shapefile of Fault Lines from the United States Geological Survey<\/a><\/li><li><a href=\"#7fe77286-73a2-44d1-8cc7-858254042f39\">Read Fault Lines Data from Shapefile<\/a><\/li><li><a href=\"#6e5d609a-4dad-4f6f-9014-1747b8dec1b0\">Find Faults of Interest<\/a><\/li><li><a href=\"#83d9548a-2b4d-48ab-9d72-d027a080a0cc\">Display Fault Lines using Geographic Axes<\/a><\/li><li><a href=\"#e2e104ac-f1e6-43e2-9cf6-1399a8583bb5\">Display Fault Lines using Geographic Globe<\/a><\/li><li><a href=\"#42461c81-9981-427a-89d3-de375c490ec0\">Find San Andreas Fault<\/a><\/li><li><a href=\"#4aba0eed-8d04-4485-9e9d-337ec8a82791\">Add use of Custom Basemap from the USGS National Map<\/a><\/li><li><a href=\"#7430cd2d-b3e4-4432-8716-175d22e597d4\">Display San Andreas Fault on USGS Basemap using Geographic Axes<\/a><\/li><li><a href=\"#0e8879eb-e050-4080-b3a1-5fab8193a20a\">Display San Andreas Fault on USGS Basemap using Geographic Globe<\/a><\/li><li><a href=\"#2288a3dc-919f-4eb9-b2d6-cdfe4d70431c\">Navigate to San Andreas Lake<\/a><\/li><li><a href=\"#9eb38910-9aa9-4900-b057-a9fb2966fb49\">View San Andreas Fault in 3-D<\/a><\/li><li><a href=\"#751bc02d-96e9-4118-b0f0-db0a46253fa0\">Add use of Custom Terrain from the USGS Earth Explorer<\/a><\/li><li><a href=\"#9c4c82be-13e7-4637-ae19-9a48cafc5e4e\">Conclusion<\/a><\/li><\/ul><\/div><h4>Introduction<a name=\"a53245ab-37a4-484a-a0dd-34aa352f7cb3\"><\/a><\/h4><p>In R2020a, Mapping Toolbox introduced six new features for displaying data on a geographic globe.<\/p><div><ul><li><a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/geoglobe.html\">geoglobe<\/a> - Create geographic globe<\/li><li><a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/geoplot3.html\">geoplot3<\/a> - Geographic globe plot<\/li><li><a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/addcustombasemap.html\">addCustomBasemap<\/a> - Add use of custom basemap data on globe<\/li><li><a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/addcustomterrain.html\">addCustomTerrain<\/a> - Add use of custom terrain data on globe<\/li><li><a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/removecustombasemap.html\">removeCustomBasemap<\/a> - Remove use of custom basemap data on globe<\/li><li><a href=\"https:\/\/www.mathworks.com\/help\/map\/ref\/removecustomterrain.html\">removeCustomTerrain<\/a> - Remove use of custom terrain data on globe<\/li><\/ul><\/div><p>This blog post illustrates how to plot fault lines on a 2-D geographic axes and a 3-D geographic globe. In geology, a fault is a fracture or discontinuity in a volume of rock and faults are one of the most important global geological hazards. Fault lines are plotted on a high zoom-level basemap hosted by Esri&reg; and a custom basemap and custom terrain data from the United States Geological Survey (USGS).<\/p><h4>Obtain Shapefile of Fault Lines from the United States Geological Survey<a name=\"91d45588-d6ec-42fe-a15b-52b8a8a7dad2\"><\/a><\/h4><p>A shapefile of fault lines from the western United States can be obtained from <a href=\"https:\/\/earthquake.usgs.gov\/static\/lfs\/nshm\/qfaults\/Qfaults_GIS.zip\">https:\/\/earthquake.usgs.gov\/static\/lfs\/nshm\/qfaults\/Qfaults_GIS.zip<\/a><\/p><p>Download and unzip the file. The shapefile is located in the folder: <tt>\"GIS Files\/Shapefile\"<\/tt>.<\/p><h4>Read Fault Lines Data from Shapefile<a name=\"7fe77286-73a2-44d1-8cc7-858254042f39\"><\/a><\/h4><p>Read the geographic data from the shapefile and convert to a geoshape vector for ease of use.<\/p><pre class=\"codeinput\">folder = <span class=\"string\">\"GIS Files\/Shapefile\"<\/span>;\r\nshapefile = <span class=\"string\">\"QFaults.shp\"<\/span>;\r\nfilename = fullfile(folder, shapefile);\r\nfaults = shaperead(filename,<span class=\"string\">\"UseGeoCoords\"<\/span>,true);\r\nfaults = geoshape(faults);\r\n<\/pre><p>Examine the number of elements and display the first element.<\/p><pre class=\"codeinput\">numberOfFaults = length(faults)\r\nfirstElenent = faults(1)\r\n<\/pre><pre class=\"codeoutput\">numberOfFaults =\r\n      112891\r\nfirstElenent = \r\n 1&times;1 geoshape vector with properties:\r\n\r\n Collection properties:\r\n      Geometry: 'line'\r\n      Metadata: [1&times;1 struct]\r\n Vertex properties:\r\n      Latitude: [41.8997 41.8914 41.8836 41.8800 NaN]\r\n     Longitude: [-120.2850 -120.2703 -120.2564 -120.2508 NaN]\r\n Feature properties:\r\n    fault_name: 'Goose Lake graben faults (Goose Lake fault)'\r\n      sec_name: ''\r\n      fault_id: '828'\r\n    section_id: ''\r\n      Location: 'California'\r\n      linetype: 'Well Constrained'\r\n           age: 'late Quaternary'\r\n           dip: 'W'\r\n     slip_rate: 'Less than 0.2 mm\/yr'\r\n    slip_sense: 'Normal'\r\n         scale: '1:250,000'\r\n         class: 'A'\r\n    mapped_cer: 'Good'\r\n        strike: ''\r\n        length: 0\r\n    cooperator: 'California Geological Survey'\r\n    earthquake: ''\r\n     fault_url: 'https:\/\/earthquake.usgs.gov\/cfusion\/qfault\/show_report_AB_archive.cfm?fault_id=828&amp;section_id='\r\n     symbology: 'late Quaternary Well Constrained'\r\n        ref_id: '828'\r\n    Shape_Leng: 4.8044e+03\r\n\r\n<\/pre><p>Find the number of unique locations.<\/p><pre class=\"codeinput\">numLocations = string(unique(faults.Location))'\r\n<\/pre><pre class=\"codeoutput\">numLocations = \r\n  16&times;1 string array\r\n    \"Alaska\"\r\n    \"Arizona\"\r\n    \"California\"\r\n    \"Colorado\"\r\n    \"Hawaii\"\r\n    \"Idaho\"\r\n    \"Kansas\"\r\n    \"Montana\"\r\n    \"Nevada\"\r\n    \"New Mexico\"\r\n    \"Oklahoma\"\r\n    \"Oregon\"\r\n    \"Texas\"\r\n    \"Utah\"\r\n    \"Washington\"\r\n    \"Wyoming\"\r\n<\/pre><h4>Find Faults of Interest<a name=\"6e5d609a-4dad-4f6f-9014-1747b8dec1b0\"><\/a><\/h4><p>Due to the size of the data, reduce the number of faults by finding faults that have a shape length greater than 10,000.<\/p><pre class=\"codeinput\">cutoffLength = 10000;\r\ndata = faults(faults.Shape_Leng &gt; cutoffLength);\r\nlat = data.Latitude;\r\nlon = data.Longitude;\r\n<\/pre><h4>Display Fault Lines using Geographic Axes<a name=\"83d9548a-2b4d-48ab-9d72-d027a080a0cc\"><\/a><\/h4><p>Display the fault lines on a 2-D map. Construct a geographic axes using <tt>geoaxes<\/tt> and plot the data using <tt>geoplot<\/tt>. The geographic axes supports eleven different basemaps. The use of \"darkmode\" is popular in many applications. For visual contrast, select the \"darkmode\" (<tt>streets-dark<\/tt>) basemap. For a contrasting visual effect, display state boundaries in white. Read the state boundaries using <tt>shaperead<\/tt>.<\/p><pre class=\"codeinput\">states = shaperead(<span class=\"string\">\"usastatelo.shp\"<\/span>,<span class=\"string\">\"UseGeo\"<\/span>,true);\r\nstates = geoshape(states);\r\nbasemap = <span class=\"string\">\"streets-dark\"<\/span>;\r\n<\/pre><pre class=\"codeinput\">figure\r\ngx = geoaxes(<span class=\"string\">\"Basemap\"<\/span>,basemap,<span class=\"string\">\"NextPlot\"<\/span>,<span class=\"string\">\"add\"<\/span>);\r\ngeoplot(gx,lat,lon,<span class=\"string\">\"LineWidth\"<\/span>,2)\r\ngeoplot(gx,states.Latitude,states.Longitude,<span class=\"string\">\"w\"<\/span>)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/R2020a_Fault_Lines_Example_01.png\" alt=\"\"> <h4>Display Fault Lines using Geographic Globe<a name=\"e2e104ac-f1e6-43e2-9cf6-1399a8583bb5\"><\/a><\/h4><p>Display the fault lines on 3-D globe. 3-D visualizations with terrain provide more context for fault lines. The 2-D map is in a Web Mercator coordinate projection system which causes a scale distortion. Construct a geographic globe using <tt>geoglobe<\/tt> and plot the data using <tt>geoplot3<\/tt>. The fault lines contain many different segments, not one continuous line.<\/p><pre class=\"language-matlab\">uif2 = uifigure;\r\ng = geoglobe(uif2,<span class=\"string\">\"Basemap\"<\/span>,basemap,<span class=\"string\">\"Terrain\"<\/span>,<span class=\"string\">\"none\"<\/span>,<span class=\"string\">\"NextPlot\"<\/span>,<span class=\"string\">\"add\"<\/span>);\r\ngeoplot3(g,lat,lon,[],<span class=\"string\">\"LineWidth\"<\/span>,2)\r\ngeoplot3(g,states.Latitude,states.Longitude,[],<span class=\"string\">\"w\"<\/span>)\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/globe_1.png\" alt=\"\"> <\/p><h4>Find San Andreas Fault<a name=\"42461c81-9981-427a-89d3-de375c490ec0\"><\/a><\/h4><p>The San Andreas fault is the most famous fault in the world and forms the tectonic boundary between the North American Plate and the Pacific Plate. The fault passes through California, a highly-populated state.<\/p><p>Search for the fault by using the <tt>fault_name<\/tt> property. Display the first element of the geoshape vector.<\/p><pre class=\"codeinput\">fault_name = <span class=\"string\">\"San Andreas\"<\/span>;\r\nindex = contains(faults.fault_name,fault_name,<span class=\"string\">\"IgnoreCase\"<\/span>,true);\r\nsan_andreas = faults(index);\r\nlat = san_andreas.Latitude;\r\nlon = san_andreas.Longitude;\r\nfirstElement = san_andreas(1)\r\n<\/pre><pre class=\"codeoutput\">firstElement = \r\n 1&times;1 geoshape vector with properties:\r\n\r\n Collection properties:\r\n      Geometry: 'line'\r\n      Metadata: [1&times;1 struct]\r\n Vertex properties:\r\n      Latitude: [1&times;39 double]\r\n     Longitude: [1&times;39 double]\r\n Feature properties:\r\n    fault_name: 'San Andreas fault zone'\r\n      sec_name: 'Shelter Cove Section'\r\n      fault_id: '1'\r\n    section_id: 'a'\r\n      Location: 'California'\r\n      linetype: 'Moderately Constrained'\r\n           age: 'undifferentiated Quaternary'\r\n           dip: 'Vertical'\r\n     slip_rate: 'Greater than 5.0 mm\/yr'\r\n    slip_sense: 'Right lateral'\r\n         scale: '1:100,000'\r\n         class: 'A'\r\n    mapped_cer: 'Good'\r\n        strike: 'N12&Acirc;&deg;W'\r\n        length: 1082\r\n    cooperator: 'California Geological Survey'\r\n    earthquake: 'San Francisco earthquake'\r\n     fault_url: 'https:\/\/earthquake.usgs.gov\/cfusion\/qfault\/show_report_AB_archive.cfm?fault_id=1&amp;section_id=a'\r\n     symbology: 'undifferentiated Quaternary Moderately Constrained'\r\n        ref_id: '1a'\r\n    Shape_Leng: 4.2662e+04\r\n\r\n<\/pre><h4>Add use of Custom Basemap from the USGS National Map<a name=\"4aba0eed-8d04-4485-9e9d-337ec8a82791\"><\/a><\/h4><p>Geographic axes and geographic globe support custom basemaps. The USGS Shaded Topographic Map is a nice map for visualizing geophysical data. Use <tt>addCustomBasemap<\/tt> to add use of this map in <tt>geoaxes<\/tt> and <tt>geoglobe<\/tt>.<\/p><pre class=\"codeinput\">basemap = <span class=\"string\">\"usgstopo\"<\/span>;\r\nbaseURL = <span class=\"string\">\"https:\/\/basemap.nationalmap.gov\/ArcGIS\/rest\/services\"<\/span>;\r\nurl = baseURL + <span class=\"string\">\"\/USGSTopo\/MapServer\/tile\/${z}\/${y}\/${x}\"<\/span>;\r\nattribution = <span class=\"string\">\"Credit: U.S. Geological Survey\"<\/span>;\r\ndisplayName = <span class=\"string\">\"USGS Shaded Topographic Map\"<\/span> ;\r\nmaxZoomLevel = 16;\r\naddCustomBasemap(basemap,url,<span class=\"string\">\"Attribution\"<\/span>,attribution, <span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">\"DisplayName\"<\/span>,displayName,<span class=\"string\">\"MaxZoomLevel\"<\/span>,maxZoomLevel)\r\n<\/pre><h4>Display San Andreas Fault on USGS Basemap using Geographic Axes<a name=\"7430cd2d-b3e4-4432-8716-175d22e597d4\"><\/a><\/h4><p>Specify the USGS basemap by setting <tt>Basemap<\/tt> to the custom basemap name.<\/p><pre class=\"codeinput\">figure\r\ngx = geoaxes(<span class=\"string\">\"Basemap\"<\/span>,basemap,<span class=\"string\">\"NextPlot\"<\/span>,<span class=\"string\">\"add\"<\/span>);\r\ngeoplot(gx,lat,lon,<span class=\"string\">\"LineWidth\"<\/span>,2,<span class=\"string\">\"Color\"<\/span>,<span class=\"string\">\"k\"<\/span>)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/R2020a_Fault_Lines_Example_02.png\" alt=\"\"> <h4>Display San Andreas Fault on USGS Basemap using Geographic Globe<a name=\"0e8879eb-e050-4080-b3a1-5fab8193a20a\"><\/a><\/h4><p>Display the San Andreas fault line on a geographic globe. Specify the USGS basemap by setting <tt>Basemap<\/tt> to the custom basemap name. Specify no terrain and set the elevation of the fault line to one meter above the terrain.<\/p><pre class=\"language-matlab\">uif1 = uifigure;\r\ng = geoglobe(uif1,<span class=\"string\">\"Basemap\"<\/span>,basemap,<span class=\"string\">\"Terrain\"<\/span>,<span class=\"string\">\"none\"<\/span>,<span class=\"string\">\"NextPlot\"<\/span>,<span class=\"string\">\"add\"<\/span>);\r\nh = 1;\r\ngeoplot3(g,lat,lon,h,<span class=\"string\">\"Color\"<\/span>,<span class=\"string\">\"k\"<\/span>,<span class=\"string\">\"LineWidth\"<\/span>,2,<span class=\"string\">\"HeightReference\"<\/span>,<span class=\"string\">\"terrain\"<\/span>);\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/globe_2.png\" alt=\"\"> <\/p><h4>Navigate to San Andreas Lake<a name=\"2288a3dc-919f-4eb9-b2d6-cdfe4d70431c\"><\/a><\/h4><p>According to <a href=\"https:\/\/en.wikipedia.org\/wiki\/San_Andreas_Fault\">wikipedia<\/a>:<\/p><pre>The fault was identified in 1895 by Professor Andrew Lawson of UC Berkeley,\r\nwho discovered the northern zone. It is often described as having been named\r\nafter San Andreas Lake, a small body of water that was formed in a valley\r\nbetween the two plates. However, according to some of his reports from 1895\r\nand 1908, Lawson actually named it after the surrounding San Andreas Valley.<\/pre><p>The USGS basemap contains topographic information and placenames. The San Andreas Lake is near the San Francisco International Airport. Use the mouse to navigate to this region.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/globe_3.png\" alt=\"\"> <\/p><h4>View San Andreas Fault in 3-D<a name=\"9eb38910-9aa9-4900-b057-a9fb2966fb49\"><\/a><\/h4><p>The globe was constructed with the <tt>Terrain<\/tt> property set to <tt>\"none\"<\/tt>. To view the San Andreas fault line in 3-D, set <tt>Terrain<\/tt> to <tt>\"gmted2010\"<\/tt> to use the  Global Multi-resolution Terrain Elevation Data (GMTED2010). This dataset has a spatial resolution of 250 meters. Use the mouse to move and rotate the globe. Use the middle click plus drag or control plus left\/right click plus drag to rotate the view.<\/p><pre class=\"language-matlab\">g.Terrain = <span class=\"string\">\"gmted2010\"<\/span>;\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/globe_4.png\" alt=\"\"> <\/p><h4>Add use of Custom Terrain from the USGS Earth Explorer<a name=\"751bc02d-96e9-4118-b0f0-db0a46253fa0\"><\/a><\/h4><p>The globe supports use of custom terrain data in DTED format. DTED files can be obtained from the USGS Earth Explorer at <a href=\"https:\/\/earthexplorer.usgs.gov\">https:\/\/earthexplorer.usgs.gov<\/a>. Select your region using the map, select \"Data Sets\", \"Digital Elevation\", \"SRTM\", and then \"SRTM Void Filled\". The region selected covers San Francisco. The spatial resolution of DTED level-2 data is 30 meters, significantly better than the 250 meters resolution of GMTED2010. By using custom terrain, you can see greater detail and it minimizes obstruction of the view of the fault lines.<\/p><p>Use <tt>addCustomTerrain<\/tt> to add use of the custom terrain data. You only need to add use of custom terrain data once.<\/p><pre class=\"language-matlab\">customTerrain = <span class=\"string\">\"sanfrancisco\"<\/span>;\r\ndtedfile = <span class=\"string\">\"n37_w123_1arc_v2.dt2\"<\/span>;\r\naddCustomTerrain(customTerrain,dtedfile)\r\n<\/pre><p>View the region using the custom terrain. Notice the greater level of detail.<\/p><pre class=\"language-matlab\">g.Terrain = customTerrain;\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/globe_5.png\" alt=\"\"> <\/p><p>When finished, you can remove use of the custom basemap and custom terrain by using the functions <tt>removeCustomBasemap<\/tt> and <tt>removeCustomTerrain<\/tt>.<\/p><pre class=\"language-matlab\">removeCustomBasemap(basemap)\r\nremoveCustomTerrain(customTerrain)\r\n<\/pre><h4>Conclusion<a name=\"9c4c82be-13e7-4637-ae19-9a48cafc5e4e\"><\/a><\/h4><p>This post provides an introduction on how to plot fault lines on a 2-D geographic axes and on a 3-D geographic globe. How might you use these tools in your work? Do you have data to view in 3-D?  What additional features would you like to see developed for the geographic globe?<\/p><p>Let us know <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=3761#respond\">here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_fb2f21c6353845098be730fbc2495395() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='fb2f21c6353845098be730fbc2495395 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' fb2f21c6353845098be730fbc2495395';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2020 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_fb2f21c6353845098be730fbc2495395()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2020a<br><\/p><\/div><!--\r\nfb2f21c6353845098be730fbc2495395 ##### SOURCE BEGIN #####\r\n%% Displaying Fault Lines on a Geographic Globe using Mapping Toolbox\r\n%\r\n% Guest blogger, Kelly Luetkemeyer, who is a senior software developer at\r\n% MathWorks, returns with an article on displaying fault lines on a geographic globe.\r\n% Kelly's previous articles included\r\n% <http:\/\/blogs.mathworks.com\/loren\/2011\/01\/20\/tracking-a-hurricane-using-web-map-service-wms\/\r\n% Tracking a Hurricane using Web Map Service>, \r\n% <http:\/\/blogs.mathworks.com\/loren\/2010\/05\/06\/oilslick\/ \r\n% Visualizing the Gulf of Mexico Oil Slick using Web Map Service> and \r\n% <https:\/\/blogs.mathworks.com\/loren\/2014\/12\/31\/using-restful-web-service-interface-in-r2014b-matlab\/\r\n% Using RESTful Web Service Interface in R2014b MATLAB>.\r\n\r\n%% Introduction\r\n% In R2020a, Mapping Toolbox introduced six new features for displaying\r\n% data on a geographic globe.\r\n\r\n%%\r\n% \r\n% * <https:\/\/www.mathworks.com\/help\/map\/ref\/geoglobe.html geoglobe> - Create geographic globe\r\n% * <https:\/\/www.mathworks.com\/help\/map\/ref\/geoplot3.html geoplot3> - Geographic globe plot\r\n% * <https:\/\/www.mathworks.com\/help\/map\/ref\/addcustombasemap.html addCustomBasemap> - Add use of custom basemap data on globe\r\n% * <https:\/\/www.mathworks.com\/help\/map\/ref\/addcustomterrain.html addCustomTerrain> - Add use of custom terrain data on globe\r\n% * <https:\/\/www.mathworks.com\/help\/map\/ref\/removecustombasemap.html removeCustomBasemap> - Remove use of custom basemap data on globe\r\n% * <https:\/\/www.mathworks.com\/help\/map\/ref\/removecustomterrain.html removeCustomTerrain> - Remove use of custom terrain data on globe\r\n%\r\n% This blog post illustrates how to plot fault lines on a 2-D geographic\r\n% axes and a 3-D geographic globe. In geology, a fault is a fracture or\r\n% discontinuity in a volume of rock and faults are one of the most\r\n% important global geological hazards. Fault lines are plotted on a high\r\n% zoom-level basemap hosted by Esri\u00ae and a custom basemap and custom\r\n% terrain data from the United States Geological Survey (USGS).\r\n\r\n%% Obtain Shapefile of Fault Lines from the United States Geological Survey\r\n% A shapefile of fault lines from the western United States can be obtained\r\n% from https:\/\/earthquake.usgs.gov\/static\/lfs\/nshm\/qfaults\/Qfaults_GIS.zip\r\n%\r\n% Download and unzip the file. The shapefile is located in the folder:\r\n% |\"GIS Files\/Shapefile\"|.\r\n\r\n%% Read Fault Lines Data from Shapefile \r\n% Read the geographic data from the shapefile and convert to a geoshape\r\n% vector for ease of use.\r\nfolder = \"GIS Files\/Shapefile\";\r\nshapefile = \"QFaults.shp\";\r\nfilename = fullfile(folder, shapefile);\r\nfaults = shaperead(filename,\"UseGeoCoords\",true);\r\nfaults = geoshape(faults);\r\n\r\n%% \r\n% Examine the number of elements and display the first element.\r\nnumberOfFaults = length(faults)\r\nfirstElenent = faults(1)\r\n\r\n%%\r\n% Find the number of unique locations.\r\nnumLocations = string(unique(faults.Location))'\r\n\r\n%% Find Faults of Interest\r\n% Due to the size of the data, reduce the number of faults by finding\r\n% faults that have a shape length greater than 10,000.\r\ncutoffLength = 10000;\r\ndata = faults(faults.Shape_Leng > cutoffLength);\r\nlat = data.Latitude;\r\nlon = data.Longitude;\r\n\r\n%% Display Fault Lines using Geographic Axes\r\n% Display the fault lines on a 2-D map. Construct a geographic axes using\r\n% |geoaxes| and plot the data using |geoplot|. The geographic axes supports\r\n% eleven different basemaps. The use of \"darkmode\" is popular in many\r\n% applications. For visual contrast, select the \"darkmode\" (|streets-dark|)\r\n% basemap. For a contrasting visual effect, display state boundaries in\r\n% white. Read the state boundaries using |shaperead|.\r\nstates = shaperead(\"usastatelo.shp\",\"UseGeo\",true);\r\nstates = geoshape(states);\r\nbasemap = \"streets-dark\";\r\n\r\n%%\r\nfigure\r\ngx = geoaxes(\"Basemap\",basemap,\"NextPlot\",\"add\");\r\ngeoplot(gx,lat,lon,\"LineWidth\",2)\r\ngeoplot(gx,states.Latitude,states.Longitude,\"w\")\r\n\r\n%% Display Fault Lines using Geographic Globe\r\n% Display the fault lines on 3-D globe. 3-D visualizations with terrain\r\n% provide more context for fault lines. The 2-D map is in a Web Mercator\r\n% coordinate projection system which causes a scale distortion. Construct a\r\n% geographic globe using |geoglobe| and plot the data using |geoplot3|. The\r\n% fault lines contain many different segments, not one continuous line.\r\n\r\n%%\r\n%   uif2 = uifigure;\r\n%   g = geoglobe(uif2,\"Basemap\",basemap,\"Terrain\",\"none\",\"NextPlot\",\"add\");\r\n%   geoplot3(g,lat,lon,[],\"LineWidth\",2)\r\n%   geoplot3(g,states.Latitude,states.Longitude,[],\"w\")\r\n\r\n%%\r\n% \r\n% <<globe_1.png>>\r\n% \r\n\r\n%% Find San Andreas Fault\r\n% The San Andreas fault is the most famous fault in the world and forms the\r\n% tectonic boundary between the North American Plate and the Pacific Plate.\r\n% The fault passes through California, a highly-populated state.\r\n\r\n%%\r\n% Search for the fault by using the |fault_name| property. Display the\r\n% first element of the geoshape vector.\r\nfault_name = \"San Andreas\";\r\nindex = contains(faults.fault_name,fault_name,\"IgnoreCase\",true);\r\nsan_andreas = faults(index);\r\nlat = san_andreas.Latitude;\r\nlon = san_andreas.Longitude;\r\nfirstElement = san_andreas(1)\r\n\r\n%% Add use of Custom Basemap from the USGS National Map\r\n% Geographic axes and geographic globe support custom basemaps. The USGS\r\n% Shaded Topographic Map is a nice map for visualizing geophysical data.\r\n% Use |addCustomBasemap| to add use of this map in |geoaxes| and\r\n% |geoglobe|.\r\nbasemap = \"usgstopo\";\r\nbaseURL = \"https:\/\/basemap.nationalmap.gov\/ArcGIS\/rest\/services\";\r\nurl = baseURL + \"\/USGSTopo\/MapServer\/tile\/${z}\/${y}\/${x}\";\r\nattribution = \"Credit: U.S. Geological Survey\";\r\ndisplayName = \"USGS Shaded Topographic Map\" ;\r\nmaxZoomLevel = 16;\r\naddCustomBasemap(basemap,url,\"Attribution\",attribution, ...\r\n    \"DisplayName\",displayName,\"MaxZoomLevel\",maxZoomLevel)\r\n\r\n%% Display San Andreas Fault on USGS Basemap using Geographic Axes\r\n% Specify the USGS basemap by setting |Basemap| to the custom basemap name.\r\nfigure\r\ngx = geoaxes(\"Basemap\",basemap,\"NextPlot\",\"add\");\r\ngeoplot(gx,lat,lon,\"LineWidth\",2,\"Color\",\"k\")\r\n\r\n%% Display San Andreas Fault on USGS Basemap using Geographic Globe\r\n% Display the San Andreas fault line on a geographic globe. Specify the\r\n% USGS basemap by setting |Basemap| to the custom basemap name. Specify no\r\n% terrain and set the elevation of the fault line to one meter above the\r\n% terrain.\r\n\r\n%%\r\n%   uif1 = uifigure;\r\n%   g = geoglobe(uif1,\"Basemap\",basemap,\"Terrain\",\"none\",\"NextPlot\",\"add\");\r\n%   h = 1;\r\n%   geoplot3(g,lat,lon,h,\"Color\",\"k\",\"LineWidth\",2,\"HeightReference\",\"terrain\");\r\n\r\n%%\r\n% \r\n% <<globe_2.png>>\r\n% \r\n\r\n%% Navigate to San Andreas Lake\r\n% According to <https:\/\/en.wikipedia.org\/wiki\/San_Andreas_Fault wikipedia>: \r\n% \r\n\r\n%%\r\n%\r\n%  The fault was identified in 1895 by Professor Andrew Lawson of UC Berkeley, \r\n%  who discovered the northern zone. It is often described as having been named \r\n%  after San Andreas Lake, a small body of water that was formed in a valley \r\n%  between the two plates. However, according to some of his reports from 1895 \r\n%  and 1908, Lawson actually named it after the surrounding San Andreas Valley.\r\n\r\n%%\r\n% The USGS basemap contains topographic information and placenames. The San\r\n% Andreas Lake is near the San Francisco International Airport. Use the\r\n% mouse to navigate to this region.\r\n\r\n%%\r\n% \r\n% <<globe_3.png>>\r\n% \r\n\r\n%% View San Andreas Fault in 3-D\r\n% The globe was constructed with the |Terrain| property set to |\"none\"|. To\r\n% view the San Andreas fault line in 3-D, set |Terrain| to |\"gmted2010\"| to\r\n% use the  Global Multi-resolution Terrain Elevation Data (GMTED2010). This\r\n% dataset has a spatial resolution of 250 meters. Use the mouse to move and\r\n% rotate the globe. Use the middle click plus drag or control plus\r\n% left\/right click plus drag to rotate the view.\r\n\r\n%%\r\n%   g.Terrain = \"gmted2010\";\r\n\r\n%%\r\n% \r\n% <<globe_4.png>>\r\n% \r\n\r\n%% Add use of Custom Terrain from the USGS Earth Explorer\r\n% The globe supports use of custom terrain data in DTED format. DTED files\r\n% can be obtained from the USGS Earth Explorer at\r\n% https:\/\/earthexplorer.usgs.gov. Select your region using the map, select\r\n% \"Data Sets\", \"Digital Elevation\", \"SRTM\", and then \"SRTM Void Filled\".\r\n% The region selected covers San Francisco. The spatial resolution of DTED\r\n% level-2 data is 30 meters, significantly better than the 250 meters\r\n% resolution of GMTED2010. By using custom terrain, you can see greater\r\n% detail and it minimizes obstruction of the view of the fault lines.\r\n\r\n%%\r\n% Use |addCustomTerrain| to add use of the custom terrain data. You only\r\n% need to add use of custom terrain data once.\r\n\r\n%%\r\n%   customTerrain = \"sanfrancisco\";\r\n%   dtedfile = \"n37_w123_1arc_v2.dt2\";\r\n%   addCustomTerrain(customTerrain,dtedfile)\r\n\r\n%%\r\n% View the region using the custom terrain. Notice the greater level of\r\n% detail.\r\n\r\n%%\r\n%   g.Terrain = customTerrain;\r\n\r\n%%\r\n% \r\n% <<globe_5.png>>\r\n% \r\n\r\n%%\r\n% When finished, you can remove use of the custom basemap and custom terrain by using the\r\n% functions |removeCustomBasemap| and |removeCustomTerrain|.\r\n\r\n%%\r\n%   removeCustomBasemap(basemap)\r\n%   removeCustomTerrain(customTerrain)\r\n\r\n%% Conclusion\r\n% This post provides an introduction on how to plot fault lines on a 2-D\r\n% geographic axes and on a 3-D geographic globe. How might you use these\r\n% tools in your work? Do you have data to view in 3-D?  What additional\r\n% features would you like to see developed for the geographic globe?\r\n%\r\n% Let us know <https:\/\/blogs.mathworks.com\/loren\/?p=3761#respond here>.\r\n\r\n\r\n##### SOURCE END ##### fb2f21c6353845098be730fbc2495395\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/2020\/globe_5.png\" onError=\"this.style.display ='none';\" \/><\/div><!--introduction--><p>Guest blogger, Kelly Luetkemeyer, who is a senior software developer at MathWorks, returns with an article on displaying fault lines on a geographic globe. Kelly's previous articles included <a href=\"http:\/\/blogs.mathworks.com\/loren\/2011\/01\/20\/tracking-a-hurricane-using-web-map-service-wms\/\">Tracking a Hurricane using Web Map Service<\/a>, <a href=\"http:\/\/blogs.mathworks.com\/loren\/2010\/05\/06\/oilslick\/\">Visualizing the Gulf of Mexico Oil Slick using Web Map Service<\/a> and <a href=\"https:\/\/blogs.mathworks.com\/loren\/2014\/12\/31\/using-restful-web-service-interface-in-r2014b-matlab\/\">Using RESTful Web Service Interface in R2014b MATLAB<\/a>.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2020\/07\/15\/displaying-fault-lines-on-a-geographic-globe-using-mapping-toolbox\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[41,6],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/3761"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=3761"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/3761\/revisions"}],"predecessor-version":[{"id":3765,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/3761\/revisions\/3765"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=3761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=3761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=3761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}