?

Log in

No account? Create an account

OpenWebGIS is online Geographic Information System

Previous Entry Share Next Entry
Create fractals on the map by using OpenWebGIS
openwebgis
Fractal_OpenWebGIS_Julia_Set_TitleOpenWebGIS_fractal3D_2


The concepts of fractal and fractal geometry, which appeared in the late '70s, after the mid-80s have become part of everyday life of mathematicians and programmers. The word "fractal" comes from the Latin word "fractus" and is translated as "consisting of fragments". It was proposed by Benoit Mandelbrot in 1975 to refer to irregular, but self-similar structures, which he studied. The birth of fractal geometry is usually associated with the release in 1977 of the book by Mandelbrot `The Fractal Geometry of Nature '. In his works,the results of other scientists working in the period 1875-1925 years in the same field (Poincare, Fatou, Julia, Kantor, Hausdorff) were used . But only now it is possible to combine their works into a single system.

OpenWebGIS offers the new term: Geographic Fractal Art. The OpenWebGIS blog and full list of articles about OpenWebGIS provide a lot of new information about possibilities of OpenWebGIS. Create your own fractal maps and share them with friends. Fractals created with the help of OpenWebGIS may be interesting not only from esthetic and mathematic point of view but for example it may be used for automatic generating of large amounts of geographical data which have any spatial distribution and attribute value regularities. Then the data may be used for some processes modeling.

Each point of a fractal (Mandelbrot set and Julia sets), created with the help of OpenWebGIS has the geographic coordinates. This means that you can export the data to other GIS, statistical programs, etc. and study in detail the fractal set. So created fractal is not the image, but the geographic vector layer consisting of the points created with the help of OpenLayers.

You can Export the Fractal Layer to other GIS formats - gml, geojson, csv, kml. To do it, use menu item "Layers->Export Layer to ... format". Loot at Figure 1.
The fractal shown in Figure 1 can be named "Fractal Julia set over London" and has Formula: Zn+1=atan(Zn*Zn*Zn*Zn*Zn)*atan(Zn*Zn*Zn*Zn*Zn); Zn=0.38+0.0001*i; "i" is the imaginary unit; number of iteration=10
See interactive map of Fractal Julia set over London

OpenWebGIS_2d3dFractal1
Figure 1

