By Kenneth Field, Esri Research Cartographer
In many industries, simple geometric shapes such as squares and circles do not adequately represent objects. Some phenomena are just more complicated and require alternative approaches to represent them meaningfully. We had a question on Ask a Cartographer recently about creating pie segment shapes as features to support a requirement in the telecommunications industry. The geometry of the feature needed to represent the signal emitted from a cellphone mast. This sort of geometry cannot be built out of the box but by using Python we were able to build a custom Geoprocessing tool that could automate the process and build the features required. In this blog entry we explain why a pie segment better represents a cellphone signal, how they were constructed and what data are needed to run the tool. We also share the Geoprocessing tool so that others with this requirement can make similar maps.
A cellphone signal is transmitted from a mast (a central point); in a particular direction (orientation); across a defined area (spread); and for a specific distance (extent). Figure 1 illustrates the principles involved and shows how the segment can be described by its bearing (to give orientation), angle (to give spread) and radius (to give extent of the signal’s reach).
Figure 1. Principles of pie sector feature geometry
The pie sector is part of an ellipse which has an x, y origin at its centre. The center points are defined by longitude and latitude values in a geographic coordinate system. Although longitude and latitude locate exact positions on the surface of the globe, they do not provide uniform units of measurement for length and distance because the earth is not a perfect sphere. Only along the equator does the distance represented by one degree of longitude approximate the distance represented by one degree of latitude.
Instead of basing calculations on a spherical earth shape, we can use geodesic measurements to account for the inherent distortion of projected space on the non-spherical shape. Geodesic features are particularly useful when performing analysis for features that are more dispersed and span large distances (where distortions increase in orders of magnitude). This also explains why, in figure 1, we have an ellipse rather than a perfect circle since it is a geodesic buffer about an x, y origin with a uniform radius length throughout.
The direction of the centerline of the pie sector (blue dashed line in figure 1) is defined by the bearing (or azimuth) from North and is measured in degrees. The centerline is also the radius of the circle from which the pie sector forms a part. The radius determines the distance from the longitude, latitude (x, y) origin to the outer edge of the arc to model the extent of the cellphone signal’s reach. Two radii will form the straight edges of the pie sector (solid blue lines in figure 1). Because the cellphone transmitter is directional, the segment has a sector angle of opening that establishes the spread of the signal and so, the position of the two radii that form the extent of the pie sector. Figure 2 illustrates how this data might appear in a table as a set of input data that defines the features.
Figure 2. Tabulated data for cellphone pie sector features
Since ArcGIS doesn’t contain a Geoprocessing tool that can build these sort of features, the starting point to building a new tool is exploring what already exists and then determining if the current tools contains functionality that can be used as a basis for a new tool. There are several tools that work with geodesic measurement e.g. Construct Geodetic , Bearing Distance To Line, Table To Ellipse, and XY To Line.
Using the functions that already exist in these tools and the tabulated data that define the cellphone signals it is possible to construct geodesic buffers about an x, y origin, calculate the bearing of the sector, define the points on the buffer line that mark the end points of the two enclosing radii, build the line features to connect the buffer edge to the origin, build polygon features and then select the pie sector.
The tool is scripted in Python to automate the various stages in the process of feature geometry creation. The tool is built for ArcGIS v10.0 Service Pack 2 and will not work on previous versions of ArcGIS. It functions only at the ArcInfo license level since it uses the XY To Line tool that is only available at that level.
To run the tool, first download the zip file from the Models and Scripts Resources page on Mapping Center and then save it in a suitable location on your hard drive. This does not have to be a particular directory but should be somewhere you can access and which is likely to remain. In a new ArcMap Document, open ArcCatalog and then navigate to the Sector toolbox and open it to see the Geodesic Sector tool (figure 3). Whilst this blog entry is not designed to step through the code for the tool, the tool itself contains full documentation and comments to enable users to follow its operation (and modify if necessary). If you wish, you can explore the code structure and see how it calculates and creates the pie sectors by right clicking the tool in Catalog and selecting Edit.
Figure 3. Opening the Sector Analysis tool in ArcCatalog
Before running the tool, check that you are not running background processing. The tool requires processing to be run in the foreground which can be controlled by clicking Geoprocessing > Geoprocessing Options on the Standard toolbar.
To run the Geodesic Sector tool, double click the tool to launch a dialog box where you input the model parameters (figure 4). The input file needs to be in dBase format (.dbf). The output will be a polygon feature class so be sure to provide a suitable name in a file geodatabase. The remaining parameters can be completed by selecting from dropdowns that reflect the field names in your attribute table.
Figure 4. Populating the geodesic pie sector tool parameters
Figure 5 illustrates the different stages of the construction of the pie sectors that goes on behind the scenes in ArcGIS. The data created as part of the interim steps are deleted from the geodatabase once the tool has finished running but they can be retained by removing the relevant commented out section in the code if required. Instructions for this are included in the code itself.
Figure 5. Stages in constructing geodesic pie sectors
Figure 5a shows the construction of the geodesic buffers about the longitude and latitude using the Table to Ellipse functions. The next step creates radii lines that delineate each sector (shown here in blue) and also the centre line (shown here in red) using Bearing Distance to Linefunctions (figure 5b). The geodesic buffers and the sector lines are then merged into one polygon using Feature to Polygon functions (figure 5c). Finally, only those polygons that are intersected by the previously created center lines are selected and then exported as the final pie sector feature class (figure 5d). Temporary files are deleted and the pie sector feature class is added to the Table of Contents. Figure 6 illustrates the results of running the tool on our test data to create seven pie sectors of varying dimensions.
Figure 6. Pie sector polygon features
The geodesic pie sector tool developed to create the pie sector features only creates the basic two-dimensional shape of the direction and spread of a cellphone signal. It’s sufficient for many mapping tasks. To model the physics involved in the way in which the signals move through three dimensional space would require further modelling to show the z dimension and signal modulation. However, the pie sector tool gives you a starting point from which to model the more complex structure of the cellphone signal.
Thanks to Linda Beale, Geoprocessing Product Engineer, for building the model and developing the tool.
Postscript: In testing this tool it became apparent that some computers stored their Python libraries in alternate locations. In order for this (and other Python scripted tools) to work, it is important that you set a PYTHONPATH Environment variable in your Computer System settings. To check your Environment variables, right-click on My Computer and choose Properties, and then go to Advanced System Settings, select the Advanced tab and then click the Environment Variables button (at the bottom right). Does the PYTHONPATH Environment variable exist?
If not, click New and create a PYTHONPATH environment variable and point it to c:python26ArcGIS10.0lib. Click OK twice, close the remaining dialog boxes and then reboot your machine and you should be all set.