<?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 Pavlos Demetriades on Medium]]></title>
        <description><![CDATA[Stories by Pavlos Demetriades on Medium]]></description>
        <link>https://medium.com/@pavlosdemetriades99?source=rss-a045a9932f1d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iaRmS5ib4Su8l2AxXqEO8A@2x.jpeg</url>
            <title>Stories by Pavlos Demetriades on Medium</title>
            <link>https://medium.com/@pavlosdemetriades99?source=rss-a045a9932f1d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:32:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pavlosdemetriades99/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[Downloading Overture Map Foundation’s buildings data using Apache Sedona with Docker — Python and…]]></title>
            <link>https://python.plainenglish.io/downloading-overture-map-foundations-buildings-data-using-apache-sedona-with-docker-python-and-473f5175f241?source=rss-a045a9932f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/473f5175f241</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Pavlos Demetriades]]></dc:creator>
            <pubDate>Tue, 02 Jan 2024 11:06:35 GMT</pubDate>
            <atom:updated>2024-10-10T14:06:41.577Z</atom:updated>
            <content:encoded><![CDATA[<h3>Downloading Overture Map Foundation’s buildings data using Apache Sedona with Docker — Python and stored them in PostGIS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*Cb0LMqEIEN9Un-HChbd9bQ.png" /></figure><p><a href="https://overturemaps.org/">The Overture Maps Foundation is a project by the Linux Foundation that aims to create reliable, easy-to-use, and interoperable open map data 1</a>. It is a collaborative effort by Amazon Web Services (AWS), Meta (i.e. Facebook), Microsoft, and TomTom to build an ecosystem of interoperable open map data. The foundation is intended for developers who build map services or use geospatial data. Overture aims to incorporate map data from multiple sources including Overture Members, civic organizations, and open data sources. The foundation will simplify interoperability by providing a system that links entities from different data sets to the same real-world entities. Overture Maps data will undergo validation checks to detect map errors, breakage, and vandalism to help ensure that map data can be used in production systems. Overture will define and drive adoption of a common, well-structured, and documented data schema to create an easy-to-use ecosystem of map data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdgWLjzIXUcpVMD3ptjPNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tt95lQdL8wRA4kbMdSW2uA.png" /></figure><p>Apache Sedona is a cluster computing system that processes large-scale spatial data. It is an open-source project of the Apache Software Foundation that extends existing cluster computing systems, such as Apache Spark and Apache Flink, with a set of out-of-the-box distributed Spatial Datasets and Spatial SQL that efficiently load, process, and analyze large-scale spatial data across machines. It supports various geospatial data formats, tools, and languages, and has many use cases and applications in various domains. The system offers Scala, Java, Python, and R APIs and integrates them into the underlying system kernels for spatial analytics and data mining applications.</p><h3>The use case.</h3><p>In this article we are going to download all the buildings of Cyprus (we hope so that all exist 😎) from the Overture Maps Foundation dataset — buildings and stored them in PostGIS using docker — python.</p><p>For more about the conversion of parquet to geoparquet format, read this article from <a href="https://medium.com/u/4951e7059b96">Jia Yu</a>.</p><p><a href="https://medium.com/@dr.jiayu/harnessing-overture-maps-data-apache-sedonas-journey-from-parquet-to-geoparquet-d99f7767a499">Harnessing Overture Maps Data: Apache Sedona’s Journey from Parquet to GeoParquet</a></p><h4>Steps</h4><ol><li>Docker Hub — Pulling the Apache Sedona image — Running a container — Configuring Ports</li><li>Jupyter Lab in Docker — Converting buildings data to GeoDataFrame</li><li>Downloading the buildings data locally — csv format</li><li>Stored the building data in our PostGIS Geodatabase</li><li>Using QGIS to visualize Cyprus Buildings which are stored in PostGIS.</li></ol><h4>1. Docker hub— Pulling the Apache Sedona image — Running a container — Configuring Ports</h4><p>First of all, we must download <a href="https://hub.docker.com/">Docker hub</a>. After the download we search for apache/sedona. Then we press Run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zX5VVD-LHcxRfshj1eNhQw.png" /></figure><p>After that, we choose the Images tab and the apache/sedona Image must show up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MkAPgwjseOI6Z2mf9s-bQ.png" /></figure><p>Then we press the Run button (under the Actions Group). We choose optional Settings and then we configure the ports as shown in image, below, after we run the container ▶️.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*kuUkXbTfKjlmDq3D62MxbQ.png" /></figure><p>After that in the container tab, a container of Apache Sedona must show up (For me the name is thirsty_leavitt, for you must be Apache Sedona — 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owM9ybnnJ9dFYXCmdQEO2A.png" /></figure><p>👉<em> Ctrl + Right click </em><a href="http://127.0.0.1:8888/lab"><em>http://127.0.0.1:8888/lab</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohOq3_5ZcHBjIECs-VKBjA.png" /></figure><p>After pressing <em>Ctrl + Right click</em> <a href="http://127.0.0.1:8888/lab"><em>http://127.0.0.1:8888/ lab</em></a> a jupyter lab environment open in the browser.</p><h4>2. Jupyter Lab in Docker — Converting buildings data to Geopandas GeoDataFrame</h4><p>To start the procedure to find all the building of Cyprus we must open the Sedona_OvertureMaps_GeoParquet.ipynb for guidance. Also, we create a new .ipynb file called Cyprus_Buildings.ipynb. After that we start coding in Cyprus_Buildings.ipynb.</p><pre># Importing Libraries<br><br>from sedona.spark import *<br>import os<br>import time<br>import pandas as pd<br>import geopandas as gpd</pre><pre># AWS Data link for Overture Maps Data<br><br>DATA_LINK = &quot;s3a://wherobots-public-data/overturemaps-us-west-2/release/2023-07-26-alpha.0/&quot;</pre><pre># Configuring <br><br>config = SedonaContext.builder().master(&quot;spark://localhost:7077&quot;) .\<br>    config(&quot;spark.hadoop.fs.s3a.aws.credentials.provider&quot;, &quot;org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider&quot;). \<br>    config(&quot;fs.s3a.aws.credentials.provider&quot;, &quot;org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider&quot;). \<br>    getOrCreate()<br><br>sedona = SedonaContext.create(config)</pre><pre># Cyprus closed polygon or your Area of Interest, THE POLYGON must be closed<br>spatial_filter = &quot;POLYGON ((32.222900390625 34.479391971048, 32.222900390625 35.719757939334, 34.749755859375 35.719757939334, 34.749755859375 34.479391971048,32.222900390625 34.479391971048))&quot;</pre><pre>%%time # Magic command to print the processing time<br><br>df_building = sedona.read.format(&quot;geoparquet&quot;).load(DATA_LINK+&quot;theme=buildings/type=building&quot;)<br><br>df_building = df_building.filter(&quot;ST_Contains(ST_GeomFromWKT(&#39;&quot;+spatial_filter+&quot;&#39;), geometry) = true&quot;)<br><br>df_building = df_building.limit(2_000_000) # 2_00_000 optional<br><br># Wall time: 24.5s for ~ 800_000 Buildings - Awesome !!🚀🚀</pre><pre>%%time<br># Visualizing all the buildings using Kepler<br><br>map_building = SedonaKepler.create_map(df_building, &#39;Building&#39;)<br>map_building</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yLOcthlpH2A3vfqJzwORAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H957ETUhr6uIHM_oq93PGQ.png" /></figure><p>Converting Apache Sedona DataFrame to Pandas DataFrame and then to GeoDataFrame</p><pre># Converting Apache Sdona DataFrame to Pandas DataFrame<br><br>df = df_building.toPandas()<br><br># and then converting the DataFrame to GeoDataFrame<br><br>gdf = gpd.GeoDataFrame(data=df)</pre><p>Downloading Cyprus Buildings in csv format in the Container.</p><pre># Downloading the data in the container in Geojson format<br><br>gdf.to_csv(path_or_buf=&quot;Downloaded_Data/OMF_Buildings.csv&quot;)</pre><h4>3. Downloading the buildings data locally — csv format</h4><p>A new file called Downloaded_Data must be shown up (left panel of jupyter lab). Inside of this folder a file Called OMF_Buildings.csv appears. To download it locally we press right click on it and then download. We save the file in a folder so that we know where it is located.</p><h4>4. Storing the building data in our PostGIS Geodatabase using Python — Anaconda locally (not using docker).</h4><p>Before we start, we must create a virtual environment using conda. In Anaconda Shell we type</p><p><strong>Command Line</strong></p><pre>conda create -n sql python # creating the new environment<br>conda activate sql # activate the new environment<br>conda install ipython-sql sqlalchemy psycopg2 notebook pandas geopandas -c conda-forge # installing necessary libraries</pre><p><strong>Python</strong></p><pre># importing libraries<br>import os<br>from sqlalchemy import create_engine<br>from sqlalchemy import inspect<br>import pandas as pd<br>import geopandas as gpd</pre><pre># variables for the connection of our database<br><br>host = &quot;localhost&quot; # Geodatabase is local<br>database = &quot;Cyprus_Data&quot; # The name of your Postgres geodatabase<br>user=os.getenv(&quot;USERNAME&quot;) # The username of your geodatabase is using<br>password = os.getenv(&quot;PASSWORD&quot;) # Password of your geodatabase<br>connection_string = f&quot;postgresql://{user}:{password}@{host}/{database}&quot;<br></pre><pre># Inspect the engine if it is working<br>insp = inspect(engine)<br>Cyprus_Data_tables = insp.get_table_names() # Here we collect all the tables of our database to see if it is working</pre><p>To store the data in PostGIS first we must create a new null table in PostGIS. One way to do this is using this code in python.</p><pre>%%sql # Magic command in python to &#39;transform&#39; the cell in a &#39;sql cell&#39;<br><br># only lower case to name a table in a database (e.g. omf_buildings)<br><br>CREATE TABLE omf_buildings(name varchar, geom geometry);</pre><p>or</p><p>In your pgAdmin 4 you find your database -&gt; tables -&gt; create new table (please use only lower case to name the new table).</p><p>Loading omf_building using geopandas</p><pre>CY_Buildings.to_postgis(name=&#39;omf_buildings&#39;, con=engine, if_exists=&#39;replace&#39;, index=False)</pre><p>💡<em>Hint: If your other geospatial data in the is in different EPSG from 4326, I suggest you to transform the omf_building to that EPSG. For me the EPSG is 6312 (For Cyprus).</em></p><p>Transforming the EPSG.</p><pre>CY_Buildings = gpd.read_postgis(sql= &quot;SELECT * FROM omf_buildings&quot;,con = engine,geom_col=&#39;geometry&#39;)<br><br># Replace 4326 and 6312 with your current and target EPSG codes<br>source_epsg = 4326<br>target_epsg = 6312<br><br># Transform the geometry column to the new EPSG using SQL<br>sql_query = f&quot;&quot;&quot;<br>SELECT *, ST_Transform(geometry, {target_epsg}) AS transformed_geom<br>FROM omf_buildings;<br>&quot;&quot;&quot;</pre><pre>transformed_gdf = gpd.read_postgis(sql_query, con=engine,geom_col=&quot;transformed_geom&quot;)<br><br># Save the transformed GeoDataFrame back to the database<br>transformed_gdf.to_postgis(&quot;your_table_name_transformed&quot;, con=engine, if_exists=&quot;replace&quot;, index=False)</pre><p>5. Using QGIS to visualize Cyprus Buildings which are stored in our PostGIS database.</p><p>Database Tab -&gt; DB Manager -&gt; Cyprus Data (name of GeodataBase) -&gt; omf_buildings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bpp8h4_Ism6YoRHB5gUVZg.png" /></figure><p>Let’s try the new 3D Tiles in QGIS version 3.34. So fast … 🚀🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zhaTPdJ9gh2jlTfXIEQYXA.png" /></figure><h3><a href="https://plainenglish.io/">PlainEnglish.io</a> 🚀</h3><p><em>Thank you for being a part of the In Plain English community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer</em><strong>️</strong></li><li><em>Learn how you can also </em><a href="https://plainenglish.io/blog/how-to-write-for-in-plain-english"><strong><em>write for In Plain English</em></strong></a><em>️</em></li><li><em>Follow us: </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>X</em></strong></a><strong><em> | </em></strong><a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><strong><em> | </em></strong><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><strong><em> | </em></strong><a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em> | </em></strong><a href="https://newsletter.plainenglish.io/"><strong><em>Newsletter</em></strong></a></li><li><em>Visit our other platforms: </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a><strong><em> | </em></strong><a href="https://cofeed.app/"><strong><em>CoFeed</em></strong></a><strong><em> | </em></strong><a href="https://venturemagazine.net/"><strong><em>Venture</em></strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=473f5175f241" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/downloading-overture-map-foundations-buildings-data-using-apache-sedona-with-docker-python-and-473f5175f241">Downloading Overture Map Foundation’s buildings data using Apache Sedona with Docker — Python and…</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make a unique beautiful basemap using QGIS]]></title>
            <link>https://medium.com/@pavlosdemetriades99/how-to-make-a-unique-beautiful-basemap-using-different-basemaps-in-qgis-8acc05221f71?source=rss-a045a9932f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8acc05221f71</guid>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[qgis]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[geography]]></category>
            <dc:creator><![CDATA[Pavlos Demetriades]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 10:16:37 GMT</pubDate>
            <atom:updated>2024-09-07T06:48:05.774Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to make a unique - beautiful basemap using QGIS</h3><blockquote>Our wanted final result is</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XqtAK8AfTpbiz2v0arNLCw.png" /><figcaption>Final Result of our unique basemap in QGIS</figcaption></figure><blockquote>What a basemαp is:</blockquote><p><a href="https://gisgeography.com/basemap/">A basemap is a layer that provides geographical context to the map and other dataset layers above it</a>. <a href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/map-authoring/author-a-basemap.htm">It serves as a reference map on which you overlay data from layers and visualize geographic information</a>. <a href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/map-authoring/author-a-basemap.htm">An individual basemap can be made of multiple feature, raster, or web layers</a>. <a href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/map-authoring/author-a-basemap.htm">Basemaps are the foundation for your maps and provide context for your work</a>.</p><blockquote>What is QGIS?</blockquote><p><a href="https://www.qgis.org/en/site/">QGIS is a free and open-source geographic information system that allows you to create, edit, visualize, analyze, and publish geospatial information</a>.</p><blockquote>Making a beautiful basemap</blockquote><p>For making a beautiful basemap we will use Carto Dark and F4 Map — 2D basemaps. For finding these two basemaps, HCMGIS plug-in is neccessary to be installed in QGIS. This is a simple step. When you open QGIS go to:</p><ul><li>Plugins (In tab menu) -&gt; Manage and Install Plugins.. -&gt; All -&gt; HCMGIS -&gt; Install Plugin (In this case Reinstall Plugin button appears).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wm0wc6DMGFkn6QOFmklvg.png" /></figure><h4>Loading Cart Dark and F4 Map — 2D basemaps</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*sm8sy-1RRrl5wGl6WIEPag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9eTNV7qCQfOQlvzd6RSbyA.png" /><figcaption>Cart Dark basemap (Left) &amp; Layer Styling (Right)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnwMgRXGKxttzC7QG0J3JQ.png" /><figcaption>F4 Map — 2D basemap (Left) &amp; Layer Styling (Right)</figcaption></figure><p>Next steps:</p><ul><li>Duplicate the Cart Dark basemap (Called it Carto Dark copy)</li><li>Make a Group in QGIS and called it BACKGROUND (optional)</li><li>Put basemaps in the Group (BACKGROUND) with this order</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*lia8ba_QBZ5y9I__lDSZ_g.png" /></figure><ul><li>Then follow the Layer Styling properties (Right side) of each basemap, the properties are as follows.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WKCfnm4_8gGpdHdhfwXnAQ.png" /><figcaption>Layer Styling Properties of the F4 Map — 2D Basemap (Don’t be scary if all turned to black)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueBD0dRRETcSVfohMJYA1A.png" /><figcaption>Layer Styling Properties of the Carto Dark</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzurnTLSBYxj5fYdiE76TQ.png" /><figcaption>Layer Styling Properties of the Carto Dark copy</figcaption></figure><p>Wow ! That’s an amazing unique basemap.</p><p>Also, you can fill it with you own geospatial data, like building and roads</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIdrPr4hddG5MPTwVSzFZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3MpvSx1GheDBGKiqf2V2Bw.png" /><figcaption>Bigger picture with Buildings</figcaption></figure><p>Tip💡: You can change the properties of the Layer Styling with your own way. For example, change the color of colorize to pink and gamma to 1.39 (In Carto Dark copy).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*87VHQYUxkqvGzKUJoCgN7A.png" /><figcaption>Result after changing Dark Carto copy properties of Layer Styling</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8acc05221f71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Urban Green Spaces can be affected by Socioeconomic Factors and Land Uses]]></title>
            <link>https://medium.com/@pavlosdemetriades99/how-urban-green-spaces-can-be-affected-by-socioeconomic-factors-and-land-uses-c682e5ba7539?source=rss-a045a9932f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c682e5ba7539</guid>
            <category><![CDATA[remote-sensing]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[google-earth-engine]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[geospatial-data]]></category>
            <dc:creator><![CDATA[Pavlos Demetriades]]></dc:creator>
            <pubDate>Mon, 28 Aug 2023 21:22:25 GMT</pubDate>
            <atom:updated>2023-09-07T18:03:33.993Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was made according to a Streamlit application that I have created. You can go to application by following the <a href="https://remote20sensing20app20-20introductionpy-myvoxzalycr9w5r9vsivov.streamlit.app/"><strong><em>link</em></strong> </a>👈</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z704Mm-w7A5fSft45lC0aQ.png" /><figcaption>New York City Map (by author)</figcaption></figure><blockquote>1.1 Introduction</blockquote><p>The aim of this article is “How green spaces are affected by socio-economic factors and land use”, with a focus on the case of New York City. The article includes an introduction and sections on Luxury Effect, Land Use Effect and Legacy Effect, Datasets and a Bibliography. All sections include graphs, charts, and maps to support the analysis. The article concludes that there is a strong correlation between green spaces and mean income, land use, and historic districts, and suggests further analysis with additional indicators and dynamic maps for more representative results. The article is made of four sections. The 1st examines how Luxury Effect can affect Urban Green Spaces (UGS) and the 2nd and 3rd subsections examine how Land Use Effect and Legacy Effect can affect UGS, respectively. The 4th is about the Datasets that are being used in this project.<br>The Socioeconomic Factors which will be examined are:</p><ul><li>Household Mean Income (Luxury Effect)</li><li>Historic Districts (Legacy Effect)</li></ul><p>Why New York City? New York City is one of the biggest megacities in the world and has plenty of green spaces (e.g. Central Park), so it is perfect for this projet. Also, someone can find many sources with New York city’s data (e.g. mean income), such as NYC Open Data Program, United States Census etc.</p><p>Green spaces are an integral part of urban fabric, and their relationship should be characterized as inseparable. Green spaces refer to areas where vegetation is present, including parks and squares, generally providing spaces for residents to freely walk and connect with nature. According to Angelos Siolas (2015), green spaces, also known as “Urban Green Spaces”, are the points where the city meets nature. Green spaces should be an integral part of every neighborhood, and their distribution should be uniform, with sizes sufficient to meet the needs of all residents.</p><p>Numerous studies have shown that green spaces are influenced by various socio-economic factors. Hai-Li Zhang et al. (2021) studied how green spaces depend on property values, the history of the area, land uses, and other factors in two different periods. Mendel Giezen (2018) used satellite images to detect a reduction in green spaces over time due to increased construction. Therefore, the purpose of this study is to identify the correlation between certain socio-economic factors and green spaces in <strong>two time periods (2011 and 2019) </strong>at the level of USA Tract.</p><p>It is important to note<strong> that in this study, green spaces refer specifically to areas with vegetation.</strong> Green spaces in cities offer various benefits that make the relationship between nature and the urban environment inseparable. They can act as natural carbon sinks, absorbing carbon dioxide emissions from vehicles. They also reduce the likelihood of flooding by absorbing atmospheric precipitation and help control soil erosion. Additionally, green spaces function as noise reduction tools in cities and simultaneously creating a more pleasant and sustainable living environment for residents. Furthermore, green spaces can be considered as temperature regulators, mitigating the heat island effect predominantly found in urban areas. Lastly, they undoubtedly enhance the aesthetics of the city, providing a more visually appealing environment.</p><blockquote>1.2. Luxury Effect vs Urban Green Spaces</blockquote><p><strong><em>A plot with Mean Income and Green [%]</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7WyqzrGyG_Ruwzj08SHiA.png" /><figcaption>Green with Mean Income (by author)</figcaption></figure><p>If someone zoom-in from 0–150k (for interaction with the plots visit this <a href="https://remote20sensing20app20-20introductionpy-myvoxzalycr9w5r9vsivov.streamlit.app/Luxury_Effect_vs_Urban_Green_Spaces"><strong><em>page</em></strong></a> 👈), it will appear a positive correlation between Mean Income and Urban Green Spaces (Green [%]). Although this positive correlation occurs (from 0 -150k), something weird is happening with the highest values of Mean Income, they behave like outliers, isn’t it? The highest values of Mean Income correspond with the lowest values of the Green [%]. Respectively this is happening with the highest values of the Green [%] and the lowest values of the Mean Income. So, what actually is going on? I think a map creation will unveil what really is happening at a spatial level.</p><p><strong><em>Maps with Mean Income tracts and “Green Tracts”</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2cTXNC46oo-bOpREenhXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o1tA9-xK6hac00Sz3j_DvA.png" /><figcaption>Green [%] and Houshold Mean Income 2011 (by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUAcGf5bB-6sQsHP029vPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NCup-Vq40TBjT7pldTupw.png" /><figcaption>Green [%] and Houshold Mean Income 2019 (by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZ76fwjLq_mi5xO_Ga_VsA.png" /><figcaption>2D Map (kepler.gl) — Mean Income &amp; Green Tracts (by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XoLf1TiTsfmlm0-V2cxApA.png" /><figcaption>3D Map ( kepler.gl)— Mean Income &amp; Green Tracts (by author)</figcaption></figure><p><em>For seeing the full legend, please consider both maps (2d &amp; 3d)</em></p><p>Let’s focus initially on the high values of green spaces, as we are examining the relationship between green spaces and mean income. The majority of tracts with high values of green spaces are mainly located in Staten Island and Queens. In both cases, there are high percentages of mean income. On the contrary, in the Bronx and Brooklyn (in terms of low-income values), the tracts have the lowest values of green spaces and also lower mean income values. In these three cases, a strong correlation is observed between green spaces and mean income values. What is particularly striking is the very low percentage values found in most tracts in Manhattan and the very high mean income values. An attentive observer will notice that most tracts in Manhattan <strong>are adjacent to Central Park, the largest park in New York City</strong>. As shown on the above map, Central Park has a large percentage of green spaces. A similar phenomenon is also observed in the case of low percentage values of green spaces and very high mean income values.</p><p><strong><em>Conclusions</em></strong></p><ul><li>1st: There is a positive correlation between UGS and Mean Income.</li><li>2nd: There is a ‘mandatory’ need for more realistic indices than the plot (Mean Income and UGS) for more realistic results.</li><li>3rd: This example shows the necessity of map creation.</li><li>4th: This example reveals the complexity of the spatial characteristics, the real world.</li></ul><blockquote>1.3 Land Use Effect vs Urban Green Spaces</blockquote><p>For the Land Use Effect, a classification has been made for the two epochs. As mentioned before, aerial images from NAIP Imagery program were used, so the classification refers to those images. Also, a further analysis was done with the creation of a change detection map.</p><p>For more details about the Classifications (e.g. Accuracies, maps), go to this <a href="https://remote20sensing20app20-20introductionpy-myvoxzalycr9w5r9vsivov.streamlit.app/Land_Use_Effect_vs_Urban_Green_Spaces"><strong><em>page</em></strong></a> 👈.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89JoMnJmFnFDp7jChz9C2Q.png" /><figcaption>Screenshot of Streamlit Application (by author)</figcaption></figure><p><em>Quantification of Land Uses</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*jJcuA9QJx38S1Ei3pmKRtw.png" /><figcaption>Table of the Quantification of Land Uses (by author)</figcaption></figure><p>The percentage of the change that UGS had was approximately +4%. The positive symbol means the positive percentage change in the overall percentage of all tracts. The biggest change is located on the Artifacts, with a percentage of 7.4%. This may be due to the large percentage change in the shadow category (~7.3% Epoch 2019). A pleasant phenomenon that appears is that there is a huge percentage of Green in New York City in both periods.</p><p>Plots: Artifacts vs Urban Green Spaces</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LmzHvUFJfvQBm8gDfFwt6w.png" /><figcaption>Plots of Artifacts vs Urban Green (by author)</figcaption></figure><p>There is an obvious negative correlation between Artifacts and UGS. Also, the majority of the tracts have a higher percentage of Artifacts [%] than Green [%].</p><p><strong><em>Quantification of change detection of land uses for the epochs 2019 &amp; 2011</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*XfwvqqdiaIZD_4YszbIguA.png" /><figcaption>Table of Quantification of change detection of land uses (by author)</figcaption></figure><p>CrossClassCode column’s numbers correspond to the numbers of a Change Detection Image. (Don’t pay attention to this).</p><p><strong><em>Change Detection</em></strong></p><p><em>From Trees to Buildings</em></p><p><em>Yellow circles show the correct change detections and Red Circles the false change detections</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*zkUJwNlEo7Rk-M0s491Ung.png" /><figcaption>From Trees to Buildings (image by author)</figcaption></figure><p>The main change detection in this picture is the appearance of the big building in 2019.</p><p>From Buildings to Trees</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*MA697aaLSxGhUAsKlG71vQ.png" /><figcaption>From Buildings to Trees (image by author)</figcaption></figure><p>In this case, most detections which appear in blue are false. This may be due to the Image 2011 which has not been preprocessed. In respect to this, this case shows the necessity of the preprocess method to be made for an image, especially for an image that will be used for a change detection. Also, another thing that pops up is the necessity of the two images to have the same resolutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*Jo-PGj_RNJrNSnYWr4Cd1Q.png" /><figcaption>From Buildings to Grass (image by author)</figcaption></figure><p>In this case this change detection shows the change between Buildings and Grass.</p><p><strong><em>Conclusions</em></strong></p><ul><li>1st: For a change detection, it is mandatory, the two image will have the same resolutions and be preprocessed</li><li>2nd: UGS are depended on a huge level from Land Uses, specifically there is a negative dependance with the Artifacts (Buildings and Roads).</li><li>3rd: New York city has a big percentage of Green in US tracts in both periods.</li></ul><blockquote>1.4 Legacy Effect vs Urban Green Spaces</blockquote><p><strong><em>Map of Historic Districts</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1e03Mk6et89ZunVUn6hOxg.png" /><figcaption>Map of Historic Districts (by author)</figcaption></figure><p>Someone can notice that most Historic Districts have more than 20% of the UGS. This is a great index, which shows that someone can find a wide area of UGS in such places. Another thing that pops up is the positive spatial relation between UGS and Historic Districts.</p><p>Plot with Green Percentage of two Epochs into Historic Districts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6LbspRCGXSg3f-XDMgKkw.png" /><figcaption>A plot of Green [%] within Historic District (by author)</figcaption></figure><p>This chart is plotting the Percentage of the Urban Green Spaces and the Historic Districts. On the X axis, are the IDs and on the Y axis the percentage, in the two epochs respectively. When the two dots (blue and purple) intersect each other, it means that the percentage of the UGS on a specific Historic District didn’t change. Therefore, if the blue dot is higher than purple dot, that means the UGS in a Historic Districts saw a rise on the urban green</p><p><strong><em>Conclusions</em></strong></p><ul><li>1st: There is a positive strength correlation of the UGS and Historic Districts</li><li>2nd: Over the years UGS are getting bigger into Historic Districts</li></ul><blockquote>1.5 Datasets</blockquote><p>The Datasets that have been used, are:</p><ul><li>NAIP Imagery Dataset (Land Use Effect)</li></ul><p>The National Agriculture Imagery Program (NAIP) is a program that acquires aerial imagery during the agricultural growing seasons in the United States. The primary goal of the NAIP program is to make digital ortho photography available to governmental agencies and the public within a year of acquisition. The program collects (1-meter imagery for the entire conterminous United States. The imagery is acquired during peak growing season, ‘leaf on’ and delivered to USDA County Service Centers to maintain the common land unit (CLU) boundaries and assist with farm programs.</p><ul><li>Mean Income (Luxury Effect)</li></ul><p>The Mean Income is the mean income of the US households per tract. The dataset is from the US Census Bureau. A tract is the smallest area that is used for the US Census. <a href="https://www.census.gov/programs-surveys/acs">The link of this dataset</a></p><ul><li>Historic Districts (Legacy Effect)</li></ul><p>The Historic Districts Dataset, is a dataset that contains the Historic Districts of the US states. This dataset contains boundaries and associated attribute information for all designated historic districts or areas under consideration for historic district designation (i.e. calendared) by the New York City Landmarks Preservation Commission (LPC), including items that may have been denied designation or overturned. This dataset was taken by <a href="https://opendata.cityofnewyork.us/">NYC Open Data Program NYC Open Data Program</a></p><ul><li>USA tracts</li></ul><p>USA Tract represents the smallest geometrical entity in which US census data are recorded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qrfo-2gQSTlXFk24rdOQzA.png" /><figcaption>New York City Map (by author)</figcaption></figure><blockquote>Bibliography</blockquote><ul><li>Hai-Li Zhang a, J. P.-L.-F. (2021). Wealth and land use drive the distribution of urban green space in the tropical coastal city of Haikou, China. ELSEVIER.</li><li>Mendel Giezen, S. B. (2018). Using Remote Sensing to Analyse Net Land-Use Change from Conflicting Sustainability Policies: ISPRS</li><li>Άγγελος Σιόλας, Α. Β. (2015). Μέθοδοι, Εφαρμογές και Εργαλεία Πολεοδομικό Μετασχηματισμού: Εργαλεία και Τεχνικές. ΑΘΗΝΑ: Kallipos</li><li>Richards, J. A. (2012). Remote Sensing Digital Image Analysis — An introduction. Canbera, Australia: Spring</li><li>Sofia F. Francoa, J. L. (2018). Measurement and valuation of urban greenness: Remote sensing and hedonic applications to Lisbon, Portugal. ELSEVIER</li><li>Wei Lia, J.-D. M. (2014). A comparison of the economic benefits of urban green spaces estimated with NDVI and with high-resolution land cover data. ELSEVIER</li><li>Wu, Q. (2020). geemap: A Python package for interactive mapping with. Geograpgy. The Journal of Open-Source Software.</li><li>Yingdan Mei, X. Z. (2018). Capitalization of Urban Green Vegetation in a Housing Market with Poor Environmental Quality: Journal of Urban Planning and Development.</li><li>Zhonglin Ji, Y. P. (2022). Prediction of Corn Yield in the USA Corn Belt Using Satellite Data and Machine Learning: From an Evapotranspiration Perspective. Basel, Switzerland.: MDPI</li><li>Γεωργούλη, Κ. (2015). Τεχνητή Νοημοσύνη — Μια Εισαγωγική Προσέγγιση. Αθήνα: Kallipos</li><li>Δημήτρης, Α. (1998). Ψηφιακή Τηλεπισκόπηση. Αθήνα</li><li>Ιωάννης, Ψ. (2021). Χαρτογράφηση καμένων εκτάσεων απο διαχρονικά δορυφορικά δεδομένα Sentinel-2 στο περιβάλλον του Google Earth Engine. Αθήνα: ΕΜΠ</li><li>Κωνσταντίνος Γ. Περάκης, Ι. Ν. (2015). Η Τηλεπισκόπηση σε 13 ενότητες. Kallipos</li><li>Σπύρος Φουντάς, Θ. Γ. (2015). Γεωργία Ακριβείας. Kallipos</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c682e5ba7539" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lorenz Curve in Geographic Analysis with Python]]></title>
            <link>https://python.plainenglish.io/lorenz-curve-in-geographic-analysis-with-python-666405b79555?source=rss-a045a9932f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/666405b79555</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[geographical-information]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[lorenz]]></category>
            <dc:creator><![CDATA[Pavlos Demetriades]]></dc:creator>
            <pubDate>Thu, 17 Aug 2023 09:35:39 GMT</pubDate>
            <atom:updated>2023-08-21T00:52:26.790Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>What a Lorenz curve is</blockquote><p>“<em>The Lorenz curve is based on the cumulative frequencies of a frequency distribution table and is used to make comparisons regarding the concentration and inequality of various phenomena, such as income, green distribution, population, employment, etc. The comparison is made with respect to an ideal equal distribution, in which the frequencies of all values in the frequency distribution table are equal. In economics, a classic application of the Lorenz curve is the study of income inequality within a population group. In Geographic Analysis, the data pertains to the geographical distribution of a variable, such as population. In other words, the population does not exhibit a uniform distribution, as some cities are larger and others smaller. With the Lorenz curve, we can graphically represent and measure the inequality. Additionally, it allows for longitudinal comparisons, such as whether the inequality of the population is increasing or decreasing over time, as well as comparisons between different geographic regions for the same phenomenon</em>.” — (Polyxeni, 2017)</p><blockquote>Distribution of Urban Green using Lorenz curve</blockquote><p>The “spatial phenomenon” that is being investigated in this article, is the distribution of urban green. Urban green distribution must be uniform in the neighborhoods as the benefits that are presenting because of it are huge.</p><h4>Why Urban Green is important in cities?</h4><p>Urban green is an integral part of urban fabric, and their relationship should be characterized as inseparable. Urban green refers to areas where vegetation is present, including parks and squares, generally providing spaces for residents to freely walk and connect with nature. According to Angelos Siolas (2015), green spaces, also known as “Urban Green Spaces”, are the points where the city meets nature. Urban green should be an integral part of every neighborhood, and th<strong>eir distribution should be uniform, with sizes sufficient to meet the needs of all residents.</strong></p><p>Urban green in cities offers various benefits such as it can act as natural carbon sinks since absorbing carbon dioxide emissions from vehicles. It also reduces the likelihood of flooding by absorbing atmospheric precipitation and helps control soil erosions. Additionally, urban green functions as noise reduction toll in cities and simultaneously creating a more pleasant and sustainable living environment for residents. Furthermore, urban green can be considered as temperature regulator, mitigating the heat island effect predominantly found in urban areas. Lastly, urban green enhances the aesthetic of a city, providing a more pleasant environment.</p><blockquote>Our Case Study</blockquote><p>As mentioned before, the case study of this article is to make the Lorenz curve of the urban green. The case study takes place in New York City and the data which provides us with the area of urban green in New York City came from a classification of land uses that the author (i.e. Me 😏) made using Google Earth Engine in a US census tract level. Also, the case study is considering two time periods to see how urban green is growing in New York city over the years.</p><p>From now on, when the urban green pops up, it will refer to vegetation of New York City.</p><h4>Python</h4><p>Python libraries that have been used for this analysis are:</p><ul><li>Pandas</li><li><a href="https://plotly.com/">Plotly</a></li><li>Scipy</li></ul><p>Let’s start coding</p><ol><li>Importing our libraries</li></ol><pre># Imorting our Libraries<br>import pandas as pd <br>import plotly.express as px</pre><p>2. Loading our dataset</p><pre><br># Reading our dataset (.csv format) using pandas<br>Lorenz_Data_Frame_2019 = pd.read_csv(&quot;Lorenz_Data_2019.csv&quot;) <br><br># Storing our data in a DataFrame<br>Lorenz_Data_Frame_2019 = pd.DataFrame(Lorenz_Data_Frame_2019)<br><br># Printing first two rows of our dataset<br>Lorenz_Data_Frame_2019.head(2)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*HGRSK-xloh5g6H9jPBQnww.png" /><figcaption>First two rows of our dataset in a DataFrame format</figcaption></figure><p>Explaining the columns of the DataFrame. As shown above there are three columns. Tract — Green [m²], Tract — Area [m²] and GEOID.</p><ul><li>Tract — Green [m²]: The area [m²]of urban green <strong>in a US census tract.</strong></li><li>Tract — Area [m²]: The area [m²] of a US census tract.</li><li>GEOID: The ID of a US census tract.</li></ul><p>3. Manipulating data for the extraction of Lorenz Curve</p><p>Calculating urban green in all US census tracts to find the sum of all urban green.</p><pre># Calculating all Urban Green<br>All_Green = Lorenz_Data_Frame_2019[&quot;Tract - Green [m^2]&quot;].sum()</pre><pre><br># Calculating the percentage of urban green in each US census tract and <br># The values will be stored in a new column called [&quot;Tract - Green [%] - AK&quot;]<br>Lorenz_Data_Frame[&quot;Tract - Green [%] - AK&quot;] = Lorenz_Data_Frame[&quot;Tract - Green [m^2]&quot;].div(All_Green).mul(100)<br><br># AK stands for Cumulative Distribution in Greek (Athristiki Katanomi)<br><br># If there are Nan Values is our dataset this will present conflict in a division<br><br># Replacing all Nan Values with 0.0 <br>Lorenz_Data_Frame_2019[&quot;Tract - Green [%] - AK&quot;].fillna(value=0.0,inplace=True)<br><br># Printing the results<br>Lorenz_Data_Frame_2019.head(1)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*rsZwuEfum_PUqPm8OdmaIQ.png" /><figcaption>A new column Tract — Green [%] — AK with the percentage of Green in a US census tract</figcaption></figure><pre># Making a new column called &quot;AK [%]&quot; for storing the Cumulative values for the creation of Lorenc Curve<br># Also, the first value of this column is equal to the first value of the column &quot;Tract - Green [%] - AK&quot; .iloc[0]<br># This is mandatory for the mathematical operation of the CD<br><br>Lorenz_Data_Frame_2019[&quot;AK [%]&quot;] = Lorenz_Data_Frame_2019[&quot;Tract - Green [%] - AK&quot;].iloc[0]<br><br># Creation of a for loop for the calculation of the Cumulative values green<br><br>for i in range(len(Lorenz_Data_Frame.index) - 1): # -1 because we are starting for the 1st value<br>    <br>    j = i + 1 # j represents the next value and i the previous<br>    Lorenz_Data_Frame.loc[j,&quot;AK [%]&quot;] = Lorenz_Data_Frame.loc[j,&quot;Tract - Green [%] - AK&quot;] + Lorenz_Data_Frame.loc[i,&quot;AK [%]&quot;]<br>    i = i + 1<br><br># Let&#39;s print the results<br><br>Lorenz_Data_Frame_2019.head(3)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*2OAxvLSUc91kLGUxVH5_mg.png" /><figcaption>Results after for loop</figcaption></figure><p>So, let’s take a look at AK [%] values. As mentioned before the 1st value of Tract — Green [%] — AK equals to 1st value of AK [%] column. The second value of AK[%] (0.366064 = 0.108636 + 0.257428) column equals with the 1st value of AK[%] (0.108636) plus the second of Tract — Green [%] — AK (0.257428). So, the 3rd value of AK[%] (0.475576) equals with second of AK[%] (0.366064) plus the third value of Tract — Green [%] — AK (0.109512).</p><p>4. Same process for the uniform Distribution</p><pre># Making the same process for the uniform Distribution<br><br># Calculating the ideal percentage of urban green for a US census tract<br># in a new column called &quot;Tract - Uniform Green [%]&quot;<br><br><br>Lorenz_Data_Frame_2019[&quot;Tract - Uniform Green [%]&quot;] = (100/len(Lorenz_Data_Frame)) <br><br># Storing the first value of the new column &quot;AK Uniform [%]&quot; as we did before<br>Lorenz_Data_Frame_2019[&quot;AK Uniform [%]&quot;] = Lorenz_Data_Frame_2019[&quot;Tract - Uniform Green [%]&quot;].iloc[0]<br><br># Creation of a for loop for the calculation of the Cumulative values (Uniform Distribution)<br>for i in range(len(Lorenz_Data_Frame_2019.index) - 1):<br>    #print(i)<br>    j = i + 1<br>    Lorenz_Data_Frame_2019.loc[j,&quot;AK Uniform [%]&quot;] = Lorenz_Data_Frame_2019.loc[j,&quot;Tract - Uniform Green [%]&quot;] + Lorenz_Data_Frame.loc[i,&quot;AK Uniform [%]&quot;]<br>    i = i + 1<br><br># Let&#39;s print the results<br>Lorenz_Data_Frame_2019.head(3)</pre><p>Let’s see our results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*An-J6XrL2V_58H8dmz4w7Q.png" /><figcaption>Results after for loop</figcaption></figure><p>For creating the line of uniform distribution all US census tracts must have the same percentage, as the column Tract — Uniform Green [%] shows. The column AK Uniform [%] shows the cumulative values as they resulting from these two columns, with the same way as mentioned above.</p><p>5. Plotting our results using <a href="https://plotly.com/python/">Plotly</a> to make Lorenz Curve</p><p>As mentioned above, to see how the distribution of urban green is going over the years, we should consider two time periods. As a result, we must make the same process with data coming from another period (* the two time periods should have as big deviation as it possible for better results). So, in our case data from 2011–2013 were taken. The process of calculating the Cumulative values of this period is the same as above.</p><p>Let’s plot our results.</p><pre># Importing our libraries<br>import plotly.express as px<br>import plotly.graph_objects as go<br>from scipy import signal<br><br><br># Making a figure for plotting our results<br>fig = go.Figure()<br><br><br># <br>fig.add_trace(go.Scatter(<br>    x=Lorenz_Data_Frame.index,<br>    y=signal.savgol_filter(Lorenz_Data_Frame_2011[&quot;AK [%]&quot;],<br>                          1000, # window size used for filtering<br>                           5), # order of fitted polynomial<br>    mode=&#39;markers&#39;,<br>    marker=dict(<br>        size=5,<br>        color=&#39;mediumpurple&#39;,<br>        #symbol=&#39;triangle-up&#39;<br>    ),<br>    name=&#39; 2011 Green Distribution&#39;<br>))<br><br>fig.add_trace(go.Scatter(<br>    x=Lorenz_Data_Frame_2019.index,<br>    y=signal.savgol_filter(Lorenz_Data_Frame_2019[&quot;AK [%]&quot;],<br>                           1000, # window size used for filtering<br>                           5), # order of fitted polynomial<br>    mode=&#39;markers&#39;,<br>    marker=dict(<br>        size=5,<br>        color=&#39;darkgreen&#39;,<br>        #symbol=&#39;triangle-up&#39;<br>    ),<br>    name=&#39; 2019 Green Distribution&#39;<br>))<br><br>fig.add_trace(go.Scatter(<br>    x=Lorenz_Data_Frame.index,<br>    y=signal.savgol_filter(Lorenz_Data_Frame_2019[&quot;AK Uniform [%]&quot;],<br>                           20, # window size used for filtering<br>                           5), # order of fitted polynomial<br>    mode=&#39;markers&#39;,<br>    marker=dict(<br>        size=5,<br>        color=&#39;mediumblue&#39;,<br>        ##symbol=&#39;triangle-up&#39;<br>    ),<br>    name=&#39; Uniform Green Distribution&#39;<br>))<br><br>fig.show(height = 30)</pre><h4>Explanation of code (Thanks ChatGPT 😏)</h4><p>“This code snippet is using the Plotly library in Python to create a plot of Lorenz curves for different distributions (about urban green). It seems like you are comparing the Lorenz curves for three different distributions: one from 2011, another from 2019, and a uniform distribution. The Lorenz curves are smoothed using the Savitzky-Golay filter to provide a clearer representation.</p><p>Here’s a breakdown of the code:</p><ol><li>Importing necessary libraries:</li></ol><ul><li><em>‘plotly.express as px’ </em>is used for creating interactive plots.</li><li><em>‘plotly.graph_objects as go’ </em>is used for more control over the plot details.</li><li><em>‘from scipy import signal’ </em>is used to access the Savitzky-Golay filter.</li></ul><p>2. Creating the figure object:<br> ‘<em>fig = go.Figure()’</em></p><p>3. Adding traces (lines or markers) to the figure for each distribution:</p><ul><li>Three traces are added to the figure, each corresponding to a different distribution (2011, 2019, and uniform).</li><li>The x-axis values are taken from `Lorenz_Data_Frame.index`, which presumably represents the data points’ indices.</li><li>The y-axis values are calculated using the Savitzky-Golay filter on the corresponding distribution data from `Lorenz_Data_Frame_2019`.</li><li>The `<em>mode=’markers</em>’` indicates that scatter markers will be used for the plot.</li><li>The `<em>marker</em>` dictionary is used to customize marker properties, such as size and color.</li><li>The `<em>name</em>` parameter assigns a label to each trace, which will be shown in the plot legend.</li></ul><p>4. Displaying the plot:<br><em> ‘fig.show(height=30)’</em><br> The `fig.show()` function is used to display the plot. The `height` parameter is set to 30 to adjust the plot’s height.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GMMbRguM96Cdlys1hSx33A.png" /><figcaption>The result of f<em>ig.show(height=30)</em></figcaption></figure><p>In summary, this code creates a plot showing smoothed Lorenz curves for three different distributions (2011, 2019, and uniform).<strong> The Savitzky-Golay filter is applied to make the curves smoother</strong>. The colors and labels are customized, and the final plot is displayed using Plotly.”</p><p>Boom … I think it is right … Thanks ChatGPT for this awesome explanation.</p><h4>Let’s discuss our results</h4><ul><li>1st: Green and purple lines must end in 100 in y axis. This deviation occurs because of the Savitzky-Golay filter.</li><li>2nd: There is a purple line 😎</li></ul><p>Let’s get to the point now … about urban green distribution</p><ul><li>Comparing 2019 and 2011 urban green distribution there is no difference.</li><li>Comparing the uniform line with the other two, visually the distribution of urban green (spatial phenomenon) deviates quite a bit from the uniform.</li></ul><blockquote>Bibliography</blockquote><p>Geographical Analysis, Polyxeni Iliopoulou, 2017</p><h3>In Plain English</h3><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, and <a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=666405b79555" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/lorenz-curve-in-geographic-analysis-with-python-666405b79555">Lorenz Curve in Geographic Analysis with Python</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment of a Drainage Basin and Stream Network using Python]]></title>
            <link>https://medium.com/@pavlosdemetriades99/1-deployment-of-a-drainage-basin-and-stream-network-using-python-d709d47f05d2?source=rss-a045a9932f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d709d47f05d2</guid>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[hydrology]]></category>
            <dc:creator><![CDATA[Pavlos Demetriades]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 11:58:51 GMT</pubDate>
            <atom:updated>2024-03-04T17:06:16.729Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Understanding Drainage Basin and Stream Network (BSN)</blockquote><h4>What a Basin is</h4><p>A <strong>drainage basin</strong> is an area of land where all flowing surface water converges to a single point, such as a river mouth, or flows into another body of water, such as a lake or ocean. A basin is separated from adjacent basins by a perimeter, the drainage divide, made up of a succession of elevated features, such as ridges and hills. The drainage basin or watershed is a fundamental landscape unit in fluvial geomorphology. A drainage basin contains a primary, or trunk, river and its tributaries. Watersheds are separated from their neighbors by a divide; a highpoint where water flows in different directions on either side.</p><h4>What a Stream Network is</h4><p>A <strong>stream network</strong> is a system of interconnected streams and rivers that drain water from a particular area. S<strong>tream networks can be delineated from a digital elevation model (DEM) using the output from the Flow Accumulation tool</strong>. Flow accumulation in its simplest form is the number of upslope cells that flow into each cell1. Once created, the stream network can be further analyzed using the Stream Order, Stream Link, and Stream to Feature tools, for ordering (ranking) the streams, assigning unique IDs to stream links, or creating a feature dataset, respectively.</p><h4>Basin and Stream Network (BSN)</h4><p>BSN is a process used to simulate hydrological processes and model river flows. It is essential in a range of applications from flood prediction to ecosystem management</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UuWivxpr4xXTYlBqWbLNQ.png" /><figcaption>Drainage Basin (pink polygon) and Stream Network (Strahler Order — Colormap: Blues)</figcaption></figure><h4>Why Deploy BSN using Python?</h4><p>Python provides a range of libraries and computational tools that make deploying BSN easier, faster, and more accurate than manual methods.</p><h4>Applications of BSN</h4><p>BSN has many applications, including flood risk management, water resource management, habitat restoration, and ecosystem management.</p><blockquote>Leafmap: Α Geospatial Python Package</blockquote><p>Leafmap is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is a free and open-source <strong>Python package</strong> that enables users to analyze and visualize geospatial data with minimal coding in a Jupyter environment. Leafmap is built upon several open-source packages, such as <a href="https://github.com/python-visualization/folium">folium</a> and <a href="https://github.com/jupyter-widgets/ipyleaflet">ipyleaflet</a> (for creating interactive maps), <a href="https://github.com/jblindsay/whitebox-tools"><strong>WhiteboxTools</strong></a> and <a href="https://github.com/opengeos/whiteboxgui">whiteboxgui</a> (for analyzing geospatial data), and <a href="https://github.com/jupyter-widgets/ipywidgets">ipywidgets</a> (for designing interactive graphical user interface [GUI]). Leafmap has a toolset with various interactive tools that allow users to load vector and raster data onto the map without coding. In addition, users can use the powerful analytical backend (i.e., WhiteboxTools) to <strong>perform geospatial analysis</strong> directly within the leafmap user interface without writing a single line of code. The WhiteboxTools library currently contains 500+ tools for advanced geospatial analysis, such as <a href="https://jblindsay.github.io/wbt_book/available_tools/gis_analysis.html">GIS Analysis</a>, <a href="https://jblindsay.github.io/wbt_book/available_tools/geomorphometric_analysis.html">Geomorphometric Analysis</a>, <a href="https://jblindsay.github.io/wbt_book/available_tools/hydrological_analysis.html">Hydrological Analysis</a>, <a href="https://jblindsay.github.io/wbt_book/available_tools/lidar_tools.html">LiDAR Data Analysis</a>, <a href="https://jblindsay.github.io/wbt_book/available_tools/mathand_stats_tools.html">Mathematical and Statistical Analysis</a>, and <a href="https://jblindsay.github.io/wbt_book/available_tools/stream_network_analysis.html">Stream Network Analysis</a>.</p><blockquote>Getting started with BSN Deployment in Python</blockquote><h4>Dataset Preparation</h4><p>To deploy BSN using Python, you need to prepare a Digital Elevation Model (DEM) of the area of interest and relevant hydrological data (optional). The methodological framework for the deployment of BSN is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*0OHZFofu1_xKYYEO_Xh3ng.png" /><figcaption>Methodological Framework for the deployment of BSN</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cgLOPFZIxL6iha7ghTMtvA.png" /><figcaption>Our Digital Elevation Model (DEM) after Batch Deppression</figcaption></figure><h4>Python (Deployment of Drainage Basin)</h4><pre># Importing libraries<br>import whitebox <br>import leafmap<br>import leafmap.foliumap<br>wbt = whitebox.WhiteboxTools()</pre><pre># Calling leafmap.Map() function for the visualization of Map<br>Map = leafmap.Map()</pre><pre># Define the working environment (path) which the DEM is located<br>wbt.set_working_dir(&#39;\path&#39;)</pre><pre># 1. Batch depressions of Digital Elevation Model (DEM)<br>wbt.breach_depressions(dem = &quot;DEM_2m.tif&quot;, output = &quot;DEM_BreachDepression.tif&quot;)</pre><pre># 2. Calculation of flow Direction<br>wbt.d8_pointer(dem = &quot;DEM_BreachDepression.tif&quot;, output = &quot;D8_Pointer_python.tif&quot;)</pre><pre># 3. Calculation of Basin<br>wbt.basins(d8_pntr=&#39;D8_Pointer_python.tif&#39;, output = &quot;Basins_python.tif&quot;)<br><br># 4. RasterToVectorPolygon<br>wbt.raster_to_vector_polygons(i = &quot;Basins_python.tif&quot;,output=&quot;Basins_python_Shapefile.shp&quot;)</pre><pre># Visualization of all raster layers (.tif)<br>Map.add_raster(source = &quot;DEM_BreachDepression.tif&quot;, layer_name=&quot;DEM_Breach_Deppression&quot;)<br>Map.add_raster(source = &quot;D8_Pointer_python.tif&quot;,layer_name = &quot;D8_Pointer&quot;)<br>Map.add_raster(source = &quot;Basins_python.tif&quot;, layer_name = &quot;Basins&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oeDsNA4oKAGNhidZ2tmlrg.png" /><figcaption>Drainage Basins in Leafmap</figcaption></figure><h4>Python (Deployment of Stream Network)</h4><pre># 1. Calculation of Flow Accumulation<br># pntr = TRUE -&gt; because i = D8_Pointer..<br># log = True<br># These are optional (pntr,log)<br>wbt.d8_flow_accumulation(i=&#39;D8_Pointer_python.tif&#39;,output=&quot;D8_Flow_Accumulation_Python.tif&quot;,log=True,pntr=True)<br>Leafmap_Map.add_raster(source=&quot;D8_Flow_Accumulation_Python.tif&quot;, layer_name=&quot;Flow_Accumulation&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSafYEKlXpWjk0h5hUENfA.png" /><figcaption>Flow Accumulation</figcaption></figure><pre># 2. Deployment of Stream Network<br># Threshold value selected after different options of its value<br>wbt.extract_streams(flow_accum=&quot;D8_Flow_Accumulation_Python.tif&quot;,output=&quot;Stream_Network_python.tif&quot;,threshold=5)</pre><pre># 3. Ordering the stream order by Strahler Order<br>wbt.strahler_stream_order(d8_pntr=&quot;D8_Pointer_python.tif&quot;,streams=&quot;Stream_Network_python.tif&quot;,output=&quot;Strahler_Stream_Order_python.tif&quot;,zero_background=True)<br># Adding stream network (by Strahler Order) as a local_tile pallete = Blues<br>Leafmap_Map.add_local_tile(source=&quot;Strahler_Stream_Order_python.tif&quot;,layer_name=&quot;Strahler_Stream_Order_python.tif&quot;,palette=&quot;Blues&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYXpBS1THAoj2lGrqhTN3w.png" /><figcaption>Stream Network (by Strahler Order)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dRyIrshLhUdjOiAIaQmWw.png" /><figcaption>Drainage Basin and Stream Network in Leafmap</figcaption></figure><pre># 4. Vectorization of Strahler Order Stream Network <br><br>wbt.raster_to_vector_lines(i=&quot;Strahler_Stream_Order_python.tif&quot;,output=&quot;Strahler_Stream_Order_python.shp&quot;)</pre><p>Bibliography in Greek</p><ul><li>Υδρολογία με χρήση Γεωγραφικών Συστημάτων Γεωπληροφορικής και δεδομένων Τηλεπισκόπησης — Νικόλαος Ι. Λαμπράκης, Κωνσταντίνος Γ. Νικολακόπουλος, Κωνσταντίνα Ν Κατσάνου</li><li>Χαρτογραφική Σύνθεση &amp; Απόδοση σε Ψηφιακό Περιβάλλον — Λύσανδρος Τσούλος, Ανδριανή Σκοπελίτη, Λήδα Στάμου</li></ul><p>Bibliography in English</p><ul><li><strong>Hydrology using Geographic Geoinformatics Systems and Remote Sensing data — Nikolaos I. Lambrakis, Konstantinos G. Nikolakopoulos, Konstantina N. Katsanou</strong></li><li>Cartographic Composition &amp; Performance in a Digital Environment — Lysandros Tsoulos, Andriani Skopeliti, Leda Stamou</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d709d47f05d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>