The points have attributes: “iterationValue” - the total value of Z at the last iteration; “longitude”, “latitude” and “Time” - contingent date and time (measured from 1970.01.01) calculating the value of a point and applying it on the map - (The attribute “Time” can be used for the construction of fractal animation). In order to make a colorful fractal according to your taste, simply click on the word `legend` which is under the fractal layer name, then in the window that opens select the number of classes of the legend, select the field classification (iterationValue) and set the desired color for each class. To know about calculating of each point coordinates and
“iterationValue” and “Time” attributes, if you look at the JavaScript`s code part of OpenWebGIS:
[part of JavaScript code(click to open)]
var DELTA=parseFloat(document.getElementById("fractal_delta_id").value);//Decreasing this value increases the number of the points (less dense of the fractal) on the map
var CPS = 2;
var ArrayFeatures=[];
var MAX_ITERATIONS=parseInt(document.getElementById("fractal_iteration_id").value);

 for (var Re = -CPS; Re <= CPS; Re = Re + DELTA)
{ // Represents the Re-axis. Re is the real part of a complex c value.
next_c_value:
for (var Im = -CPS; Im <= CPS; Im = Im + DELTA)
{ // Represents the Im-axis. Im is the imaginary part of a complex c value.
if(document.getElementById("FractalsName_1").value=='Mandel')
{var Zre=0; var Zim=0;var Сre=Re; var Cim=Im;}
if(document.getElementById("FractalsName_1").value=='Julia')
{
var Zre=Re; var Zim=Im;var Сre=parseFloat(document.getElementById("id_pFracJul").value); var Cim=parseFloat(document.getElementById("id_qFracJul").value);
}

      var attr={};  var exponentialSmoothingSum = 0; var iteration=0;
      for (var iterationCount = 1; iterationCount <= MAX_ITERATIONS; iterationCount++)
 {    var phi=0;
if(Zre>0)
{var phi=Math.atan(Zim/Zre);
}
if(Zre==0&&Zim==0){var phi=0;}
if(Zre<0&&Zim>0)
{var phi=Math.PI+Math.atan(Zim/Zre);
}
if(Zre<0&&Zim<0)
{var phi=(-1)*Math.PI+Math.atan(Zim/Zre);
}
var ModulZ=Math.sqrt(Zre*Zre+Zim*Zim);
var dP=parseFloat(document.getElementById("id_dFracJul").value);
var phiRad=(dP*phi);
var SquareZre=Math.pow(ModulZ,dP)*(Math.cos(phiRad));
var SquareZim=Math.pow(ModulZ,dP)*(Math.sin(phiRad));
var ZaddRe=SquareZre+Сre;var ZaddIm=SquareZim+Cim;
if(document.getElementById("id_sFracJul")&&document.getElementById("id_sFracJul").value!=="0")
{
if(document.getElementById("id_sFracJul").value=="Math.cotan")
{ZaddRe=1/Math.tan(ZaddRe); ZaddIm=1/Math.tan(ZaddIm);}
else{
ZaddRe=eval(document.getElementById("id_sFracJul").value+"("+ZaddRe+")");ZaddIm=eval(document.getElementById("id_sFracJul").value+"("+ZaddIm+")");}
}
if(document.getElementById("id_sFracJul")&&document.getElementById("id_s2FracJul").value!=="0")
{
if(document.getElementById("id_s2FracJul").value=="Math.cotan")
{ZaddRe2=1/Math.tan(ZaddRe); ZaddIm=1/Math.tan(ZaddIm);}
else{
ZaddRe2=eval(document.getElementById("id_s2FracJul").value+"("+ZaddRe+")");ZaddIm2=eval(document.getElementById("id_s2FracJul").value+"("+ZaddIm+")");}
}
if(document.getElementById("id_sFracJul")&&document.getElementById("id_sFracJul").value!=="0"&&document.getElementById("id_s2FracJul").value!=="0")
{
ZaddRe=ZaddRe*ZaddRe2;ZaddIm=ZaddIm*ZaddIm2;
}
if(document.getElementById("id_sFracJul")&&document.getElementById("id_s3FracJul").value!=="0")
{ZaddRe=ZaddRe*ZaddRe;ZaddIm=ZaddIm*ZaddIm;}
Zre=ZaddRe;Zim=ZaddIm;
varZmodul=ZaddRe*ZaddRe+ZaddIm*ZaddRe;//mathematically correct expession should be like this: varZmodul=ZaddRe*ZaddRe+ZaddIm*ZaddIm, but also from a mathematical point of view, we can interrupt the iteration at any value so at this point in OpenWebGIS the iteration is terminated under the following condition. In this way, when the iterations are interrupted the fractals become much more interesting. Perhaps in future versions of OpenWebGIS user will be able to choose conditions by themselves.

  iteration+=(Zre*Zre + Zim*Zim)

if (varZmodul> 4)
{continue next_c_value;}
      }
attr.iterationValue=iteration;
if(iteration>MAX_ITERATIONS/4)
{
var PixelW=map.getPixelFromLonLat(new OpenLayers.LonLat(ext.right,ext.top));
var PixelH=map.getPixelFromLonLat(new OpenLayers.LonLat(ext.left,ext.bottom));

lat=((PixelH.y)*(2-Im))/4; // latitude of the point
lon=((PixelW.x)*(Re+2))/4; // longitude of the point

var lonlat=map.getLonLatFromPixel(new OpenLayers.Pixel(lon,lat));
var lon=lonlat.lon;
var lat=lonlat.lat;

var new_pos2=new OpenLayers.LonLat(lon,lat);

var new_pos22=new OpenLayers.LonLat(lon,lat).transform(map.getProjectionObject(),new OpenLayers.Projection("EPSG:4326"));
attr.longitude=new_pos22.lon;
attr.latitude=new_pos22.lat;
yii.setSeconds(yii.getSeconds()+1);
var monthNN=yii.getMonth()+1;if(monthNN<10){monthNN='0'+monthNN;}
var dayNN=yii.getDate(); if(dayNN<10){dayNN='0'+dayNN;}
var hoursNN=yii.getHours();if(hoursNN<10){hoursNN='0'+hoursNN;}
var minNN=yii.getMinutes();if(minNN<10){minNN='0'+minNN;}
var secNN=yii.getSeconds();if(secNN<10){secNN='0'+secNN;}
var Datert2=yii.getFullYear()+"-"+monthNN+'-'+dayNN+'T'+hoursNN+':'+minNN+':'+secNN;
attr.Time=Datert2;
points=new OpenLayers.Geometry.Point(new_pos2.lon, new_pos2.lat);
var first_point= new OpenLayers.Feature.Vector(points);
first_point.attributes=attr;
ArrayFeatures.push(first_point);}
         } // for
  } // for

In order to select the type of a fractal and to set the parameters of the calculation you need to select the OpenWebGIS menu  "Calculations->Fractals" (See Figure 2). In the figure Fractal Julia set is shown created using the formula: Zn+1=sin(Zn*Zn)*cos(Zn*Zn), where Zn=0.38+0.001*i
Fractal_OpenWebGIS_Julia_Set_sin_cos
Figure 2.

The legend created for data shown in the Figure above can be seen in the Figure below. Using standard opportunities of OpenWebGIS, you can change the layer legend with the information about attributes of Layer. To do this, click on the word "legend" under layer name (in this case, "Fractal" - but you can select any layer name), after that under the layer name will appear  the region on which you click to open the legend settings window.  Set parameters of legend in the appeared new window like in the Figure 3 (firstly set the number of classification equal to 4. Set values,colors and then click on the button "OK -update legend".

Fractal_OpenWebGIS_Julia_Set_sin_cos_legenda
Figure 3.

Fractal calculating and creating might take a lot of time and depending on parameters set by you there will be need to wait for a minute or five minutes or even more. The larger iteration quantity, the more time necessary for calculations. The decrease of "delta" parameter increases the points quantity  (the fractal becomes more dense and sightly), and that means it increases calculations time.
You can get all attributes value of each point of the fractal on the map. To do it select Layer’s name ‘Fractal’ in the dropdown list “Editable Layer”. Then click on the point you are interested in and you must get the result like in Figure 4. The values of all attributes of each point you can see by hovering the cursor over it and clicking on it (if while hovering over a polygon, it is not activated, then move the map a little bit and then again hover the cursor). See Figure 4.
Fractal_OpenWebGIS_Mandelbrot_Set
Figure 4.

You can also look at points attributes in the table. To do it, select the menu item "Edit-> Open attribute table" (see Figure 5) and in appeared new browser window specify the rows number in a table, then press the button "Open table".See Figure 5. In this Figure Fractal Julia set is shown created using the formula Zn+1=sin(Zn*Zn*Zn*Zn)*Zn*Zn*Zn*Zn, where Zn=0.71+0.001*i
Fractal_OpenWebGIS_Julia_Set_sin_table
Figure 5

You can also create a three-dimensional image of a fractal using the charting module available in the menu item "Edit-> Open attribute table" (see Figure 7). In the Figure 6,7 Fractal Julia set is shown, it was created using the formula: Zn+1=Zn*Zn, where Zn=0.28+0.0113*i.
Fractal_OpenWebGIS_2
Figure 6.
Fractal_OpenWebGIS_chart
Figure 7. The chart is turned with the help of buttons "X+", "X-", "Y+", "Y-", "Z+","Z-"


When calculating the fractal, the current center of the map extent is taken as the center of the fractal, and the boundaries of a fractal comply with the minimum and maximum coordinates of the current extent (View) of the map. The extent of the map defines the geographic boundaries of GIS mapping information in the data frame.
Let`s have a look at other fractals created with the help of OpenWebGIS. In Figure 8 Fractal Julia set is shown created using the formula: Zn+1=sin(Zn*Zn*Zn*Zn)
*Zn*Zn*Zn*Zn, where Zn=0.71+0.001*i
Fractal_OpenWebGIS_Julia_Set_sin_options3D
Figure 8.

