<?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 Jared Yamaoka on Medium]]></title>
        <description><![CDATA[Stories by Jared Yamaoka on Medium]]></description>
        <link>https://medium.com/@xander80?source=rss-b0a8e0ce7d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3jUmjlUgLiWsnQ_JYaWRxQ.jpeg</url>
            <title>Stories by Jared Yamaoka on Medium</title>
            <link>https://medium.com/@xander80?source=rss-b0a8e0ce7d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:57:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xander80/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[Identifying Buildings in Satellite Images with Machine Learning and Quilt]]></title>
            <link>https://medium.com/quilt/identifying-buildings-in-satellite-images-with-machine-learning-and-quilt-5a5579670885?source=rss-b0a8e0ce7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a5579670885</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jared Yamaoka]]></dc:creator>
            <pubDate>Wed, 12 Jul 2017 03:33:18 GMT</pubDate>
            <atom:updated>2018-12-28T03:48:55.863Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently there has been interest in using satellite images as <a href="http://dailycaller.com/2016/08/15/hedge-funds-are-using-satellites-to-gain-new-data/">investing tools</a>. Hedge funds are looking at construction in Beijing to bet on concrete demand, or they are counting cars in Walmart parking lots to get an early estimates on profits. Here I discuss a project to determine land use (i.e. is an area a building or not a building) from satellite images. The idea was to measure the change in land use over time as an economic indicator. This project was a proof of concept for the Insight Data Fellows Program.</p><p>Images from the <a href="https://landsat.usgs.gov/landsat-8">Landsat 8 satellite</a> are readily available from several sources, including Amazon Web Services (AWS). The <a href="https://pythonhosted.org/landsat-util/">landsat-util</a> program is a convenient way to search for and download these images. For my test case I chose Austin, TX. Austin has been the <a href="http://www.bizjournals.com/austin/news/2016/12/08/austin-remains-population-magnet-but-growth-in-the.html">2nd fastest growing</a> city in the USA by percent of population over the last five years and has relatively clear skies. Clouds are the bane of satellite image analyses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfNKkuX8L-Bxps4esSm6kA.png" /><figcaption>Austin, TX</figcaption></figure><p>For this project, I also used the Quilt package manager. It enables the creation of data packages that are sharable and portable. More specifically Quilt provides data wrapped in a Python module as well as a repository for the data, a-la github. I downloaded and processed 4 images of Austin and built a Quilt package.</p><h3><strong>Quilt</strong></h3><p>Using the Quilt package is quite simple. The installation instructions can be found <a href="https://quiltdata.com/">here</a>. To follow along this tutorial you can check out my data package with all the images and labels you need to get started.</p><pre>$ quilt install jared/landuse_austin_tx</pre><p>From here you can browse the package in Python:</p><pre>&gt;&gt;&gt; from quilt.data.jared import landuse_austin_tx<br>&gt;&gt;&gt; landuse_austin_tx<br>&lt;PackageNode &#39;/quilt_packages/jared/landuse_austin_tx&#39;&gt;<br>images<br>labels<br>metadata</pre><p>I provide the original images as well as images cropped to a region around the city. These crops are much more manageable at 2 mega pixels (MP) than the computer crushing 60MP of the full images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*eOOhyB-GeQbKUqU6cw7hgg.png" /><figcaption>Cropped region of Austin, TX</figcaption></figure><p>For my training image, I have chosen to use LC80270392014022LGN00 which is from 1/14/2014. A description of the naming convention can be found <a href="https://gisgeography.com/landsat-file-naming-convention/">here</a>. This was chosen because of the low cloud cover. To access the image containing light with wavelengths 0.630–0.680 µm (red band):</p><pre>&gt;&gt;&gt; b4 = landuse_austin_tx.images.cropped.LC80270392014022LGN00. \<br>... LC80270392014022LGN00_B4<br>&gt;&gt;&gt; r = skimage.io.imread(b4(), as_grey=True)</pre><p>More information about the available image bands is <a href="https://en.wikipedia.org/wiki/Landsat_8">here</a>.</p><h3><strong>Feature Engineering</strong></h3><p>The data was loaded and some higher level features were engineered to help better train the classifier. All bands have a resolution of 30m except band 8 which records all colors (panchromatic) at a resolution of 15 meters. This image was used to sharpen the red, green, and blue bands (r,g,b) by replacing the intensity in each band with the panchromatic image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f92b5b2d7b2514639a6d12cf42123fea/href">https://medium.com/media/f92b5b2d7b2514639a6d12cf42123fea/href</a></iframe><p>The above code also produces the <a href="https://en.wikipedia.org/wiki/Normalized_Difference_Vegetation_Index">normalized difference vegetation index</a> (ndvi), which I call a “tree finder”. The ratio of reflected near-infrared light to red light is enhanced for plants (vs buildings and concrete).</p><p><em>NDVI = (NIR-Red)/(NIR+Red)</em></p><p>This is a well know feature in the remote sensing community and was suggested by a colleague (one of the nice parts of the Insight Program is the diverse background of the Fellows). The feature is very powerful and gives ~10% improvement in accuracy over a classifier trained with out it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJG1AGeXA9m4LeJkIn-NEA.png" /><figcaption>Normalized Difference Vegetation Index</figcaption></figure><p>The second feature I call a “building finder” is designed to find edges in the image, and is known in image processing lingo as <a href="https://en.wikipedia.org/wiki/Edge_detection">edge detection</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93a2eee5588ceb44b79a01da48664e88/href">https://medium.com/media/93a2eee5588ceb44b79a01da48664e88/href</a></iframe><p>Each RGB band is blurred with a gaussian filter and then subtracted from the original image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_XP_w9GlOeWxV2JNzGfjw.png" /><figcaption>Difference of Gaussian Image</figcaption></figure><h3><strong>Data Labels</strong></h3><p>The labels for the training came from <a href="https://www.openstreetmap.org/search?query=austin%20tx#map=11/30.3080/-97.7499">Open Street Maps</a> which provides crowd sourced land use data. The vector shape files as well as rasters for the cropped images are available in landuse_austin_tx. The labels were a bit of trouble actually. The data available covers only 15% of the image and is highly biased to buildings. This leads to a strong over classification of “nature” as “buildings,” particularly in the farmland on the east of the city. To address this, the “nature” labels are interpolated as an area not labeled as a building. Training over a small fraction of the image and cross validating against the rest, there was less than 1% variation in accuracy. However labels are still one area that could be improved… most likely with some effort hand labeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*8juSf5SG4Kq_P8hYEj2hPw.png" /><figcaption>Labels: Building (red) and Nature (green)</figcaption></figure><h3>Modeling</h3><p>I modeled this as a two class problem, “Buildings” and “Nature” (anything not a building). In the future one can imagine separating out road or bodies of water (both considered “Nature” in the current model), but for this proof of concept this was not done.</p><p>Prior to large scale training, I moved to a <em>c4.8xlarge</em> EC2 container on AWS. This provided the resources, more specifically the memory to quickly explore the data and trained my models at least 20 times faster than my laptop. Here the Quilt system ensured the data was completely transferred and my code ran without having to change hard coded paths.</p><h4>TPOT</h4><p>I attempted to optimize the learning with the use of <a href="http://rhiever.github.io/tpot/">TPOT</a> automated machine learning tool. This tool explores different models and returns the one with the best metric. It even returns the code to implement the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*F6O-eIXOhDkeKJgdzf5eIA.gif" /></figure><p>After running on a large EC2 instance for about 8 hours TPOT provided an optimized model, with code!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/910e97b88e130ad883862c40e1415b6d/href">https://medium.com/media/910e97b88e130ad883862c40e1415b6d/href</a></iframe><p>The default metric of optimization is “balance accuracy” which is an unweighted average of all class accuracies. This actually was not the best metric for this analysis, where the recall of buildings provides the best measure of the measure of the rate of urbanization.</p><p>I would love to re-optimize with TPOT using my preferred metric, but because of time constraints, I did an ad-hoc optimization and settled for an XGBoost classifier with 350 estimators. This returned a similar accuracy, but with a greater recall for the buildings (class 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*Z87Uk3aGM3_8T1QU9caXqA.png" /><figcaption>Class 1 are Buildings and Class 2 are Nature (Non-Building)</figcaption></figure><p>Finally you can see the output of the classifier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxbwIPQAtc2-F218qWkg1A.png" /><figcaption>Output of XGBoost classifier for image (LC80270392014022LGN00) from 2014</figcaption></figure><h3>Time Series Analysis</h3><p>Having trained a model, I began to look for changes over time. Here you can see the the output of the classifier for another image (LC80270392017030LGN00) from January, 2017.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mn3J2nWs38aNulUwk_h5ew.png" /><figcaption>Output of XGBoost classifier for image (LC80270392017030LGN00) from 2017</figcaption></figure><p>Taking the classifier outputs from the 2014 image and 2017 image (shown above), I apply a gaussian filter to smooth the expectation and subtract. This gives the class change over time (red areas below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*zdIoaEq4_jZ7C7clNx1lsg.png" /><figcaption>Crop from LC80270392014022LGN00 (2014)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*ruCoHcRgKU_XPbNO6i06rA.png" /><figcaption>Crop from LC80270392017030LGN00 (2017)</figcaption></figure><p>As you can see I am able to find new construction (the red area in upper portion of the two images).</p><p>However the model is also sensitive to color or exposure variation that is not consistent with new construction (the red area in the lower portion of the two images). I believe more training across different images should help mitigate this effect, but more study is needed.</p><h3>Conclusions</h3><p>I have shown that I can successfully use ML to classify land use on a per image basis. The example mentioned in the Modeling section was trained on 10% of the data, but still achieved 83% accuracy (total) and 58% recall (buildings) across the entire image.</p><p>While the time series analysis will require cross image training or perhaps more feature tuning, the per image performance is reasonable. A more careful preparation of the labels and training several images is the next obvious step, but due to time constraints this wasn’t possible at this time. However those wanting to test the procedure for themselves, the Quilt data set and <a href="https://github.com/jyamaoka/LandUse">sample code</a> are just a download away.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a5579670885" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quilt/identifying-buildings-in-satellite-images-with-machine-learning-and-quilt-5a5579670885">Identifying Buildings in Satellite Images with Machine Learning and Quilt</a> was originally published in <a href="https://medium.com/quilt">Quilt</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>