<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by George Panagiotopoulos on Medium]]></title>
        <description><![CDATA[Stories by George Panagiotopoulos on Medium]]></description>
        <link>https://medium.com/@george-k-panagiotopoulos?source=rss-327f30d8e43d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VP_HMWLYioMZ2RwG</url>
            <title>Stories by George Panagiotopoulos on Medium</title>
            <link>https://medium.com/@george-k-panagiotopoulos?source=rss-327f30d8e43d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 02:27:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@george-k-panagiotopoulos/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Value of Mountains]]></title>
            <link>https://george-k-panagiotopoulos.medium.com/for-our-mountains-70c132dd4723?source=rss-327f30d8e43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/70c132dd4723</guid>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[nature]]></category>
            <category><![CDATA[mountains]]></category>
            <category><![CDATA[science]]></category>
            <category><![CDATA[climate-change]]></category>
            <dc:creator><![CDATA[George Panagiotopoulos]]></dc:creator>
            <pubDate>Fri, 08 Jan 2021 16:47:03 GMT</pubDate>
            <atom:updated>2021-01-14T11:43:01.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Alpine lakes on mount Mavrovouni, Greece." src="https://cdn-images-1.medium.com/max/1024/1*kPPMouvi-ZemL6V3IxM2RQ.jpeg" /></figure><p>When I was little, I spent my summers in a small village on Mount Kallidromos. A small mountain, not very well known, but in my eyes then it could have been Mount Everest. So, every year, I had a goal, to reach the top of the mountain. From year to year, I was getting closer, until one August afternoon, I managed to achieve my goal. I still remember the feelings of that day, when I saw my reward, a wonderful sunset behind the mountain. After many years, I still remember that feeling. That sense of exploration, and discovery.</p><p>For us orophiles, this is a familiar feeling. For the rest, you don’t know what you are missing. Mountains have always been a source of awe and imagination. Mount Olympus, the highest mountain in Greece is the home of the gods in Greek Mythology. But there are many more that make the mountains so amazing. Today, I will tell you about two, natural resources and diversity.</p><h3>Natural Resources</h3><p>Mountains are the earth’s water tanks. Almost every source of freshwater originates in some mountain. This is a result of both low temperatures and geology. Low temperatures help to store water in the form of ice. The ice melts in the spring, and we get clean water throughout the dry summer months. Also, the mountains’ geology can hold rainwater for many months or even years after it is poured into the earth.</p><p>Apart from this, it also rains more in the mountains. This phenomenon is called orographic precipitation. As the air with humidity lifts when it meets a mountain, it cools down, and its volume decreases. When the air reaches its saturation point, clouds are formed and eventually rain.</p><p>This is why we enjoy freshwater even when it’s not raining for a while. Otherwise, all the rain would flow into the ocean in a few days at most.</p><p>But there is more to it than water. One-third of the forests worldwide are found in the mountains. And this while mountains cover just 24% of the earth’s land area. Forests are in great danger because of climate change and human activity. Mountain forests are not immune to climate change. On the contrary, they can be even more prone to climate change because of the fragile balance between elevation zones. Yet, they might be less endangered by humans. Mountains’ topography and climate are quite difficult for most activities. In most cases, it’s too cold and too sloppy to do anything, except for livestock grazing and tourism. Livestock grazing is a serious threat, but one of the most destructive activities of forests, agriculture, is harder in the mountains. There is simply not enough usable space.</p><p>Besides their aid in the carbon dioxide levels, mountain forests also help to store water and prevent erosion. They are one of the most valuable resources of the earth, even if rainforests are more in the spotlight. And they can be protected without conflicting with agriculture.</p><h3>Biodiversity</h3><p>Mountain ecosystems are among the most diversified on earth. Usually, jungles beat them, but after that, it’s hard to find a more diversified ecosystem on the planet. The main reason is the elevation zones. Generally, temperature decreases as the elevation increases, about 6–10 °C every 1000 m depending on a few factors. This is attributed to the less dense air as we move up in altitude, which limits the amount of heat that the air can store. In addition to that, some other factors play a crucial role in the mountain climate, like the aspect. Many mountains have a sunny and a shaded side, where conditions vary and especially in winter. As a result, different climate zones form at different elevations with their own unique ecosystem. For example, Mount Kilimanjaro in Africa (technically a volcano) has at least 5 climate zones. From jungles to glaciers, all in the same mountain. To find the same climate zones on lowlands, you would have to travel from the tropics to the arctics. That’s more than 5,000 km, a thousand times the height of Mount Kilimanjaro. Especially the mountains in the tropics are overflowing with biodiversity. The northern Andean mountain range has more than 45,000 plant species, of which almost half are endemic.</p><p>There are other factors that make the mountains so full of diversity and life. Geology, remoteness, and lack of human activity certainly have something to do with it. Still, it is a puzzling thing for scientists, as it has been discussed in this article:</p><p><a href="https://science.sciencemag.org/content/365/6458/1108">Humboldt&#39;s enigma: What causes global patterns of mountain biodiversity?</a></p><p>So, why is diversity important? Would it be so bad to have two or three species of plants and animals? It turns out that diversity is what’s holding the earth’s ecosystem together. For example, if some plant is endangered because of unfavorable conditions, there are many more alternatives for the animals. Biodiversity is the reason that “life always finds a way”.</p><h3>Cultural diversity</h3><p>But there is another form of diversity in the mountains, the cultural diversity. And like biodiversity, cultural diversity is vital. You may have heard of the Hunza Valley. A mountainous valley in Pakistan at an average elevation of 2,500 km. In the Hunza district, around 250,000 people speak 4 different languages. One of them, the Burushaski language, is one of the language isolates of the world. This means that it has no relation to any other language of the world. Not even with the ones of the neighboring areas. This variety is a result of years and years of isolation in a specific landscape. Anthropologists talk a lot about the role of the environment in human perception. Tim Ingold, in his amazing work “The Perception of the Environment”, discusses how human skills are not inherited but are grown in a certain environment. It’s no surprise then that remoteness and isolation can produce unique skills that reflect in the culture.</p><figure><img alt="Hunza valley, Pakistan. A mountainous village in the bottom of very high peaks." src="https://cdn-images-1.medium.com/max/1024/0*nxY9yJPjijkAjFNT" /><figcaption>Hunza valley, Photo by <a href="https://unsplash.com/@shuttergames?utm_source=medium&amp;utm_medium=referral">Shuttergames</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A harsh environment can make people difficult, suspicious, and sometimes xenophobic. In such a closed society, people develop their own characteristics, more out of necessity than beliefs. Yet, this diversity is what gives people identity. In light of globalization, there are so few things that can make us connect with people and places. I am not a black-and-white person. I love the internet and what it has offered to our civilization. But, unique local cultures are an amazing source of identity and connection. It cannot be replaced by blogs and chats.</p><p>Mountains are in great danger and if things go wrong, we will pay it dearly. Climate change can destroy the rich environment of the mountains. For example, risen temperatures can lead to less ice and more forest fires in the mountains. Since typically those forests are not used to such phenomena, the impact can be even more disastrous. Fewer mountain forests will lead to less biodiversity and more erosion. More erosion and less ice will lead to less freshwater. Less biodiversity will lead to less stable ecosystems, and so on. It’s a vicious circle that intensifies each run.</p><p>Cultural diversity has also an enemy, tourism. Unfortunately, tourism has degraded many remote mountain places. It’s not that tourism is bad, it’s how it is done. Often, and in an attempt of quick profit, people tend to shadow their unique culture favoring more mainstream solutions. Small businesses are replaced by large multinational companies. Grand ski resorts take the place of small local activities. Local products are replaced by cheaper imported goods and more.</p><p>Mountains are amazing, but they are in danger. Protect them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70c132dd4723" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neighborhood analysis in Web GIS: a COVID-19 Case]]></title>
            <link>https://george-k-panagiotopoulos.medium.com/neighborhood-analysis-in-web-gis-a-covid-19-case-5b95062e7504?source=rss-327f30d8e43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b95062e7504</guid>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[spatial-analysis]]></category>
            <category><![CDATA[web-gis-services]]></category>
            <category><![CDATA[spatial]]></category>
            <dc:creator><![CDATA[George Panagiotopoulos]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 18:15:22 GMT</pubDate>
            <atom:updated>2021-01-06T18:15:22.804Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFVrgHDceY5Gl4uX-mkEfQ.png" /></figure><h3>Neighborhood analysis in Web GIS: a Covid-19 Case</h3><p>It’s easier than you might think</p><h3>A brief introduction</h3><p>In this article, we will look at how to develop Web GIS applications that can perform neighborhood analysis. Virtually, all mapping applications can be considered Web GIS applications, as they are an information system and deal with spatial data. However, a true GIS usually consists of 4 basic subsystems — data entry, processing and management, analysis, and presentation. The analysis part is often missing from most web GIS applications, in which the main goal is to present geographical data in an aesthetically pleasing way. But, as we will see here, spatial analysis is not something difficult with today’s tools.</p><h3>What are the spatial neighbors?</h3><p>Spatial neighbors are entities that have some spatial connection to the entity under study. The spatial connection can be interpreted in several ways. The simplest form is that of the distance between them. For example, we can define a distance threshold above which spatial entities will not be considered neighbors. It is important here to understand that neighbors are always about an entity in question. When we assign a value to an entity based on its neighbors, we do not also give the neighbors a value, but in turn, the neighbors will get a value based on their own neighbors.</p><p>Regarding distance, it is also important to note that this is often given as an exponential function to include the distance decay effect. Distance decay is based on <a href="https://en.wikipedia.org/wiki/Tobler%27s_first_law_of_geography">Tobler’s first law of geography</a> and practically means that the furthest we are from a location the less likely it is to interact with it (based on an exponential function that can vary depending on the subject).</p><p>Another well-known neighborhood method is the k-nearest neighbors. This method gives the k-nearest neighbors regardless of distance. This is a very common method in image analysis applications, in which neighboring pixels are examined. Finally, some consider neighborhoods within a network (e.g. the road network). There are many more methods of spatial connection, each one with its pros and cons depending on what we want to do.</p><h3>Neighborhood analysis, why is it useful?</h3><p>Consider a timely example. Let’s say we have countries with daily cases of Covid-19. The relationship between neighboring countries may help to understand how the virus moves. Of course, this may not be applicable in all cases. Still, there is no doubt that neighboring countries have greater interaction with each other than the more distant ones. Especially, in matters related to personal hygiene. An examination of a country’s state and its neighbors can provide insight into the origin of the virus. For example, if neighboring countries have a lower infection rate compared to the country in question, it is more likely that the transmission came from air travel. If all neighboring countries have high infection rates, it is more likely that the transmission came from border interaction. Finally, if the country has a low infection rate compared to its neighbors, then they should increase border testing.</p><p>Another application of neighborhood analysis is clustering. It is possible to identify groups of countries that are in a similar state and act accordingly. The results of a spatial analysis could eventually be used for proper decision-making.</p><h3>Ok, neighborhood analysis is important, how do I do it in a web GIS application?</h3><p>Finding neighbors is a process that requires many resources. For example, to create a table with the distances between countries (as polygons) may take several hours or even days. This is not something we can do in real-time in a web application. Additionally, it would not be good practice to load the server with such processes by hundreds or thousands of users at a time.</p><p>But there is an important parameter that we can consider. Spatial data in most applications do not change over time. Take the countries in this example. How often do countries change spatially? But even in applications where we can have frequent changes in spatial data (let’s say soil samples), the spatial proximity can be calculated on the server at regular intervals.</p><p>What does this mean in practice? That we can calculate the spatial neighbors in advance and feed them to the application as static data, without requiring the user to run the spatial neighborhood algorithms each time. Calculating spatial neighbors is a simple process in most GIS software. For example, in QGIS there is the distance matrix tool with which we can calculate the distance of all spatial entities between them. In the example with the countries the table would look something like this:</p><figure><img alt="A matrix of the distances between countries" src="https://cdn-images-1.medium.com/max/1024/1*1pc2GDYFySYduF3KOow1oA.jpeg" /></figure><p>Having this distance matrix, it is now easy to calculate the neighbors by any method. For example, if we want the 4 closest neighbors, a simple application is the following:</p><pre>CountryObject = {<br>    ISO: &quot;&quot;,<br>    Name: &quot;&quot;,<br>    Value: &quot;&quot;,<br>    Neighbors: []<br>}</pre><pre>countriesLoop:<br>for (var c = 0; c &lt; countries.length; c++) {<br>    var neighbors = [];</pre><pre>neighborsLoop:<br>    for (var n = 0; n &lt; neighborsTable.length; n++) {<br>        if (neighborsTable[n].fromCountryISO === countries[c].ISO) {<br>            neighbors.push(neighborsTable[n])<br>            if (neighbors.length === 4) {<br>                countries[c].neighbors = neighbors;<br>                break neighborsLoop;<br>            }<br>        }<br>    }<br>}</pre><p>The double loop may not be the most efficient way to perform the calculation. You can try different methods to achieve the same result. If we wanted to find the neighbors based on the distance we could use the distance in the if statement, something like this:</p><pre>If (neighborsTable[n].distance &lt; thresholdDistance) { … }</pre><h3>Time for spatial calculations</h3><p>Once we have found the neighbors of our spatial entities, it is time to calculate the spatial neighborhood models. There are many models that we can calculate from the spatial neighborhood. Here, we will give two relatively simple examples, the spatial moving average, and the spatial similarity index.</p><p>The spatial moving average is like the moving average in statistics, in which we calculate the average value of subsets of the data. Respectively, in the spatial moving average, we calculate the average value of a subset of the spatial entities, i.e. the neighbors. In this way, we can find spatial clusters in which the value is high or low. In the example of Covid-19 cases, we can identify clusters of high values in Europe and low values in Africa.</p><figure><img alt="A map showing the spatial moving average of countries’ COVID-19 cases" src="https://cdn-images-1.medium.com/max/1024/1*1Cj7XWu2AAkzrUx2ovPLZw.png" /><figcaption>Spatial Moving Average of Covid-19 new cases per millions of population (Data as of 31 Dec 2020).</figcaption></figure><p>The spatial similarity index is an index that tells us how much uniformity the spatial entity under examination has with its neighbors. In this index, the value of the spatial entity under study is compared to the average value of its neighbors. As shown in the picture, we can see which countries are different from their neighbors. They should be especially careful if they have a low value compared to their neighbors.</p><figure><img alt="A map showing the spatial similarity index of countries’ COVID-19 cases" src="https://cdn-images-1.medium.com/max/1024/1*GZXA0L0pJMthGgSofD_x9g.jpeg" /><figcaption>Spatial Similarity Index of Covid-19 new cases per millions of population (Data as of 31 Dec 2020).</figcaption></figure><p>To calculate these two indicators the process is relatively simple. From the table with the countries and their neighbors:</p><pre>countriesLoop:</pre><pre>for (var c = 0; c &lt; countries.length; c++) {</pre><pre>neighborsLoop:</pre><pre>for (var n = 0; n &lt; countries[c].neighbors.length; n++) {</pre><pre>var SumNeighborsValue = countries[c].neighbors[n].Value++</pre><pre>}</pre><pre>var meanNeighborsValue = SumNeighborsValue / countries[c].neighbors.length</pre><pre>countries[c].SMAValue = (SumNeighborsValue + countries[c].Value) / countries[c].neighbors.length + 1 // Spatial Moving Average, the sum of neighbors&#39; values plus current spatial entity’s value to the number of neighbors plus the current spatial entity</pre><pre>countries[c].SSIValue = countries[c].Value / meanNeighborsValue // Spatial Similarity Index, the current spatial entity’s value to the mean value of neighbors</pre><pre>}</pre><p>In the SMA method, each entity takes the average value of the neighborhood, while in SSI, its value to the average value of the neighborhood.</p><p>The last thing you need to do is to present the results on a map. The best way is with a color gradation that shows the differentiation of the neighbors compared to the examined spatial entity. Before that, we need to group the values ​​into some classes so that the visualization is better. There are many ways to sort a series of values and get breakpoints and classes, like the <a href="https://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization">Jenks optimization method</a>.</p><p>To sum it up:</p><ul><li>Create a neighbors&#39; table of the spatial entities (e.g. with distance) on the appropriate software.</li><li>Feed the neighbors’ table to the app. It could be through REST calls to a database or a JSON file.</li><li>On the app, get the neighbors and perform the calculation that you want.</li><li>Classify the values and provide a color for each class to the spatial entities.</li></ul><p>You can see an example from the above <a href="http://geochoros.survey.ntua.gr/coronavirus/">here.</a></p><p><a href="http://geochoros.survey.ntua.gr/coronavirus/">GeoCHOROS Coronavirus Map</a></p><p>Note that the website does not update very often because this is a pilot project done for educational purposes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b95062e7504" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Essential Things You Need to Understand to Learn GIS]]></title>
            <link>https://medium.com/swlh/5-essential-things-you-need-to-understand-to-learn-gis-cf55efcd08d0?source=rss-327f30d8e43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf55efcd08d0</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[spatial]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[geography]]></category>
            <category><![CDATA[gis]]></category>
            <dc:creator><![CDATA[George Panagiotopoulos]]></dc:creator>
            <pubDate>Thu, 03 Dec 2020 12:35:15 GMT</pubDate>
            <atom:updated>2020-12-04T07:05:11.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dWk-BK1tYEXY9Z7RmxGINw.jpeg" /></figure><p>Geographic Information Systems (GIS) are an amazing tool for our jobs, career opportunities, and studies. But, most people are having a hard time learning them. Over the years, I have come to realize that there are specific things that we struggle with. In this article, we will see what they are and how we can better understand them to develop our knowledge in GIS.</p><h3>Understand data types</h3><p>There are two basic types of data in GIS — vector and raster. Vector data are geometries. There are three types of geometry that one can use — points, lines, and polygons. It’s that simple. We can capture any spatial entity using these three geometries with accuracy.</p><p>And it’s even simpler because both lines and polygons are joined points. The difference from a typical geometric shape is that its coordinates are somewhere in the real world (more on that later).</p><p>The second type of data, the rasters, are images. The only difference with a simple image is that a GIS raster is geo-referenced. An image consists of pixels. Usually, the pixels are small enough that we can not see them unless we zoom in enough on the image. Each pixel has a unique value (given with the color of the pixel) so we can display the real world on the computer screen.</p><p>A common form of raster data is orthophotos. Orthophotos are satellite or aerial images geometrically corrected so that we can accurately measure distances and areas of various elements in the image.</p><p>We can use both types of data to do calculations in GIS, but their use depends on the purpose of our work. For example, a river can be captured with an orthophoto, but also as a line geometry. Each form has its advantages and disadvantages. In the vector form, it is very easy to measure its length, but we can not calculate how far its riverbed reaches. Yet, this is something that we can do with two orthophotos of the river at different times of the year.</p><figure><img alt="On the left a river in vector format and on the right the same river in raster format, the two basic types of data in the GIS" src="https://cdn-images-1.medium.com/max/1024/1*-Jm5f2AqU0jCck2CtfMh9w.jpeg" /><figcaption>The two basic types of data in the GIS. On the left a river in vector format and on the right the same river in raster format.</figcaption></figure><h3>The world is made of layers</h3><p>One thing to keep in mind when starting with GIS is how the software works. Layers are one of its most important functionalities. This is the way most design software works, from cad to photo editors. Various elements are integrated into a single framework in the form of layers. Each layer may have different types of data or properties that we want to separate from the other layers.</p><p>To make this a habit and to make it easier to understand its power, it helps to think of the world as a set of layers. Look at the world the next time you go out and try to see discrete layers of things. Try to understand what real-world objects could form layers. How would you combine them into a GIS to do an analysis?</p><figure><img alt="A picture of a street with imaginable GIS layers of objects." src="https://cdn-images-1.medium.com/max/1024/1*diOo8yZ9jgggL-BmSwHQDA.jpeg" /><figcaption>Try to see the world as layers. The roads are lines, the building blocks are polygons, the signs are points, etc.</figcaption></figure><h3>Understand scale</h3><p>Scale is a key factor influencing the way we work in GIS and beyond. If you think about it, scale plays an important role in many things. It makes sense in a quantity question to provide an order of magnitude. For example, if someone asks how much you make per year, they will not be interested in the slightest penny.</p><p>Similarly, in GIS and depending on the purpose, we may not be interested in details in inches, feet, or even miles. And that’s very important in the way we work. We can display a city as a point on a small scale, a polygon on a medium scale, and even as many polygons (building blocks) on a larger scale.</p><p><strong><em>A quick tip:</em></strong><em> In mapping, the scale is the ratio of the dimensions on paper (or on the computer) to the dimensions in the real world. So, the larger the study area (denominator), the smaller the scale.</em></p><p>It doesn’t make sense to map cities as a set of building blocks if the scale we need is at that of a country or a continent. Understanding the scale of our work will save us a lot of resources and time.</p><figure><img alt="A city is captured in various ways (a point, a polygon, and multiple polygons) for different scales of analysis." src="https://cdn-images-1.medium.com/max/1024/1*tlkxuWR8DcaScSCWl5OPaw.jpeg" /><figcaption>A city can be captured in various ways for different scales of analysis.</figcaption></figure><h3>Understand coordinate reference systems (CRSs)</h3><p>I remember when I started learning GIS and was attacked by a lot of incomprehensible terms about coordinate reference systems, such as geodetic systems, geographic and projection coordinate systems, datums, ellipsoids, and so on. I was thinking what is all this craziness and what does it have to do with making a map. In fact, coordinate reference systems are not always needed to make a map. But GIS is more than that. GIS can do pretty maps, but that is not their true value. The real value is in the spatial analysis, so we must be able to make spatial calculations (eg area and distance).</p><p>And you might wonder why I can’t do calculations in a geometric shape without all the above? The problem is that the earth is not flat 😱. Also, many other factors affect the shape of the earth, such as the movement of the continental plates. For these reasons, a spatial entity in a virtual space, such as on paper or on a computer screen, is distorted. And if we do not capture this distortion then the calculations we make will be wrong.</p><p>Moreover, we need the ability to exchange spatial information. The process of exchanging spatial data is very easy when we have a common reference.</p><p>CRSs are generally a very difficult aspect of geography, with huge research behind it. Yet, we don’t have to know everything about CRSs to use GIS. A general idea of how they work and why we need them is enough. We have covered the why, let’s see how it works in a nutshell.</p><p>If you draw a geometric shape that represents an object in space (say a field), neither the paper nor the computer knows where that field is in the real world. For the paper and the computer, the dimensions of the shape can be expressed in centimeters or pixels. To find the real-world dimensions of the object, we need to convert the local coordinates of the virtual world to geographic ones.</p><p>For example, in the CRS EPSG:3857, the earth is projected on a flat surface and the coordinates of each point are meters from the prime meridian (red line on the image) and the equator (green line on the image). In another common CRS, the EPSG:4326, the earth’s projection is ellipsoid and the coordinates are in degrees.</p><figure><img alt="A shape with local coordinates on a plane and the same shape on a globe with geographic coordinates." src="https://cdn-images-1.medium.com/max/990/1*R1WA1knH4I5rzRiwLf0vHQ.jpeg" /></figure><p>The cool thing is that we don&#39;t need to do much about all these, as some others have already made the conversions for us. In spatial data, the true coordinates of a shape in space are already stored in the files. When you combine them with other spatial data, they will fall in the right place. And don’t worry in case you start creating spatial data from scratch because we always do that in a referenced map.</p><p>An important thing is that there are many CRSs, depending on the area you are looking at on earth. Almost all countries have a CRS that represents their area most accurately. But even that is not a problem as switching from one system to another is a common process.</p><h4>Two more notes:</h4><ul><li>It’s good practice to always have your data in the same coordinate reference system. Although most programs handle different systems perfectly, a clean and systematic database goes a long way.</li><li>It is better to convert the vector than the raster files. This is because it’s easier to change a geometric shape than pixels, which are squares by default. When a pixel is moved or distorted, a new one must be created with values ​​from its neighbors.</li></ul><h3>Learn (or remember) how it all started</h3><p>Once upon a time, GIS were symbols on a console. In this primitive form, people worked on GIS and could draw conclusions. Everything starts somewhere. In programming, the first moves were so simple that they seem funny today. Yet, people used this simple form and came up with incredible results.</p><figure><img alt="A bunch of console symbols forming a map." src="https://cdn-images-1.medium.com/max/566/1*IpyhsQtDSSzX7q1PC3qu8A.jpeg" /><figcaption>This used to be a GIS.</figcaption></figure><p>And things were very difficult then. One could write the command del *.*, hit enter, and boom everything was gone forever, the work of a lifetime. No recycle bins or trash cans, no “are you sure you want to delete these files”, no cloud sync storage and whatsoever. A wrong move could mean the end of all. But even in calculations, it was very difficult to understand what you were doing. Executing a command simply changed the line on the console. You did not know if it worked or not. Only a black screen and you had to find a way to see if everything went as you expected.</p><p>Things have changed a lot since then, but it’s good to remember where it all started and for what purpose. GIS was another application of technology like so many others. The way to digitize, speed up, and optimize spatial analysis. And the symbols on the console were more than enough to do things better than we did until then.</p><p>I hope you can take a different look at GIS after this article. There is nothing complicated about the whole process if you know what you are doing and why. My last tip is to start learning GIS with a real problem that you know well and the whole process will be enjoyable.</p><h4>Links to get started:</h4><ul><li><a href="https://en.wikipedia.org/wiki/Geographic_information_system">Geographic information system</a></li><li><a href="https://en.wikipedia.org/wiki/GIS_file_formats">GIS file formats</a></li><li><a href="https://en.wikipedia.org/wiki/Scale_(map)">Scale (map)</a></li><li><a href="https://en.wikipedia.org/wiki/Spatial_reference_system">Spatial reference system - Wikipedia</a></li><li><a href="https://en.wikipedia.org/wiki/Geographic_coordinate_system">Geographic coordinate system</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf55efcd08d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/5-essential-things-you-need-to-understand-to-learn-gis-cf55efcd08d0">5 Essential Things You Need to Understand to Learn GIS</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenLayers and three.js]]></title>
            <link>https://javascript.plainenglish.io/openlayers-and-three-js-99c904eed76c?source=rss-327f30d8e43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/99c904eed76c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[3d]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[George Panagiotopoulos]]></dc:creator>
            <pubDate>Sat, 31 Oct 2020 13:44:26 GMT</pubDate>
            <atom:updated>2020-12-02T21:01:57.936Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3yOer9ANt60djuanhTezA.jpeg" /></figure><p>Recently, I considered creating an online 3D globe for a project. Three.js is an amazing library and there are many resources on the internet to create visually stunning globes. But I also wanted to have the rich mapping functionality of OpenLayers.</p><p>While there are libraries for this purpose, I thought about exploring the possibilities of these two libraries, without being restricted by a one-package solution. And the possibilities are endless. Let’s begin.</p><p>The first step is to create a 3D sphere using three.js. Nothing complicated here, just a few notes:</p><ul><li>We use the Orthographic camera since the perspective is not suited for this kind of thing.</li><li>We integrate the orbit controls to be able to rotate and zoom on the globe.</li></ul><pre>var camera = new THREE.OrthographicCamera(<br>  -window.innerWidth / 4,<br>  window.innerWidth / 4,<br>  window.innerHeight / 4,<br>  -window.innerHeight / 4,<br>  1,<br>  1000<br>);</pre><pre>camera.position.set(0, 0, 100);</pre><pre>var controls = new THREE.OrbitControls(camera, renderer.domElement);</pre><pre>var globe = new THREE.Mesh(<br>  new THREE.SphereGeometry(90, 64, 64),<br>  new THREE.MeshPhongMaterial()<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p92BRuaGSOIkIFwhow576g.jpeg" /><figcaption>A three.js scene with a sphere, orbit controls and orthographic camera.</figcaption></figure><p>Next, we add a simple OpenLayers map and here is where fun begins. Three.js has a method to put a canvas element as a texture to a mesh object. It is basically the same as the base texture class, but it accepts a canvas element as input and it sets the needsUpdate property to true by default. OpenLayers has a map event, from which we can get the map canvas when the rendering is complete. Inside the event, we set the map canvas as a texture to our sphere and set the needsUpdate property of the sphere’s material to true.</p><pre>map.on(&quot;rendercomplete&quot;, function () {<br>var mapContainer = document.getElementById(&#39;map&#39;);</pre><pre>var mapCanvas = mapContainer.getElementsByTagName(&#39;canvas&#39;)[0];</pre><pre>var texture = new THREE.CanvasTexture(mapCanvas);<br>  globe.material.map = texture;<br>  globe.material.needsUpdate = true;<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*izcvyVvOlBPNbGjWlAKGmw.jpeg" /><figcaption>An OpenLayers map projected on a three.js sphere.</figcaption></figure><p>At first, the result is pretty bad. One thing we must do is to change the projection of the OpenLayers view. This is because OpenLayers uses by default the EPSG:3857 Spherical Mercator, which projects the coordinates on a 2D surface and, thus, stretches the map at the poles. This is fine for a flat view, but, for a sphere, we require the EPSG:4326 or something similar, which uses an ellipsoidal 2D coordinate system. Changing the projection system of the OpenLayers view is very simple.</p><pre>var view = new ol.View({<br>  projection: &quot;EPSG:4326&quot;,<br>  extent: [-180, -90, 180, 90],<br>  center: [0, 0],<br>  zoom: 2<br>});</pre><p>The map looks way better but still we miss a few parts. This is because the canvas does not render the whole map. To address this, we have to force the canvas view to show the whole map. The map bounds in degree units are [-180,-90,180,90], so that makes a ratio of 2:1 for width and height. Setting the width and height of the map element to 1000px and 500px respectively, correctly renders the whole map on the canvas and eventually the texture of our sphere. We also hide the map so it does not obscure the 3d view (and hopefully saving resources).</p><pre>&lt;div id=&quot;container&quot;&gt;<br>  &lt;div id=&quot;map&quot; style=&quot;position: fixed; visibility:hidden; width: 1000px; height:500px;&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezaQaNFQYbERRMu9wZ-TYw.jpeg" /><figcaption>An OpenLayers map correctly projected on a three.js sphere.</figcaption></figure><p>This is better. We now have a 3D globe with an OpenLayers map correctly applied onto it. But there is still an issue. We cannot zoom on the sphere and get a better resolution of the map, meaning more tiles. I tried several methods to make this happen, but it seems that the one that works well is to increase the size of the canvas at certain zoom levels of the three.js camera. And it makes sense, because a zoom on the sphere would require a higher resolution texture.</p><p>To do that, we can use the OrbitControls end event. Inside the event we can get the camera zoom and change the canvas size at certain zoom levels. We use three cases of zoom for testing, but obviously more are applicable. Note that it is required to call the method updateSize() on our map whenever we change the size of the map element. Also, because the view does not zoom-out when we decrease the map size, we have to reset the view resolution (or zoom level). You can get the resolution of each map size with the view.getResolution() method and use the values to set the resolution again. Finally, for efficiency, we do not want this to fire on every zoom change, so we need a way to restrict the size changing on every orbit control change. Here, I use the Math.floor for the camera zoom to get integer values and a temporary variable to store the current width, but you can get similar results in several ways.</p><pre>var currentWidth = 1000;<br>controls.addEventListener(&quot;end&quot;, function (event) {<br>switch (Math.floor(camera.zoom)) {<br>    case 1:<br>      document.getElementById(&quot;map&quot;).style.width = &quot;1000px&quot;;<br>      document.getElementById(&quot;map&quot;).style.height = &quot;500px&quot;;<br>      if (currentWidth !== 1000) {<br>        map.updateSize();<br>        view.setResolution(0.36);<br>        currentWidth = 1000;<br>      }<br>      break;<br>    case 2:<br>      document.getElementById(&quot;map&quot;).style.width = &quot;2000px&quot;;<br>      document.getElementById(&quot;map&quot;).style.height = &quot;1000px&quot;;<br>      if (currentWidth !== 2000) {<br>        map.updateSize();<br>        view.setResolution(0.225);<br>        currentWidth = 2000;<br>      }<br>      break;<br>    case 3:<br>      document.getElementById(&quot;map&quot;).style.width = &quot;4000px&quot;;<br>      document.getElementById(&quot;map&quot;).style.height = &quot;2000px&quot;;<br>      if (currentWidth !== 4000) {<br>        map.updateSize();<br>        view.setResolution(0.18);<br>        currentWidth = 4000;<br>      }<br>      break;<br>    default:<br>      break;<br>  }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4a2Q5PvZey_07KDZ0A7KA.jpeg" /><figcaption>An OpenLayers map on a three.js sphere with zoom functionality.</figcaption></figure><p>And it is getting better. We now have a 3D globe with OpenLayers, on which we can zoom and get a better resolution. But there is a final issue. We download the tiles from the whole world. This is a very heavy procedure and it makes the scene very laggy when the tiles’ loading is called. To tackle this issue, we can use the setExtent method on the tile layer and restrict the tile loading to a specific area of interest. In order to do that, we have to find the map coordinates that the camera is currently looking at the sphere. And there is a clever way to do this.</p><p>Firstly, we use the Raycaster class of the three.js to get the sphere intersection on the center of the screen (and consequently that of the camera). From this, we can get the UV position of the map canvas that the center of the camera is currently looking at. Multiply the UV coordinates by the canvas size in pixels and we get the corresponding pixel on the canvas. And, thankfully, OpenLayers has a very useful function, the getCoordinateFromPixel, from which we can get the coordinates on the map (x,y) from a canvas pixel.</p><pre>var raycaster = new THREE.Raycaster();<br>controls.addEventListener(&quot;end&quot;, function (event) {<br>raycaster.setFromCamera({ x: 0, y: 0 }, camera);</pre><pre>let intersects = raycaster.intersectObject(globe);</pre><pre>let x = -map.getCoordinateFromPixel([<br>    intersects[0].uv.x * currentWidth,<br>    (intersects[0].uv.y * currentWidth) / 2<br>  ])[1];<br>  let y = map.getCoordinateFromPixel([<br>    intersects[0].uv.x * currentWidth,<br>    (intersects[0].uv.y * currentWidth) / 2<br>  ])[0];</pre><pre>});</pre><p>Finally, to get the extent, we define a circle at the center with a radius of 20 degrees (this will depend on the size of the extent that we need and it could change dynamically for various camera zoom levels). From the circle feature, we get the extent and we pass it on the OSM layer. The result looks pretty good.</p><pre>var circle = new ol.Feature({<br>    geometry: new ol.geom.Circle([y, x], 20)<br>  });</pre><pre>var circleSource = new ol.source.Vector({<br>    features: [circle]<br>  });</pre><pre>osm.setExtent(circleSource.getExtent());</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFDjto6g4mRSmBBynYhHWA.jpeg" /><figcaption>An OpenLayers map on a three.js sphere with extent restriction.</figcaption></figure><p>As a final touch, we can add a second OSM layer to cover the black texture around our focus area. To restrict this layer’s tile loading, we set the maxZoom property of the layer’s source to 2.</p><pre>new ol.layer.Tile({<br>      extent: [-180, -90, 180, 90],<br>      source: new ol.source.OSM({<br>        maxZoom: 2<br>      })<br>    }),</pre><p>We now have a fully functional OpenLayers map on a three.js 3D sphere. This unlocks many possibilities for 3D mapping. It is amazing that we can do this with a few lines of code and have in our arsenal the power and features of two great libraries.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fgpanag%2Fembed%2Fpreview%2FJjKLZJj%3Fheight%3D600%26slug-hash%3DJjKLZJj%26default-tabs%3Djs%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fgpanag%2Ffull%2FJjKLZJj&amp;image=https%3A%2F%2Fassets.codepen.io%2F5266107%2Finternal%2Fscreenshots%2Fpens%2FJjKLZJj.default.png%3Ffit%3Dcover%26amp%3Bformat%3Dauto%26amp%3Bha%3Dtrue%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D2%26amp%3Bversion%3D1604149260%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/09ef6c7d221307ace7cce5dbc8648409/href">https://medium.com/media/09ef6c7d221307ace7cce5dbc8648409/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99c904eed76c" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/openlayers-and-three-js-99c904eed76c">OpenLayers and three.js</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>