In Figure 7 the fractal is shown created in the form of 3D chart in a seperate window. Users also can create fractals in 3D directly on the Earth Globe.
In order to open the 3D map you must first click on the button 3d_offin the upper right corner of the map. This button has the title "Add 3d Map. Globe ". There will be a pop-up window in which you can set the desired options. Let`s create a fractal in 3D on the Earth Globe shown in 2D in Figure 8. To do it set the options of 3D view in the window that appears after clicking the button "Add 3d Map. Globe " as shown in Figure 8 .

After setting the corresponding options and pressing the button "Ok" you will get 3D view of the Earth Globe and the fractal as shown in the Figure 9. And the Globe  and 3D fractal rotation can be seen in the Figure 10.
Fractal_OpenWebGIS_Julia_Set_sin_3D
Figure 9.

OpenWebGIS_fractal3D_1
Figure 10.

For working with the 3D map use these navigation instructions:
Pan view: Left click + drag;
Zoom view: Right click + drag, or Mouse wheel scroll;
Rotate view: Middle click + drag, or CTRL + Left click + drag.

Let`s have a look at 2D and 3D view of fractal created using the formula: Zn+1=tan(Zn*Zn*Zn*Zn*Zn*Zn*Zn)*sin(Zn*Zn*Zn*Zn*Zn*Zn*Zn)*Zn*Zn*Zn*Zn*Zn*Zn*Zn, where Zn=0.58+0.0003*i (See Figure 11,12,13). The Globe  and 3D fractal rotation can be seen in the Figure 14.
Fractal_OpenWebGIS_Julia_Set_tan_sin_z
Figure 11.

