# Geospatial Assessment of the Territorial Road Network by Fractal Method
## 3 The Main Research
### Results  
For geospatial assessment of the transport provision of territories, a geoprocessing tool was created: an autonomous Python script that allowed one to calculate the fractal dimension for vector geodata with a linear geometry type. ArcGIS contains a large library of geoprocessing tools for spatial modeling and the analysis of geographic data. The tools are grouped into toolboxes by the type of actions they perform (e.g., 3D Analyst, Spatial Analysis, and Cartography) [29; 30]. To provide access to all standard ArcGIS geoprocessing tools via Python code, the ArcPy library was imported. In addition, the NumPy and SciPy libraries were imported into the script, allowing the use of high-level mathematical functions with data arrays, including data linear approximation [31; 32]. Two inputs to the script were entered: a polygon shapefile with the administrative boundary of the study area and a polyline shapefile with the road network (Figure 3). In addition, it was necessary to indicate the area scale for fractal analysis (i.e., the area of one hexagon on the ground). When running the script using the GenerateTessellation() tool, a polygon shapefile (Hexagons.shp) was created with regular hexagons of a given area (Figure 4), which covered the study area and was then used to calculate the fractal dimension of the roads. The attribute table of this layer contained an ID column with a unique code for each hexagon object. Figure 3: Python script interface. Using the Intersect() tool, the intersection of linear objects of the Roads.shp road network with the Hexagons.shp hexagon layer was performed. According to these results, each section of the road was assigned the ID of the hexagon in which it was located. The combination of road sections belonging to one hexagon into a single object that had an ID that matched the hexagon ID was performed using the Dissolve() tool. The resulting polyline shapefile would then be used in a script called HexagonsDiss.shp. The calculation of the fractal dimension was carried out in a cycle for each polygonal object from the Hexagons.shp attribute table. In each iteration of the cycle, using the CreateFishnet() tool, a grid was constructed with the cell size \(\varepsilon\), and the number of squares N(\(\varepsilon\)) that covered all linear objects (roads) inside the current hexagon was calculated. Calculations of N(\(\varepsilon\)) were carried out for various values of \(\varepsilon\). There were five steps. Each hexagon was covered by a grid with 1, 4, 16, 64, and 256 squares, and the size of the square decreased by 1, 2, 4, 8, and 16 times, respectively (Figure 5). The calculation of the fractal dimension was carried out using linear approximation by the method of least squares. As an estimate of the fractal dimension, the slope value of the straight line was used. The following is a fragment of the program code for a script that calculates the coefficients \(\alpha\) and \(\beta\) of the linear function in Equation (10) using the least squares method:  
#Target function fitfunc = lambda p, x: (p[0] + p[1] * x)  
Figure 4: Hexagon polygon shapefile covering the study area. Figure 5: Steps for executing the box-counting method. #Distance to the target function errfunc = lambda p, x, y: (fiffunc(p, x) - y)
#Minimize the sum of squares of a set of equations; p1 = [\(\alpha\),\(\beta\)] p1_success = optimize.leastsq(errfunc, [0,0], args = (logx, logy))  
For the example shown in Figure 5, changes to N(\(\varepsilon\)) as a function of \(\varepsilon\) are given in Table 1. The regression line to estimate the fractal dimension is shown in Figure 6.  
After performing linear regression, an equation of the following form was obtained: ln(N(\(\varepsilon\))) = 0.1992 + 1.4852 ln(1/\(\varepsilon\)) + \(\Delta\). The slope of this curve is equal to the box-counting dimension d = 1.4852. Accordingly, the level of transport provision, in accordance with Equation (11), is equal to TP = 1.4852/2 = 0.7426.