Showing posts with label ArcMap. Show all posts
Showing posts with label ArcMap. Show all posts

Friday, December 14, 2012

Global Lake Stress Analysis: Integrating ArcMap and Google Earth



This is an ongoing project, and the results will be published upon its completion. As a result, no GIS results are discussed.

This project requires viewing lakes on imageries provided by Google, Esri and Microsoft Bing for stress analysis. Esri and Bing imageries can be added directly to ArcMap as basemap layers. Basin and lakes layers can be added to ArcMap, thus these lakes can be visually inspected against the backdrop of Esri and Bing basemaps. This way while working in  ArcMap, we can inspect each lake feature by zooming in and analyzing them in context of imageries basemap. Note that even this way, Bing maps take rather longer time to display. This could be probably because Bing maps zoom to predefined resolution levels seen as notches on the zoom scale, but ArcMap can zoom to any arbitrary scale of resolution so it resamples to the resolution of display causing delays in rendering. 

Unfortunately, Google imageries cannot be added as another basemap layer to ArcMap. So, an alternative method is needed to inspect lakes on Google imageries. One of the methods is to launch Google Earth, and then enter coordinates (latitude, longitude) of the lake and then zoom to that location. To do this for thousands of lakes is cumbersome, and error prone. A better approach is needed. I was able to find a script at esri’s website supplied by third party for free that tries to address this situation. The tool is available at URL http://arcscripts.esri.com/details.asp?dbid=16083. It was written for earlier versions of ArcGIS, so I modified it to run on ArcGIS 10. 

The goal is to execute some JavaScript function embedded inside an HTML page hosted by Internet Browser from a VBA application. This is similar to the following scenario. Imagine that we have a button on the HTML page which is attached to a JavaScript function which gets activated when the button is clicked. We have a VBA application that we want to use to launch the HTML page in Internet Explorer, and then click on the button from the VBA code automatically. That is, the button on the HTML page got clicked as if a user was doing it, but in reality it is performed by the VBA code written for a User Interface (UI) tool in ArcMap. How do we do it? The following code sample demonstrates it.



JavaScript Code in HTML Page:
<input type = "button" value="Button on HTML Page" onclick="javascript: MyFunction('MyValue');">
VBA Code for ArcMap UI tool
In the VBA code, insert the following line wherever you want to  click on the button. The Document object can be obtained from Internet Explorer Application object.
IE = CreateObject(“InternetExplorer.Application”)
Document = IE.Document
Call Document.parentWindow.execScript("MyFunction ('MyValue');")

In this study, we use this approach except that we do not have a button, but instead we have a map refresh event to which we will attach the code. As explained, the basic idea is to make use of the fact that we can launch a piece of code (script) written in JavaScript that is part of a HTML page running in an independent web browser from ArcMap. The code in ArcMap is written in VBA (Visual Basic for Applications), and it is attached to the map extent change event. Thus, every time the map extent changes, such as triggered by zoom action, the VBA code in ArcMap passes the map extent coordinates to javascript (that is actually a part of an HTML page). The web browser showing the HTML page executes the JavaScript code to launch Google Earth and zooms to the passed map extent. Thus, we can keep ArcMap and a web browser applications running side by side on separate computer monitors, and can view features such as lake and basins in ArcMap and Google Earth (in a web browser) simultaneously. This approach prevents ArcMap from getting overwhelmed with basemap displays (such as Bing), and is very fast and efficient. It also offers an efficient way to compare imageries from Bing and Google side by side. 




This approach requires Google Earth installed on the computer. ArcGIS 10 was used in this study, and it requires VBA (Visual Basic for Applications) license activated. The VBA license is not active at ArcGIS 10 by default, but it is available for free from Esri. The VBA code for ArcMap, and HTML page with JavaScript code is shown below. As discussed above, the KML files for lakes are not published because they are part of an ongoing research.

It has the a HTML and VBA file. Download both the files in a zipped file. Extract the HTML file and copy it to the disk. Open the VBA code in Notepad, and edit to change the location of HTML file to point to the location where you copied it. Look for the function UIToolControl1_Select in VBA code, and edit the following line  to reflect the location of HTML file on disk. This is where in VBA you need to make changes:

Private Sub UIToolControl1_Select() ' this is the function
m_pIE.navigate2 "file://C:\Users\Desktop\GE_ArcGIS\test\SalineLakes.htm"