Set options of 3D view for the fractal layer as shown in the Figure 12.

Fractal_OpenWebGIS_Julia_Set_tan_sin_z_options3D
Figure 12.

Fractal_OpenWebGIS_Julia_Set_tan_sin_z_3D
Figure 13.

OpenWebGIS_fractal3D_2b
Figure 14.

Another example of Fractal see at Figure 15 and 16.
Fractal_OpenWebGIS_Julia_Set_tan_sin_z2
Figure 15.
OpenWebGIS_fractal3D_3
Figure 16.

Look at Julia fractal created using the formula Zn+1=sin(Zn*Zn*Zn*Zn*Zn*Zn*Zn)*(Zn*Zn*Zn*Zn*Zn*Zn*Zn), where Zn=0.71+0.001*i
when value of delta=0.012 and iteration quantity equal to 15, it looks as shown in the Figure 17. The Map is positioned on the city of Saint-Felicien.
Fractal_OpenWebGIS_Julia_Set_sin_z
Figure 17.

It`s an amazing structure, isn`t it? Perhaps it reminds a city. Let`s create a model of virtual (fictional) city using this fractal. let`s call it the Fractal city.
In order to make the fractal look  more like the city, it is necessary to decrease its density by increasing delta values. Let`s set delta=0.6. Change the legend for "iterarionValue" as shown in the Figure 18.  Then create the city in 3D space by setting the 3D options as shown in the на Figure.
Fractal_OpenWebGIS_Julia_Set_sin_z3d_options
Figure 18.

The result of our actions will be the same as shown in the Figure 19,20,21.

Fractal_OpenWebGIS_Julia_Set_sin_z3D
Figure 19.

Fractal_OpenWebGIS_Julia_Set_sin_z3D2
Figure 20.
OpenWebGIS_fractal3D_City
Figure 21.

Detailed video about fractal creation and Fractal City is shown below:


To get Animation in OpenWebGIS of a fractal creation follow these instructions:
1. Select the name of layer Fractal in "Editable Layer" drop-down list,
2. Click on the menu item "View->Time Line",
3. In opened popup window select the field with date – "Time",
4. You can move this window if you select menu item "Interface"->"Switch to interface drag",
5. Specify suitable for you parameters of animation and press the play button.

See example of fractal animation in the video below: