<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Volunteered Geographic Information &#187; GIS</title>
	<atom:link href="http://danieljlewis.org/category/gis/feed/" rel="self" type="application/rss+xml" />
	<link>http://danieljlewis.org</link>
	<description>A Geography/GIS blog by Daniel J Lewis</description>
	<lastBuildDate>Tue, 20 Dec 2011 17:15:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Generalising OS MasterMap Buildings</title>
		<link>http://danieljlewis.org/2011/12/20/generalising-os-mastermap-buildings/</link>
		<comments>http://danieljlewis.org/2011/12/20/generalising-os-mastermap-buildings/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 17:15:30 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[Representation]]></category>
		<category><![CDATA[buildings]]></category>
		<category><![CDATA[generalisation]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[mastermap]]></category>
		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=547</guid>
		<description><![CDATA[The purpose of map generalisation is to represent spatial data in a way that makes it possible to effectively view the data at scales smaller than that for which it was originally intended. In the case of the Ordnance Survey&#8217;s MasterMap product you have data at an incredibly fine level of spatial resolution, which is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F12%2F20%2Fgeneralising-os-mastermap-buildings%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F12%2F20%2Fgeneralising-os-mastermap-buildings%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The purpose of map generalisation is to represent spatial data in a way that makes it possible to effectively view the data at scales smaller than that for which it was originally intended. In the case of the Ordnance Survey&#8217;s MasterMap product you have data at an incredibly fine level of spatial resolution, which is ideally viewed at a scale of approximately 1:1000 give or take 500. When you are reliant on MasterMap, but need to create map of a wider area you are faced with the challenge of generalising data so that it can be ably understood, this means reducing the complexity of components of the spatial data, for instance smoothing wiggly lines, or transforming complicated polygons into simpler ones, as well as aggregating an abundance of small features into larger ones. Such interventions are necessary because it is increasingly difficult to resolve fine detail as map scale decreases, leading to complex shapes appearing messy and disordered when visualised at smaller scales that that which they were intended for. The actual scale of a map gives us an insight into the types of objects that it is possible to resolve at different scales; at a scale of 1:1000 a physical distance of 100cm represents 1km, at 1:10000 and 1:100000 the distance of 1km is covered by 10cm and 1cm respectively. If we conservatively suggest that we can resolve features that are 5mm across, then at 1:1000; 1:10000; and 1:100000, the smallest real world objects that can be represented are 5m,  50m, and 500m respectively. These distances equate to real world objects such as large cars and trucks (c. 5m in length), Olympic-sized swimming pools and office buildings (50m), whilst a distance of 500m is twice the span of Tower Bridge. Evidently, there are significant difference in what constitutes appropriate detail at each of these scales.</p>
<p>I&#8217;ve been dealing with one such problem recently, involving the representation of MasterMap building outlines at a scale of 1:10000, somewhat smaller that the 1:1000ish that it was intended for. In order to create an effective map I did needed to generalise the building outlines, however, unfortunately I don&#8217;t have access to ESRI&#8217;s ArcGIS &#8220;simplify building&#8221; tool due to licensing restrictions, so I had to come up with another solution. Initially I attempted the classic line generalisation procedure &#8211; the Douglas-Peucker algorithm, which simplifies by reducing the number of points in a curve subject to some pre-specified threshold value. However, buildings are strong geometric shapes, often rectangular and orthogonal, so an algorithm such as the Douglas-Peucker can have the effect of disrupting the geometric regularity of building outlines, removing corners etc. What is required is a polygon simplification algorithm that preserves orthogonality, however I couldn&#8217;t find anything that did this whilst being accessible, instead I had to come up with a procedure to approximate a generalisation of the building polygons by another methods. The image below reveals the result, which I think is successful enough to use.</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2011/12/RawGenBuildings.png"><img class="aligncenter size-large wp-image-548" src="http://danieljlewis.org/files/2011/12/RawGenBuildings-1024x724.png" alt="" width="502" height="355" /></a></p>
<p style="text-align: left">In the image above, A is the raw data, and B is the generalised data. I experimented with a few approaches, but the one I assessed as being the best was to position an enclosing rectangle around each building polygon, so that the area of the enclosing rectangle was minimised, and subsequently buffer the result to close any small gaps, choosing to dissolve as well in order to further reduce the complexity. Subsequently I removed the particularly small buildings. The generalisation is more in evidence in the image below, in which A and B are the same as before.</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2011/12/RawGenBuildings1500.png"><img class="aligncenter size-large wp-image-551" src="http://danieljlewis.org/files/2011/12/RawGenBuildings1500-1024x724.png" alt="" width="502" height="355" /></a></p>
<p style="text-align: left">I am reasonably pleased with the result, which was achieved after a little trial and error. Whilst technical approaches to orthogonal simplification exist I can&#8217;t imagine them being much more effective at this scale, although perhaps at smaller scales they would be more appropriate as they can create meaningful aggregations of building based upon characteristics such as nearest-neighbour distance.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2011/12/20/generalising-os-mastermap-buildings/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Weighted Mean Direction Surfaces in Python</title>
		<link>http://danieljlewis.org/2011/08/31/weighted-mean-direction-surfaces-in-python/</link>
		<comments>http://danieljlewis.org/2011/08/31/weighted-mean-direction-surfaces-in-python/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 13:18:18 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[Representation]]></category>
		<category><![CDATA[Southwark]]></category>
		<category><![CDATA[Brunsdon]]></category>
		<category><![CDATA[Charlton]]></category>
		<category><![CDATA[circular statistics]]></category>
		<category><![CDATA[mean direction]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[weighting]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=537</guid>
		<description><![CDATA[I work a lot with flows and spatial interactions, one thing that I&#8217;ve wanted to do for a while is compute a mean flow direction surface. Unfortunately, arithmetic means don&#8217;t work for angular data, this is because it cannot account for the circular nature of the distribution of angular measurements. For instance the angles 5 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F08%2F31%2Fweighted-mean-direction-surfaces-in-python%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F08%2F31%2Fweighted-mean-direction-surfaces-in-python%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I work a lot with flows and spatial interactions, one thing that I&#8217;ve wanted to do for a while is compute a mean flow direction surface. Unfortunately, arithmetic means don&#8217;t work for angular data, this is because it cannot account for the circular nature of the distribution of angular measurements. For instance the angles 5 degrees and 355 degrees are seperated only by 10 degrees, but their arithmetic mean is 180 degrees -w ay off, it should be 0 degrees!</p>
<p>Luckily, <a title="Local trend Statistics for Direction Data" href="http://leicester.academia.edu/ChrisBrunsdon/Papers/534394/Local_trend_statistics_for_directional_data--A_moving_window_approach">Brunsdon and Charlton</a> have published on this very subject, so I took it upon myself to implement a weighted circular mean function in Python. The key obstacle was learning about complex numbers, about which, up until this point, I had no idea about at all!</p>
<p>The first thing to do is calculate the angle between a set of candidate points (such as people) and a set of services (such as Medical Centres). This is simple enough to do using, and would look something like:</p>
<pre>import math</pre>
<pre>math.atan2((y2-y1),(x2-x1))</pre>
<p>In which the pair (x1,y1) is the location of the candidate point, and (x2,y2) the location of the allocated service for that candidate point. The line linking these two points defines a flow from a candidate point, to a servcie and vice versa.</p>
<p>Having calculated all of the angles, I used ArcGIS to create an output grid, at the extent of the candidate points, using the &#8220;fishnet&#8221; function which creates a vector grid of prespecified dimensions.</p>
<p>The beauty of Brunsdon and Charlton&#8217;s method is that it uses a local method of approximation, this means that for each cell in the output grid, a mean direction can be calculated based upon the values of nearby points, applying a weighting allows for more distance points to have less of an effect on the mean direction.</p>
<p>Firstly, I read all the candidate points into a KDTree structure, this allows me to search for local points, at the same time I also create an array of the angles for those candidate points.</p>
<pre>from scipy.spatial import cKDTree
import numpy as np

tree = cKDTree(treepoints)
res, idx = tree.query(testpoint,300000,0,2,100)
res = res[0][np.where(res[0] &lt; np.Inf)[0]]
idx = idx[0][:len(res)]</pre>
<p>The tree takes a numpy array of coordinate pairs, and the query method returns an array of distances to points (res) and their index value in the original array of coordinates (idx). The testpoint is a cell in the vector grid; 300000 is the k-number of nearest neighbours to find, here I have simply set it arbitrarily high in the context of my dataset; 0 is for approximate nearest neighbours, here I&#8217;ve specified exact; 2 indicates the use of euclidian distance; and 100 is the threshold, neighbours won&#8217;t be returned if they are further than 100 metres away. The penultimate line simply returns an array that is shortened to just those values which are less than 100m away (i.e. less than infinity) &#8211; points over 100m away are returned as value Inf.</p>
<p>The next step is to actually compute the mean direction, this requires a special approach using complex numbers however. Brunsdon and Charlton show that a direction can be stated as a complex number <em>z</em> in which <em>z = exp(iθ)</em> this is effectively: <em>z = cos(θ) + i sin(θ)  </em>in which <em>i</em> is an imaginary number. We can restate our directions in Python using:</p>
<pre>import cmath

thetas = angles[idx]
cThetas = []
for i in xrange(0,len(thetas)):
    cThetas.append(complex(np.cos(thetas[i]),np.sin(thetas[i])))
cThetas = np.array(cThetas)</pre>
<p>Here, the complex function allows the complex number representing an angle to be stored in a list, which I convert (lazily) to a numpy array. The first term, thetas, is using the idx array from the cKDTree to cleverly index the relevant angle records from the angles array which stores all the angle values in the order of entries for the cKDTree.</p>
<p>Next a temporary variable is created which calculates the mean direction:</p>
<pre>temp = np.sum(cThetas)/np.absolute(np.sum(cThetas))
MeanDir = np.angle(temp, deg = True)</pre>
<p>The mean direction is given by the argument (Arg) of the resultant complex number, Python implements this with the np.angle function, where deg = True returns the angle in degrees, and False in radians.</p>
<p>So far this is the unweighted mean, aggregating directional observations within a 100m disk (see also: uniform disk smoothing). To introduce weighting we must first define a weighting scheme, I&#8217;ve used the one suggested by Brunsdon and Charlton, which is Gaussian, and might look at bit like this:</p>
<pre>def gaussW(dists,band):
    out = np.zeros(dists.shape)
    for i in xrange(0,len(out)):
        temp = np.power(dists[i],2)/(2.0*np.power(float(band),2))
        out[i] = np.exp(-1.0 * temp)
    return out

weight = gaussW(res,100)</pre>
<p>Quite simply, I pass the distance array res to the gaussW function and it gives me back an array of weights for that ordering of distances. Using this I can redo the mean direction thus:</p>
<pre>temp = np.sum(weight*cThetas)/np.absolute(np.sum(weight*cThetas))
MeanDir = np.angle(temp, deg = True)</pre>
<p>There you have it! Attached is the script I used. Obviously, Brunsdon and Charlton implement a variance and a couple of visualisation devices, but these should be simple enough to implement now!</p>
<p>I created an output for flows of patients to GPs in Southwark, visualised using one of ESRI&#8217;s circular/direction colour ramps from <a title="Mapping Resources" href="http://mappingcenter.esri.com/index.cfm?fa=arcgisResources.gateway">colour ramp pack 2</a>. Not sure how best to visualise the legend at this point though. NB. 90 is north, -90 is South, 0/-0 is East and 180/-180 is West. The map is visualised to show the 4 cardinal directions, but the output is in fact continuous.</p>
<p style="text-align: left"><a href="http://danieljlewis.org/files/2011/08/MeanDirectionFlows.png"><img class="aligncenter size-large wp-image-538" src="http://danieljlewis.org/files/2011/08/MeanDirectionFlows-724x1024.png" alt="" width="434" height="614" /></a>My example script is <a href="http://danieljlewis.org/files/2011/08/meanDirection.txt">here. </a> Note that I am using dbfpy to read and write to shapefile DBF tables directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2011/08/31/weighted-mean-direction-surfaces-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Spatial Approach to Location Quotients</title>
		<link>http://danieljlewis.org/2011/06/17/a-spatial-approach-to-location-quotients-2/</link>
		<comments>http://danieljlewis.org/2011/06/17/a-spatial-approach-to-location-quotients-2/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 14:46:21 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[Geography]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[Representation]]></category>
		<category><![CDATA[Southwark]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[density]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Location Quotient]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=529</guid>
		<description><![CDATA[The intent of this post is not simply to uncover where the highest density of people belonging to a particular ethnic group are, but rather to use the ‘location quotient’ (LQ) technique to compare the ethnic density in any one area to the overall ethnic density in Southwark, thus providing a relative insight into where [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F06%2F17%2Fa-spatial-approach-to-location-quotients-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F06%2F17%2Fa-spatial-approach-to-location-quotients-2%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The intent of this post is not simply to uncover where the highest density of people belonging to a particular ethnic group are, but rather to use the ‘location quotient’ (LQ) technique to compare the ethnic density in any one area to the overall ethnic density in Southwark, thus providing a relative insight into where the density of particular groups is more, less or as dense as expected.</p>
<p>Location Quotients tend to work with areal units, characterising different areas subject to a larger region and providing a basic insight into where functions are clustered. Because the Southwark patient register data is address geocoded, we would be losing some spatial information if we choose to aggregate the data, not to mention the question of which areal aggregation is best. More info on how to create location quotients <a title="Wikipedia with LQs" href="http://en.wikipedia.org/wiki/Economic_base_analysis">here</a>.</p>
<p>A Location Quotient has 3 possible interpretations; if it is around 1 then the ethnic population in that area is at the level we would expect given what we observe nationally. If the LQ is less than 1 then that area has a lesser population of a particular ethnic group that what we would expect based upon national figures. Finally, in the LQ value is over 1 this suggests a concentration of the ethnic group in the area which is greater than we would expect given nationally observed levels. A LQ is quite simply a rate-ratio.</p>
<p>Instead of the standrad areal approach, the maps here use a density estimation approach in which disaggregate point data is transformed into a representation of the continuous density function of the point distribution. The LQ can then be computed for each cell based on the density of that cell with respect to the total density of the surface. This creates a smoothed LQ surface which is readily interpretable in the same manner as above. The Kernel Density Estimation used to create the ethnic and total population density surfaces should be parameterised in the same way; these examples use a 250m bandwidth and a 25m cells size, which is largely empirically redundant, based on the input dataset’s spatial resolution, but creates a more aesthetically appealing mapped representation. Naturally, the procedure works well for clustered data, in Southwarks case for the African and Muslim groups.</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2011/06/AfricanLQ.png"><img class="aligncenter size-large wp-image-530" src="http://danieljlewis.org/files/2011/06/AfricanLQ-724x1024.png" alt="" width="463" height="655" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2011/06/17/a-spatial-approach-to-location-quotients-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>&#8216;Compactness&#8217; in Zoning: the circle as the ideal.</title>
		<link>http://danieljlewis.org/2011/02/26/compactness-in-zoning-the-circle-as-the-ideal/</link>
		<comments>http://danieljlewis.org/2011/02/26/compactness-in-zoning-the-circle-as-the-ideal/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 06:17:26 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[anisotropy]]></category>
		<category><![CDATA[christaller]]></category>
		<category><![CDATA[circles]]></category>
		<category><![CDATA[isotropy]]></category>
		<category><![CDATA[Representation]]></category>
		<category><![CDATA[zones]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=509</guid>
		<description><![CDATA[I saw a thought provoking presentation recently, given by Wenwen Li of the University of California Santa Barbara, the talk was a wide ranging insight into Cyber Infrastructure, its uses for geospatial information, and some of the computational techniques that underpinned the project. One element of the project involved zone design for the greater Los [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F02%2F26%2Fcompactness-in-zoning-the-circle-as-the-ideal%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F02%2F26%2Fcompactness-in-zoning-the-circle-as-the-ideal%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I saw a thought provoking presentation recently, given by <a title="Wenwen Li" href="http://www.geog.ucsb.edu/~wenwen/" target="_blank">Wenwen Li</a> of the University of California Santa Barbara, the talk was a wide ranging insight into Cyber Infrastructure, its uses for geospatial information, and some of the computational techniques that underpinned the project. One element of the project involved zone design for the greater Los Angeles region, and involved the implementation of an algorithm that was intended to aggregate small areal units into larger zones whilst meeting a number of conditions, principle among these conditions was &#8216;compactness&#8217;. The output looked very much like a single hierarchy of Christaller hexagons, and this got me thinking about the nature of space and compactness.</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2011/02/centralplace.gif"><img class="aligncenter size-full wp-image-510" src="http://danieljlewis.org/files/2011/02/centralplace.gif" alt="From: http://watd.wuthering-heights.co.uk/mainpages/sustainability.html" width="440" height="307" /></a></p>
<p style="text-align: left">Christaller&#8217;s hexagons are the defining illustration of something called &#8216;central place theory&#8217;, a geographical abstraction that idealises settlement pattern based upon an underlying space which is assumed to be isotropic. The assumption of spatial isotropy is the big leap in this model, it assumes that the &#8216;friction of distance&#8217; from any given point increases at an equal rate whichever way you go from that point. Clearly such a suggestion is not applicable to Los Angeles, where huge freeways and interchanges can make adjacent parcels of land remote neighbours, and increase the connection between advantageously placed non-adjacent sites? Surely a city in which sprawl and ribbon development, as well as segregated communities should be modeled differently? Why then do many of our zoning algorithms favour compact &#8216;circular&#8217; shapes, very much in the christaller mould, and why do we reject uncompact areal features as ugly slivers? In short, how did the circle come to be the ideal shape of zone in regional studies? Certainly, it is easier, both implementationally and conceptually, to model circles than to consider optimising a zone system over an <em>n </em>zone by <em>n </em>zone similarity matrix pertaining to variables which may be important to aggregating any set of areal units. However, as we explore more and more the complex systems defined by cities and regions, surely there is a need to start integrating a more realistic anisotropic view of space, one in which the friction of distance from any given point in any given direction is defined by the underlying demography, built environment and/or infrastructure.</p>
<p style="text-align: left">One such attempt at this, <a title="Amoeba publication" href="http://onlinelibrary.wiley.com/doi/10.1111/j.1538-4632.2006.00689.x/full" target="_blank">AMOEBA</a> (A Multidirectional Optimum Ecotope-Based Algorithm), developed by Aldstadt and Getis, is worth noting. In this algorithm, zones are defined via the Getis-Ord Gi* statistic, which is a local statistic for identifying clustering, thus zones are defined by local conditions, which are free to vary anistropically across space, rather than by a predefined preference for circles. Spectacularly this algorithm is implemented in the superb <a title="clusterpy" href="http://www.rise-group.org/risem/clusterpy/clusterPy-module.html" target="_blank">clusterpy</a> python module for spatially constrained clustering.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2011/02/26/compactness-in-zoning-the-circle-as-the-ideal/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mapping Spatial Entropy in Southwark</title>
		<link>http://danieljlewis.org/2011/02/03/mapping-spatial-entropy-in-southwark/</link>
		<comments>http://danieljlewis.org/2011/02/03/mapping-spatial-entropy-in-southwark/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 01:32:16 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[Southwark]]></category>
		<category><![CDATA[ethnicity]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[rasters]]></category>
		<category><![CDATA[segreagtion]]></category>
		<category><![CDATA[spatially weighted entropy]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=496</guid>
		<description><![CDATA[I&#8217;ve been doing a bit of work recently on segregation with Pablo Mateos, and having gone through the motions with aspatial indices of segregation (the classics): dissimilarity, exposure and so on, I decided to investigate the more explicitly spatial ones. Taking a lead from Reardon and O&#8217;Sullivan&#8217;s (2004) paper &#8220;Measures of Spatial Segregation&#8221; in sociological methodology, I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F02%2F03%2Fmapping-spatial-entropy-in-southwark%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F02%2F03%2Fmapping-spatial-entropy-in-southwark%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been doing a bit of work recently on segregation with <a title="Pablo Mateos" href="http://www.geog.ucl.ac.uk/about-the-department/people/academics/pablo-mateos" target="_blank">Pablo Mateos</a>, and having gone through the motions with aspatial indices of segregation (the classics): dissimilarity, exposure and so on, I decided to investigate the more explicitly spatial ones. Taking a lead from Reardon and O&#8217;Sullivan&#8217;s (2004) paper &#8220;Measures of Spatial Segregation&#8221; in <em>sociological methodology</em>, I got in touch with <a title="David O'Sullivan" href="http://web.env.auckland.ac.nz/people_profiles/osullivan_d/" target="_blank">David O&#8217;Sullivan </a>and he, and his student Seong-Yun Hong, helped me with the implementation of some spatial measures of segregation. This post specifically concerns spatially weighted entropy &#8211; a measure of population diversity. Reardon and O&#8217;Sullivan define spatially weighted entropy as:</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2011/02/SpatiallyWeightedEntropy.gif"><img class="aligncenter size-full wp-image-497" src="http://danieljlewis.org/files/2011/02/SpatiallyWeightedEntropy.gif" alt="" width="350" height="94" /></a></p>
<p style="text-align: left">This equation describes the &#8216;entropy&#8217;, derived from Shannon&#8217;s information theory, for each grid cell in the image (below) in which each cell value results from the entropy computed for a 1km &#8216;neighbourhood&#8217; <em>p </em>around each cell (essentially a circular buffer)<em>. </em>The ethnic group in question is given by &#8216;m&#8217; (with the pi representing the proportion of a given group in a given neighbourhood) and relates to ethnic groups defined from the Southwark patient register using Onomap, the groups defined are: African, East Asian and Pacific, European, Muslim, South Asian, British, Eastern European, Hispanic, and Unclassified or Other. The Onomap software is able to apply this classification by looking at the forename and surname combination of patients registered to use Southwark GPs, or patients living in Southwark but using GPs outside of Southwark. The cells in the image relate directly to the residential locations of patients, who were geocoded to their household using the Ordnance Survey&#8217;s Address Layer 2 product, therefore empty cells are areas within which no recorded patients were found, such as parks, and transport infrastructure. As the data underlying this is from patient registrations with GPs, we have to accept that the data is likely to be partial, with potentially systematic biases in those people who have registered &#8211; young men and people from countries where GPs as a method of primary care do not exist- may have been omitted.</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2011/02/SwkEntropyMap.png"><img class="aligncenter size-large wp-image-500" src="http://danieljlewis.org/files/2011/02/SwkEntropyMap-791x1024.png" alt="" width="475" height="614" /></a></p>
<p>In the image, higher values of entropy indicate greater diversity of population by ethnic group, the resultant images is unsurprising in terms of Southwark, with the Dulwich Village area showing as the least diverse place, home as it is to more affluent, generally &#8216;British&#8217; groups. Likewise historical factors regarding access to housing have shaped the lower entropy scores in the middle of the borough &#8211; home to African populations and the North East, home to the British working classes who were rehoused from the now more African areas in the middle of the borough. Finally, the greater Waterloo- Elephant and Castle region in the north-west shows up as the ethnic melting pot in the borough.</p>
<p>In the image above, the 1km neighbourhood defined in the spatially weighted entropy score has a smoothing effect, I experimented with smaller values for the neighburhood size, and found that the resultant output did not change dramatically from that obtained above. At the end of the day, the selection of neighbourhood size is largely arbitrary and will depend on sociocultural factors of the area and it&#8217;s people. Similarly, as there is no data for the regions outside of Southwark we are more uncertain of the values at the edges than in the middle of the borough as we are only sampling from within Southwark itself. Nonetheless, this representation of Southwark goes somewhat beyond what is possible using the commonly used output zones defined by the census.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2011/02/03/mapping-spatial-entropy-in-southwark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spatial Design for GP Consortia?</title>
		<link>http://danieljlewis.org/2011/01/18/spatial-design-for-gp-consortia/</link>
		<comments>http://danieljlewis.org/2011/01/18/spatial-design-for-gp-consortia/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 14:59:25 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[Health Geography]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[GP Consortia]]></category>
		<category><![CDATA[NHS]]></category>
		<category><![CDATA[pysal]]></category>
		<category><![CDATA[zone design]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=483</guid>
		<description><![CDATA[The government is set to release a bill detailing how it is they expect the proposed GP Consortia to work. GP Consortia, groups of GPs working together, are set to replace the current structure of Primary Care Trusts (PCTs) and Strategic Health Authorities (SHAs) as the mechanism through which primary healthcare is provided to the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F01%2F18%2Fspatial-design-for-gp-consortia%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2011%2F01%2F18%2Fspatial-design-for-gp-consortia%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The government is set to release a bill detailing how it is they expect the proposed GP Consortia to work. GP Consortia, groups of GPs working together, are set to replace the current structure of Primary Care Trusts (PCTs) and Strategic Health Authorities (SHAs) as the mechanism through which primary healthcare is provided to the public, and services are commissioned. Recently, the planned wholesale changes to the NHS have come under a sustained attack from the media, professional bodies and MPs, meanwhile the plans for GP consortia have moved into a trial phase in which different setups are being tested for their effectiveness. The trial consortia demonstrate the extent to which the plans represent a completely new venture, with a broad spectrum of possibilities being tested in terms of consortia templates, from a &#8216;consortia&#8217; of a mere 3 GP practices, to a vast group of 83 GP practices. There seems little reasoning behind how Consortia are allowed to form at the moment, thus I saw an interesting opportunity to consider the &#8216;GP Consortia Problem&#8217; as a geographic question. This is most evident in the fact that the NHS is mandated to provide an equitable and universal service, and an unmetered potential for GPs to &#8216;consort&#8217; may well lead to increasing inequities in healthcare provision.</p>
<p>I see the &#8216;GP Consortia Problem&#8217; as solvable through a zone-design approach. To do this, I identify contiguity between all English GPs and employ spatially constrained clustering. The following assumptions are made:</p>
<ul>
<li>Distance is important, GP consortia should be space covering without holes or islands, therefore a &#8216;neighbour&#8217; approach to contiguity is advocated using graphs.</li>
<li>As a preliminary test, GPs are considered to be equal, although there is scope in the future to develop measures of dissimilarity and homegeneity which will provide better, or more appropriate solutions to the GP Consortia problem.</li>
<li>Based on the trials, I assume that Consortia must consist of at least 35 GPs, the average number of GPs per consortia in the trial phase.</li>
</ul>
<p>I have used two approaches to creating contiguity amongst the English GP practices, both of them graph theoretical concepts based upon geometric analyses: the delaunay triangulation, and the gabriel graph. I believe that the gabriel graph is a sub graph of the delaunay triangulation, as such it is sparser than the delaunay graph. The two graphs are defined as:</p>
<ul>
<li>Delaunay Triangulation &#8211; for a set of nodes (GP practices) the delaunay triangulation is the set of triangles created by drawing a circle with 3 nodes (which define the triangles edges) on the circle&#8217;s perimeter, in which the circle does not contain any other points- iterated for all sets of 3-points.</li>
<li>Gabriel Graph- 2 nodes are connected if they form the start and end-point of the diameter of a circle, and the circle does not contain any other points &#8211; iterated for all pairs of points.</li>
</ul>
<p>In this sense, both the Delaunay triangulation and the Gabriel graph are nearest proximity measures. Having obtained the graph, the differences can be seen below. Note both graphs have been constrained for the English boundary.</p>
<p style="text-align: left"><a href="http://danieljlewis.org/files/2011/01/ContiguityGraphs.png"><img class="aligncenter size-large wp-image-485" src="http://danieljlewis.org/files/2011/01/ContiguityGraphs-1024x724.png" alt="" width="491" height="347" /></a>Having created the &#8216;contiguity&#8217; graphs, I wrote a short python script to extract the realtionships between GPs and write the output as a &#8216;.gal&#8217; file for use with pySAL. I utilised the pySAL regionalisation module to compute the consortia solutions, I have used this previously in my blog, so I won&#8217;t go into detail on it. I paramterised the solution using the contiguity matrices created, assuming equality amongst GP practices, and looking for groups of at least 35 GPs. The regionalisations were then joined to a special areal geography I created for visualisation, this is simply the Voronoi diagram of the English GPs clipped to the English boundary. The results are below:</p>
<p style="text-align: left"><a href="http://danieljlewis.org/files/2011/01/SolutionGraphs.png"><img class="aligncenter size-large wp-image-489" src="http://danieljlewis.org/files/2011/01/SolutionGraphs-1024x724.png" alt="" width="491" height="347" /></a>In these results it is notable that the Gabriel graph gives a cleaner result, the density of the delaunay-based contiguity matrix means that the result is subject to some sliver-like polygons in the regionalisation, and &#8216;spikier&#8217; regions in general.</p>
<p style="text-align: left">Of course, this is just a test, but it does point at the potential to create a rationalised system fo GP Consortia. Naturally, the biggest issue with these maps is that they only establish an areal depiction of consortia, one that is largely irrelevant. This is because the actual service areas of GPs tend to overlap and extend beyond any given GP&#8217;s voronoi defined footprint. Therefore the geography of patients requires a subsequent treatment once a geography of COnsortia has been established, and only in the interaction of the two can issues pertaining to equity be understood.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2011/01/18/spatial-design-for-gp-consortia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finnish Municipalities: A case for zone design?</title>
		<link>http://danieljlewis.org/2010/11/30/finnish-municipalities-a-case-for-zone-design/</link>
		<comments>http://danieljlewis.org/2010/11/30/finnish-municipalities-a-case-for-zone-design/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 20:05:39 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[Geography]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[Modeling]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[finland]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[municipal]]></category>
		<category><![CDATA[pysal]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[zone design]]></category>

		<guid isPermaLink="false">http://danieljlewis.org.blogs.splintdev.geog.ucl.ac.uk/?p=438</guid>
		<description><![CDATA[In Finland, municipalities are incredibly powerful; like local authorities in the UK, municipalities are responsible for local administration, but they also levy an income tax and are responsible for providing most public services. Municipalities were founded on the assumption of equality, which forms the basis for the reform considerations currently ongoing in the Finnish government. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F11%2F30%2Ffinnish-municipalities-a-case-for-zone-design%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F11%2F30%2Ffinnish-municipalities-a-case-for-zone-design%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In Finland, municipalities are incredibly powerful; like local authorities in the UK, municipalities are responsible for local administration, but they also levy an income tax and are responsible for providing most public services. Municipalities were founded on the assumption of equality, which forms the basis for the reform considerations currently ongoing in the Finnish government. The fact is, municipalities simply aren&#8217;t equal, they vary wildly in population size and area; numbering 342 they are of rough numerical equivalence to UK local authorities, despite Finland itself having around 1/11th of the UK&#8217;s population. The population skew is greatly emphasised by the presence of cities such as Helsinki which cross municipal boundaries, and more remote municipalities whose geographical extent was set out by horse-and-cart distance. It is therefore understandable that the Finnish government would be interested in the possibility of mergers to reduce the number of municipalities, and create a system in which muncipalities serve a similar number, or at least a threshold, population. It is believed that this would make administration more efficient, as services can be centralised to a greater degree, and small municipalities which already share services can formalise this.</p>
<p>Some mergers have already taken place, and there are governmental incentives for merging. However, with the specified model that municalities should be reformed such that they have a base population of 20-30,000 people, from the Association of Finnish Local and Regional Authorities (<em>Kuntaliitto</em>), we can apply automated zone design scenarios to test the &#8216;what if&#8217; aspect of creating a new Finnish municipal system based on preserving different characteristics.</p>
<p>The zone design tool that I use to test a few basic scenarios is the regionalization library in pySAL, a spatial analysis module for Python. This implements the max-P algorithm for spatially contrained clustering subject to a similarity matrix, and a threshold value. I specified the research design so that I was testing for the optimal new aggregation of the pre-existing muncipalities and tested 3 different scenarios: 1) No similarity measure (all municipalities assumed equal, but for population) 2) Similarity based on municipal tax regime, and 3) Similarity based upon municipal tax regime and % non-finnish speakers, which accounts culturally for the Sami people of Lapland and ethnically Swedish Finns.</p>
<p>The regionalisation requires that you create a contiguity matrix for the zones, I arbitrarily chose the queen case, and added bespoke contiguity for Finnish islands based upon proximity, this is easy to do in GeoDa and it outputs a .gal file which you can read into python. Then all you really need to do is the following:</p>
<pre>import pysal
import numpy as np #required as pysal uses numpy arrays

#Read in your population and similarity data in some way,
#I tend to create a python list from a csv.

#convert the population and similarity data into
#numpy arrays, from lists called pop and sim
pop = np.asarray(pop)
sim = np.asarray(sim)

# Read in your precomputed Weights matrix
w = pysal.open("...\\QueenWeights.gal").read()

# Create an (optional) array of 1s to represent equality
# (replace sim in Maxp function call)
nosim = np.ones((342,1))

# Run solutions for maxp algorithms with specific parameters
r= pysal.Maxp(w,sim,floor = 20000,floor_variable = pop,initial=100)

# Write r.regions to outfile to get regional assignments,
#this can be joined to shp in ArcGIS.
</pre>
<p>The maxP algorithm works by first randomly creating a set of possible zoning configurations, then it chooses the current optimum and seeks to refine it using a computationally expensive zone-swapping method. Optimality in this case is defined by minimising dissimilarity whilst obeying the threshold population constraint. The <a title="pySAL Documentation" href="http://www.pysal.org/users/tutorials/region.html" target="_blank">API reference</a> for regionalisation in pysal is very good.</p>
<p>Here are some of the results I produced for this basic approach:</p>
<div id="attachment_453" class="wp-caption aligncenter" style="width: 271px"><a href="http://danieljlewis.org/files/2010/11/NoH20000.png"><img class="size-large wp-image-453 " src="http://danieljlewis.org/files/2010/11/NoH20000-725x1024.png" alt="" width="261" height="368" /></a><p class="wp-caption-text">Zone Design - Pop &gt; 20,000 with assumption of Municipal Equality</p></div>
<div id="attachment_454" class="wp-caption aligncenter" style="width: 271px"><a href="http://danieljlewis.org/files/2010/11/TaxLang20000.png"><img class="size-large wp-image-454 " src="http://danieljlewis.org/files/2010/11/TaxLang20000-725x1024.png" alt="" width="261" height="368" /></a><p class="wp-caption-text">Zone Design - Pop &gt; 20,000 with similarity of tax regime and language</p></div>
<p>Unlike some of the more advanced zone-design algorithms, pySAL doesn&#8217;t yet provide a way of preserving or optimising area shape characteristics, so you can get sliver-like polygons forming. Nonetheless it presents an interesting insight and a set of functions from which a more advanced/bespoke algorithm could be built.As it turns out the islands that I arbitrarily allocated to the  contiguity matrix are actually quite a contentious topic and given their  strategic significance to Sweden are in fact neutral territories which  would be untouched by any redesign of municipal structure.</p>
<p>As ever, local knowledge is important, and for the economists at <a title="VATT" href="http://www.vatt.fi/en/" target="_blank">VATT</a> this is a real task to undertake. They won&#8217;t be doing anything quite so crude, they do however have a curious spatial problem to deal with.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2010/11/30/finnish-municipalities-a-case-for-zone-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ArcGIS 10 &#8211; Field Calculator and Python</title>
		<link>http://danieljlewis.org/2010/10/11/arcgis-10-field-calculator-and-python/</link>
		<comments>http://danieljlewis.org/2010/10/11/arcgis-10-field-calculator-and-python/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 17:10:57 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arcgis]]></category>
		<category><![CDATA[esri]]></category>
		<category><![CDATA[field calculations]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://danieljlewis.org/?p=422</guid>
		<description><![CDATA[Python has been more tightly integrated in the new release of ArcGIS 10, allowing scripting to occur directly through a Python process without even opening up ArcMap. Admittedly this was available before, but now everything is more tightly coupled and a lot cleaner in it&#8217;s implementation. However, what has really interested, and indeed confused me [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F10%2F11%2Farcgis-10-field-calculator-and-python%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F10%2F11%2Farcgis-10-field-calculator-and-python%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Python has been more tightly integrated in the new release of ArcGIS 10, allowing scripting to occur directly through a Python process without even opening up ArcMap. Admittedly this was available before, but now everything is more tightly coupled and a lot cleaner in it&#8217;s implementation. However, what has really interested, and indeed confused me of late is how to use Python in the &#8216;field calculator&#8217;.</p>
<p>Field Calculator is a really useful tool, when you are looking at an attribute table for a shapefile in ArcGIS and you want to derive a value for each object in the file based on a function you can input the function into the field calculator and it will work it out for you row by row. Sometimes the value you want to derive is a bit more complicated than simple arithmetic and you need to write a script. Previously you could do this in VBA, but I always found it limited and confusing, now however you can do it in Python &#8211; much simpler!</p>
<p>There are a few pitfalls to using Python in ArcGIS field calculator, and so I&#8217;m going to specify how to write simple field calculator python scripts in ArcGIS from my early experience.</p>
<p>Firstly, for Python in field calculator the way to do it seems to be in write a Python function, and then call it for each row. In addition to this, because you are writing a function you have to give it the relevant parameters (i.e fields) with which to do the computation. Finally, and annoyingly you have to write your function in a little box, and use a consistent indentation standard (1 space works best for reasons of space) as Python requires.</p>
<p>Here is a basic recipe for achieving field calculations in ArcGIS using Python. Obvious this is overly simplistic as you do not need a script to do this calculation, but it serves as an introductory example.</p>
<p style="text-align: center"><a href="http://danieljlewis.org/files/2010/10/FieldCalculator10.png"></a><a href="http://danieljlewis.org/files/2010/10/FieldCalculator101.png"><img class="aligncenter size-full wp-image-427" src="http://danieljlewis.org/files/2010/10/FieldCalculator101.png" alt="" width="493" height="472" /></a></p>
<p>1) Name a function and parameterise it with the fields to base the calculation on. Do this in the lower box.</p>
<p style="padding-left: 30px">In the image you can see I&#8217;ve input: density( !sum_pop!, !Area!) This means send the values in the fields called sum_pop and Area to the function called density.</p>
<p>2) Define the function you are calling in the larger upper box.</p>
<p style="padding-left: 30px">You define a function in python using the &#8220;def&#8221; command. In the image i have defined the &#8220;density&#8221; function by writing the line: def density( pop,area):</p>
<p style="padding-left: 30px">This function definition means: define a function called density which takes the parameters pop and area. The parameters could be called anything, but it is useful to call them something that makes sense for use in the function. These parameters are variable names that the function uses to identify the fields you have passed the function when you called it, as in 1).</p>
<p style="padding-left: 30px">Normally you&#8217;d do some sort of calculation within the function, however this example is so simple that all we need to do is &#8220;return&#8221; a value to the function call. This function is the density defined as population over area: pop/area.</p>
<p>Looking at the field calculator I have found that you are limited to the basic, math and datetime modules in python, without the ability to import other modules. You can however define several functions and call them from within your main function.</p>
<p>For details on the basic syntax of using python, this site is particularly good: http://www.tutorialspoint.com/python/index.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2010/10/11/arcgis-10-field-calculator-and-python/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>UK OAC map in Python</title>
		<link>http://danieljlewis.org/2010/06/02/uk-oac-map-in-python/</link>
		<comments>http://danieljlewis.org/2010/06/02/uk-oac-map-in-python/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 11:05:57 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[Cartography]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[Representation]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[OAC]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[shapely]]></category>
		<category><![CDATA[UK]]></category>

		<guid isPermaLink="false">http://danieljlewis.org/?p=336</guid>
		<description><![CDATA[Here is a quick confirmation that you can use Python to draw very detailed maps; using the previously specified method I was unable to get python to draw all UK OAs due to their great number (c.220,000) and high complexity (c.50,000,000) vertices. Additionally I was unable to use the generalised OA boundaries for the UK [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F06%2F02%2Fuk-oac-map-in-python%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F06%2F02%2Fuk-oac-map-in-python%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Here is a quick confirmation that you can use Python to draw very detailed maps; using the previously specified method I was unable to get python to draw all UK OAs due to their great number (c.220,000) and high complexity (c.50,000,000) vertices. Additionally I was unable to use the generalised OA boundaries for the UK from UKBorders as they contain topological errors that the shapefile reader cannot deal with. ArcGIS is obviously a bit clever in how it handles bad topologies. So I extracted all the vertices and fed them into shapely polygons, and visualised them in the same way, but without reading shapefiles directly into python and was able to output this:</p>
<p style="text-align: left"><a href="http://danieljlewis.org/files/2010/06/UKOAC.png"><img class="aligncenter size-large wp-image-337" title="UKOAC" src="http://danieljlewis.org/files/2010/06/UKOAC-640x1024.png" alt="" width="576" height="922" /></a>This method has had an impact on the speed of computation as it can take roughly 25 minutes to output this map. The map looks pretty good, aside from a slightly odd polygon in the Bristol channel. Nevertheless, coupled with the operations that shapely, and other geo-libraries, can do this si increasing indication of the maturity of GIS in a variety of platforms. Oh, and it&#8217;s all free!</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2010/06/02/uk-oac-map-in-python/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unlocking UFOs from the National Archives</title>
		<link>http://danieljlewis.org/2010/02/18/unlocking-ufos-from-the-national-archives/</link>
		<comments>http://danieljlewis.org/2010/02/18/unlocking-ufos-from-the-national-archives/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 14:04:09 +0000</pubDate>
		<dc:creator>Daniel Lewis</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[aliens]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[Mapping UFOs]]></category>
		<category><![CDATA[National Archives]]></category>
		<category><![CDATA[sightings]]></category>
		<category><![CDATA[UFO]]></category>

		<guid isPermaLink="false">http://danieljlewis.org/?p=195</guid>
		<description><![CDATA[The British National Archives has released a large number of files relating to UFO sightings between 1994 and 2000. These previous classified documents detail (often amusingly or excruciatingly) the reports made by members of the public to the MoD regarding the sighting of Unidentified Flying Objects (UFOs). As a geographer and a user of GIS, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F02%2F18%2Funlocking-ufos-from-the-national-archives%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdanieljlewis.org%2F2010%2F02%2F18%2Funlocking-ufos-from-the-national-archives%2F&amp;source=gisdjl&amp;style=normal&amp;service=bit.ly&amp;service_api=gisdjl%3AR_cbf864f1d7672c90a5d0e63770588605&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The <a title="BNA" href="http://www.nationalarchives.gov.uk/" target="_blank">British National Archives</a> has released a large number of files relating to<a title="UFO News Story" href="http://www.nationalarchives.gov.uk/news/434.htm" target="_blank"> UFO sightings</a> between 1994 and 2000. These previous classified documents detail (often amusingly or excruciatingly) the reports made by members of the public to the MoD regarding the sighting of Unidentified Flying Objects (UFOs). As a geographer and a user of GIS, one of the overriding beliefs is that there exists an abundance of location information stored in documents waiting to be captured and analysed spatially. The records concerning UFO sightings are one such example, hundreds of reports of sightings that all give a location in addition to a lot of other information including numerous drawings of the &#8216;craft&#8217; that were seen. Because I was interested in testing out the new &#8220;Unlock&#8221; geocoding service available though Edina Digimap for academic subscribers I decided to extract some of the place information from the first UFO file and use unlock to geocode the sightings.</p>
<p>For those who need clarification,geocoding refers to the process whereby a textual reference to a location, such as a place name, an address, a postcode etc. is given a spatial reference, i.e. a pair of coordinates that can be represented on a map. What &#8220;Unlock&#8221; does is take a given placename, look for it in a gazetteer &#8211; a dictionary of all known places- and when it finds it, returns the coordinate inforamtion associated with that placename in the gazeteer. The Unlock service can be found at: <a title="Unlock" href="http://digimap.edina.ac.uk/unlock/" target="_blank">http://digimap.edina.ac.uk/unlock/</a></p>
<p>Using this service allowed me to create the following map:</p>
<p style="text-align: left"><a href="http://danieljlewis.org/files/2010/02/UFOs.jpg"><img class="aligncenter size-full wp-image-196" title="UFOs" src="http://danieljlewis.org/files/2010/02/UFOs.jpg" alt="" width="536" height="757" /></a>I decided to classify the sightings fairly crudely by season as the impression I got from the data was that there were very few sighting in the summer, and more in the autumn and winter. These sightings are mostly from 1994, part of the earliest tranche of sightings released and are to be found in the first file released by the National Archive. As a result this only accounts for about a quarter of all sightings in this year. The MoD also like to make maps, however their techniques aren&#8217;t quite so well defined as we can now achieve with GIS and geocoding technologies:</p>
<p style="text-align: left"><a href="http://danieljlewis.org/files/2010/02/ModUfosmap.png"><img class="aligncenter size-full wp-image-197" title="ModUfosmap" src="http://danieljlewis.org/files/2010/02/ModUfosmap.png" alt="" width="590" height="839" /></a>Nevertheless the map is quite illustrative of the major patterns in UFO reporting (as this may be different from raw sightings).</p>
<p style="text-align: left">The only downside to this whole process is that &#8220;Unlock&#8221; the site I used to geocode some of the data is actually quite poor. The site looks nice and the data is undoubtedly very strong, however it is a terrible user experience, there didn&#8217;t seem to be any accessible intructions on how to use the site and when I copied from the examples given to try and geocode my 50 places as a batch the output seemed to randomly drop some places in favour of several options for others, in spite of this individual searches showed that the dropped places did exist. An assessment of the sites usability is required &#8211; I can&#8217;t imagine it being used currently by anyone beyond real specialists, certainly no one will be unlocking much data unless they have a good familiarity with a number of web protocols and data structures. Hopefully in time though it will become more friendly.</p>
]]></content:encoded>
			<wfw:commentRss>http://danieljlewis.org/2010/02/18/unlocking-ufos-from-the-national-archives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