-------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <head>
<!--
Copyright 2008 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
    <title>Hello Google Earth!</title>
    <!-- *** Replace the key below below with your own API key, available at http://code.google.com/apis/maps/signup.html *** -->
<script src="http://www.google.com/jsapi?key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw"></script>  
  
    <script>
google.load("earth", "1");
var ge = null;
function init() {
  google.earth.createInstance("map3d", initCallback, failureCallback);
}

    function initCallback(object) {
      ge = object;
      ge.getWindow().setVisibility(true);
      ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);

      var link = ge.createLink('');
      var href = 'https://sites.../SelectedLakes.kmz'  //lakes
      link.setHref(href);

      var networkLink = ge.createNetworkLink('');
      networkLink.set(link, true, false); // Sets the link, refreshVisibility, and flyToView

      ge.getFeatures().appendChild(networkLink);

      link = ge.createLink('');
      href = 'https://sites..../SelectedBasins.kmz' //basin
      link.setHref(href);

      networkLink = ge.createNetworkLink('');
      networkLink.set(link, true, false); // Sets the link, refreshVisibility, and flyToView

      ge.getFeatures().appendChild(networkLink);


    }

function ZoomTo(lon,lat,z)
{

    var cam = ge.getView().copyAsCamera(ge.ALTITUDE_ABSOLUTE);
          cam.setLongitude(lon);
         cam.setLatitude(lat);
         cam.setAltitude(z)
         ge.getView().setAbstractView(cam);
         }
 
 function query()
 {
   var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);     var cam = ge.getView().copyAsCamera(ge.ALTITUDE_ABSOLUTE);
   alert(cam.getAltitude())
 
 }
 

function failureCallback(object) {
}
    </script>
  </head>
  <body onload='init()' id='body'>
    <center>
      <div>
        Assessing Lakes, UCLA
      </div>
        <div id='map3d' style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;"></div>

          
         
    </center>
  </body>
</html>

--------------------------------------------------------------
Users will need to built an ArcMap UI tool and attach the VBA code shown below.
'VBA Code for Macro in ArcMap

Private WithEvents m_pMap As Map

Private m_pIE As Object

Private Sub m_pMap_ViewRefreshed(ByVal view As esriCarto.IActiveView, ByVal

phase As esriCarto.esriViewDrawPhase, ByVal Data As Variant, ByVal envelope As

esriGeometry.IEnvelope)

On Error GoTo EH

Dim pPoint As IPoint

Set pPoint = New Point

pPoint.X = (view.Extent.XMax + view.Extent.XMin) / 2

pPoint.Y = (view.Extent.YMax + view.Extent.YMin) / 2

Dim lat As Double

Dim lon As Double

Dim pMxDoc As IMxDocument

Set pMxDoc = ThisDocument

PointToLatLon pMxDoc, pPoint, lat, lon

Dim n As Double

n = Round(pMxDoc.FocusMap.MapScale) / 5.82

m_pIE.Document.parentWindow.execScript "ZoomTo(" & lat & "," & lon & "," & n

& ");", "javascript"

Exit Sub

EH:

Debug.Print "Error: " & Err.Description

End Sub

Function PointToLatLon(pMxDocument As IMxDocument, ByVal pPoint As IPoint, ByRef

dLatitude As Double, ByRef dLongitude As Double)

On Error GoTo EH:

' variables for dealing with projections and units

Dim pSpRefOutput As esriGeometry.ISpatialReference

Dim pSpRefInput As esriGeometry.ISpatialReference

' set the spatial reference of output KML data

Dim pSpRFc As esriGeometry.SpatialReferenceEnvironment

Dim pGCS As esriGeometry.IGeographicCoordinateSystem

Set pSpRFc = New esriGeometry.SpatialReferenceEnvironment

Set pGCS = pSpRFc.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984)

Set pSpRefOutput = pGCS

pSpRefOutput.SetFalseOriginAndUnits -180, -90, 1000000

Dim pGeometry2 As IGeometry2

Set pGeometry2 = pPoint

Set pSpRefInput = pMxDocument.FocusMap.SpatialReference

' project feature into latitude/longtitude if necessary

Set pGeometry2.SpatialReference = pSpRefInput

pGeometry2.Project pSpRefOutput

Dim pNewPoint As IPoint

Set pNewPoint = pGeometry2

dLatitude = pNewPoint.X

dLongitude = pNewPoint.Y

Exit Function

EH:

Debug.Print "Error: " & Err.Description

End Function

Private Sub UIToolControl1_Select()

On Error GoTo EH:

Dim pMxDoc As IMxDocument

Set pMxDoc = ThisDocument

Set m_pMap = pMxDoc.FocusMap

Set m_pIE = CreateObject("InternetExplorer.Application")

m_pIE.Visible = True

m_pIE.navigate2 "file://C:\Users\Desktop\GE_ArcGIS\test\Ge.htm"

Exit Sub

EH:

Debug.Print "Error: " & Err.Description

End Sub

Friday, August 3, 2012

Cartography - Make Map of Water Systems in California

I created this map using basic feature data available from public domain sources. California Aqueduct and Colorado Aquaduct are the main sources of water to Southern California.





This is Online map viewer for the map produced in ArcMap showing water resources of California. The legend is shown on the right pane. The map is cached, which allows faster navigation of map. The map was cached after publishing the map service on ArcGIS server.


This map shows the basemap option that the user can select. It also shows a zoomed in view showing streams and channels not visible at larger scales.



This view of map shows the San Francisco Bay and rivers flowing into it.


Tuesday, May 1, 2012

Suitability Analysis of Potential Sites for UCLA Satellite Campus


The goal of the this project is to identify suitable sites for the development of a satellite campus of UCLA. THe UCLA campus is planning to enroll more students, and there is a need to accommodate those students in a new facility because the current campus will not be adequate for all future students.

There are a number of factors that affect the suitability analysis. It has to be located within the inland areas of Los Angeles county. The satellite campus should be accessible to the faculty and students, so it should be close to road network such as freeways, but should not be very close to it to minimize noise pollution. In addition, the slope of the land should be mild, because steep slopes are not stable locations for constructing new buildings, so safety may be compromised by steep slopes. The satellite campus should be close to urban areas, so we can take advantage of its well developed amenities and accessibility. The site should be vacant, of possible, other additional asset acquisition costs will apply. Finally, the site should be close to existing colleges and universities to enable interactions with academics at the satellite campus.

Following data is required for analysis of suitable sites. Digital Elevation Model data (DEM) was downloaded from USGS seamless server. In addition, land use shapefile, urbanized area shapefile, freeway shapefile, college and university shapefile was downloaded from the Los Angeles County GIS Portal website. All layers were projected into UTM 11N coordinate system.

Since we are considering sites only in the inland area of Los Angeles county, the explosion geoprocessing tool was used on the Los Angeles shapefile to extract island features from the county feature. In the editor, these island features were selected and deleted. The saved Los Angeles shapefile now has only inland features, and it will be used for analysis.

The DEM raster layer was clipped to the shape of Los Angeles county by using the Extract By Mask geoprocessing tool. Urbanization, freeways, college and landuse shapefiles were also clipped to the shape of inland Los Angeles county using the geoprocessing tool.
Following data

The satellite campus is going to house about 5000 students only, so parcel area need not be large. But for the sake of future expansion, we should look for areas that have greater room for development.


To identify suitable sites with gentle gradient, a slope analysis was performed on the DEM. THe DEM was then reclassified into 10 categories using a geoprocessing tool where class value of 10 represents the best site with milder slopes, and 1 represents steep sites not suitable for development. A map of slope is shown in the document.

Similarly, land use layer was converted into a raster, and then reclassified into types with varying weights assigned to various land uses. Vacant sites have the highest weight and were classified with a value of 10, and existing industrial area have the lowest desirability and were classified with a value of 1. A map of land use shows various landuse types.

The college shapefile was buffered by 3 miles, and then converted to raster. This raster was reclassified with areas inside the buffer zone assigned a class value of 10, and areas outside the buffer zone as 1 representing less desirable sites from this point of view.


The  freeway  features  were  buffered  to  1  mile  and  2  mile.  This  resulted  in  two buffered freeway shapefiles. These two buffer layers were merged using the Merge geoprocessing tool, and then converted into a raster layer. The freeway buffer raster layer was then reclassified using the geoprocessing tool. Areas that were located closer than 1 mile was classified with a value of 1, because this area will be noisy. Areas around 2 miles from the freeway were the best sites and were classified with a value of 10. Other areas were classified as 5 representing areas of intermediate suitability.


Finally, to ensure that the new site is close to urban areas, the urban area was buffered by 5 miles and then converted to raster. This raster was reclassified with areas inside the buffer zone assigned a class value of 10, and areas outside the buffer zone as 1 representing less desirable sites from this point of view.


Thus, we have 5 criteria to use to compute the suitability of areas for a new campus. Slope was considered the most important factor influencing the selection. This was followed by land use type, proximity to road network, urban areas and colleges and universities. The following equation was used with weights assigned to each criteria to compute the suitability of each cell in the raster. A raster calculator was used to calculate the new suitability raster:

Cell Score = 1.0 * slope + (0.7 * land use type) + (0.5 × freeways) + (0.6 × colleges) + (0.5 × urbanized areas)


The resulting suitability raster map shows best and worst sites based on weights selected for the study. It should be noted that selection of different weights will generate a different raster showing different suitability scores for each cell in the raster. The


assignment of weights for each criteria in this study is based on my judgement, and may differ with analysts and other factors involved in decision making.

A general pattern is revealed by the suitability raster computed  using the equation above. The southern part of Los Angeles county is less suited as there is little room for new developments because this area is densely populated. On the other hand, northern areas are less densely populated and offer greater opportunities for new development. This is evident from the green colored cells in the northern areas, and more red colored cells in the southern areas.

I recommend 4 sites for satellite campus development. These areas are shown
in circles. The decision to select a particular site will depend upon factors that are considered important by the university. If the university wants to geographically expand the campus, areas in the northern side are better suited. If the university is more interested in catering to more students, potential sites that are located towards the south of LA county should be selected because they are more densely populated.








Tuesday, April 24, 2012

Location of Additional Cell Phone Towers in Los Angeles

In the 21st century, the cell phone has become an integral part of our daily lives. The economirecession did not slow down the growth of cell phone industry in America as a vast majority of the US population is using a mobile phone. The survey of wireless carriers revealed that over 285 million Americans are mobile subscribers, about 91 percent of the total population. (Foresman). The competition among cell phone companies to provide best cell reception to its consumers has fueled the building of cell phone towers in and around cities. We have seen massive telecommunications infrastructure spring into existence. Cell phone towers (that provide cellular signals) have grown in number to almost 2 million cell phone masts or antennas in the United States alone, hence it has become important for all the cell phone carrier to find prospective location to build their towers (Lloyd).

The location of cell phone towers is so  important that the Federal Communications Commission regulates cell towers, the towers thaprovide cellular signals so that consumers may use cell phones. The FCC has laws regardinwhere towers may be built and how they must be maintained. The agency also works in conjunction with the Federal Aviation Administration to ensure that towers do not present safetrisks for aircraft, therefore selecting the location for future cell towers has become quite challenging. In addition, cell phone users also give importance to the location of a cell towers because the reception of our cell phone depends of the location these towers. Even if we have the best cell phone on the market, poor carrier coverage can render it useless. Before we sign up for service, it is important to find out whether the cell phone carrier we are considering (Cingular, T-Mobile, Verizon, etc.) has good or poor coverage in a given area. As a result people do considethe location of cell phone towers of their current or prospective cell phone carrier while buyinor renting properties because they prefer to buy a house or rent an apartment where they can gebest cell reception. Every major wireless carrier now offers nationwide coverage, but that doesn'mean all telephone companies are created equal. It all depends on where the cell phone towers are located, and if carrier isn't invested in the particular area of our interest, we are going to find ourselves moaning throughout the course of your two-year service agreement. To provide best call reception to their customers, these companies compete fiercely with other companies when it comes to building a new cell phone towers. Therefore, the location of cell towers is crucial for all the cell phone companies to maintain their share of market. 

The location of these towers habecome a major issue of debate too, in negative way. Although Federal Food and DruAdministration asserts that these towers does not pose health risk to people living close to cell phone towers location, there are studies which proves otherwise. Prospective homebuyers avoid buying property next to cell towers. Communities are increasingly expressing concerns about aesthetic problems, property values associated with cell towers. Cell phone towers location is also important when it requires rechecking. York County, Pa., plans to verify the locations of more than 200 cell phone towers to ensure that 911 calls placed from mobile devices are accurately tracked” (Rich).

















Citation:
The FCC Cell Tower Regulations. Ehow.com. Web. 9 Apr. 2012.

of-americans-have-cell-phones.ars. Proc. of Wireless Survey: 91% of Americans Use Cell
Phones, Las Vegas. 2009. Web. 9 Apr. 2012.
Lloyd. "Cell Phone Towers The Invisible Danger." Http://e743/cell-phone-towers-the-invisible-
danger/. 11 July 2010. Web. 9 Apr. 2012.

Rich, Sarah. Government Technology, 25 July 2011. Web. 8 Apr. 2012.
Rechecking.html>.