<?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>maps &#8211; Weird Data Science</title>
	<atom:link href="https://www.weirddatascience.net/category/maps/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.weirddatascience.net</link>
	<description>Paranormal Distributions. Cyclopean Data. Esoteric Regression.</description>
	<lastBuildDate>Mon, 21 Jul 2025 18:09:01 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">143387998</site>	<item>
		<title>Numbers of the Beast: Sasquatch Distribution Modelling</title>
		<link>https://www.weirddatascience.net/2025/07/21/numbers-of-the-beast-sasquatch-distribution-modelling/</link>
					<comments>https://www.weirddatascience.net/2025/07/21/numbers-of-the-beast-sasquatch-distribution-modelling/#respond</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Mon, 21 Jul 2025 18:09:01 +0000</pubDate>
				<category><![CDATA[cryptozoology]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[spatial analysis]]></category>
		<category><![CDATA[stan]]></category>
		<guid isPermaLink="false">https://www.weirddatascience.net/?p=9482</guid>

					<description><![CDATA[<div class="mh-excerpt">The third OII Halloween Lecture sinks bodily into the tortured mass of data concerning cryptozoological sightings in North America. Drawing on over a century of shadow-haunted sightings documenting the curiously repellant presence of the North America Sasquatch, or Bigfoot, we aim to identify the factors associated with its presence, delineate the confounding presence of other dread manifestations, and cast our minds globally for a faded glimpse of its remote and scarcely-conceived brethren.</div> <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2025/07/21/numbers-of-the-beast-sasquatch-distribution-modelling/" title="Numbers of the Beast: Sasquatch Distribution Modelling">[...]</a>]]></description>
										<content:encoded><![CDATA[<p>Dredged from the stygian depths of last year&#8217;s waning: a cruelly belated artefact of academia&#8217;s primordial descent. For a third time, the Oxford Internet Institute at the University of Oxford—scarcely willing, but falteringly unable to reflect on its own ill-fated decisions—chose to risk the sanity and statistical intuition of its students against the numerically unstable nightmares writhing beneath the tattered fabric of our waking world.</p>
<p>This third OII Halloween Lecture sinks bodily into the tortured mass of data concerning cryptozoological sightings in North America. Drawing on over a century of shadow-haunted sightings documenting the curiously repellant presence of the North America Sasquatch, or Bigfoot, we aim to identify the factors associated with its presence, delineate the confounding presence of other dread manifestations, and cast our minds globally for a faded glimpse of its remote and scarcely-conceived brethren.</p>
<p>In what can only generously be considered an act of gross negligence, this lecture was stored, at great risk to both its author and its audience, digitally. Technology has, once again, brought us closer than we might care to dread to secrets that we were never intended to taste.</p>
<p>A sharper, more visceral presentation of the baroque thinking underpinning these materials will follow, in an ever-spiralling series of posts on this site. Until then, however, incautious travellers may solemnly consider the below.</p>

<div class="youtube-embed ye-container" itemprop="video" itemscope itemtype="https://schema.org/VideoObject">
	<meta itemprop="url" content="https://www.youtube.com/v/M_upySOOzcI" />
	<meta itemprop="name" content="Numbers of the Beast: Sasquatch Distribution Modelling" />
	<meta itemprop="description" content="Numbers of the Beast: Sasquatch Distribution Modelling" />
	<meta itemprop="uploadDate" content="2025-07-21T19:09:01+01:00" />
	<meta itemprop="thumbnailUrl" content="https://i.ytimg.com/vi/M_upySOOzcI/default.jpg" />
	<meta itemprop="embedUrl" content="https://www.youtube.com/embed/M_upySOOzcI" />
	<meta itemprop="height" content="340" />
	<meta itemprop="width" content="560" />
	<iframe style="border: 0;" class="youtube-player" width="560" height="340" src="https://www.youtube.com/embed/M_upySOOzcI" allowfullscreen></iframe>
</div>

<blockquote><p>
<strong>OII Halloween Lecture</strong><br />
Sasquatch Distribution Modelling: Investigating patterns of Bigfoot sightings in North America.<br />
<em>Prof. Joss Wright</em><br />
<em>Oxford. October 2024</em></p>
<p>The nights grow ever closer. Streetlights flicker, shrouded in the mists, striving to pierce the gloom. The warm certainties of summer give way to the cold, dark ambiguities of autumn. Rumour, myth, and legend rise, primeval, from the shadowed recesses of our collective consciousness, undermining our faith in the fragile congruities that structure our lives.</p>
<p>As summer surrenders to the inexorable tread of autumn, our resolve falters against the unknown horrors residing in the tenebrous peripheries of the world. As scientists, as scholars, our duty is to cling resolutely to our methods and our ideals in the face of encroaching darkness. Our tools may seem fragile in the face of the seething irrationality of the night, but we are called to peer, however tremulously, wherever our inquiries may lead us.</p>
<p>Lights streak across the sky. Stories are woven of twisted faces in the darkness, half-glimpsed creatures in ancient forests, strange encounters in the wilderness. From the earliest stirrings of humanity, to the patterns of complex arcana that silently control our lives today, folklore and legend have long reported phenomena that rebel against mundane description or understanding. As our technologies evolve, and our ability to collate, scrutinise, and manipulate data spiral beyond all restraint, we are ever more capable, if not indeed obliged, to bring the lens of science to bear on these harrowing mysteries.</p>
<p>To embrace this dark season, you are invited to the annual Oxford Internet Institute Halloween Lecture.</p>
<p>This year we will pursue one of the world’s most notorious cryptozoological phenomena, investigating over a century of data regarding sightings of the Sasquatch, or Bigfoot, of North America. In which regions are these cryptic precursors of humanity most commonly observed? What factors, whether environmental or physical, create habitats most suitable for the Sasquatch to thrive, hidden from the encroaching pressures of humanity? Where, were we bold enough to look, might we seek other populations of these elusive creatures?</p>
<p>In this lecture we will examine some of the history surrounding sightings of Bigfoot, and related cryptids. We will impetuously apply statistical methods to derive underlying patterns from reported sightings, and heedlessly strive to uncover their meaning and implications. What can we learn from the accumulated data about the habits of cryptic species living on the fringes of our world? Is the beast, as ever, closer to us than we wish to believe?</p></blockquote>
<a href="https://www.weirddatascience.net/wp-content/uploads/2025/07/sasquatch_distribution_modelling.pdf" class="pdfemb-viewer" style="" data-width="max" data-height="max" data-mobile-width="500"  data-scrollbar="none" data-download="on" data-tracking="on" data-newwindow="on" data-pagetextbox="off" data-scrolltotop="off" data-startzoom="100" data-startfpzoom="100" data-toolbar="bottom" data-toolbar-fixed="off">sasquatch_distribution_modelling<br/></a>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2025/07/21/numbers-of-the-beast-sasquatch-distribution-modelling/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">9482</post-id>	</item>
		<item>
		<title>Whisperings in the Academy</title>
		<link>https://www.weirddatascience.net/2022/11/20/whisperings-in-the-academy/</link>
					<comments>https://www.weirddatascience.net/2022/11/20/whisperings-in-the-academy/#respond</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Sun, 20 Nov 2022 13:12:43 +0000</pubDate>
				<category><![CDATA[event]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[spatial analysis]]></category>
		<category><![CDATA[stan]]></category>
		<category><![CDATA[ufo]]></category>
		<guid isPermaLink="false">https://www.weirddatascience.net/?p=4385</guid>

					<description><![CDATA[<div class="mh-excerpt">The noblest of human endeavours is to enlighten the uninitiated consciousness; to bare its awareness before the endless and terrifying vistas that lie beyond darkness and ignorance.</div> <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2022/11/20/whisperings-in-the-academy/" title="Whisperings in the Academy">[...]</a>]]></description>
										<content:encoded><![CDATA[<p>The noblest of human endeavours is to enlighten the uninitiated consciousness; to bare its awareness before the endless and terrifying vistas that lie beyond darkness and ignorance.</p>
<p>In pursuit of such necessarily painful revelations the Oxford Internet Insitute at the University of Oxford &#8212; the unwitting host on which the investigations here parasitise &#8212; recently hosted an inaugural Halloween lecture. This oration drew on several years of dark explorations chronicled in this blog, to inculcuate into a new generation of unprepared and curious minds the horror and necessity of subjecting our reality to the insidious power of statistical science. Through what seems a dangerously careless oversight, this brief glimpse of truth was recorded and made available for posterity.</p>

<div class="youtube-embed ye-container" itemprop="video" itemscope itemtype="https://schema.org/VideoObject">
	<meta itemprop="url" content="https://www.youtube.com/v/qaBYjnXbnWE" />
	<meta itemprop="name" content="Whisperings in the Academy" />
	<meta itemprop="description" content="Whisperings in the Academy" />
	<meta itemprop="uploadDate" content="2022-11-20T13:12:43+00:00" />
	<meta itemprop="thumbnailUrl" content="https://i.ytimg.com/vi/qaBYjnXbnWE/default.jpg" />
	<meta itemprop="embedUrl" content="https://www.youtube.com/embed/qaBYjnXbnWE" />
	<meta itemprop="height" content="340" />
	<meta itemprop="width" content="560" />
	<iframe style="border: 0;" class="youtube-player" width="560" height="340" src="https://www.youtube.com/embed/qaBYjnXbnWE" allowfullscreen></iframe>
</div>

<p>&nbsp;</p>
<p>For the terminally inquisitive, the archival materials on which this work was drawn are presented here.</p>
<a href="https://www.weirddatascience.net/wp-content/uploads/2022/11/bayes_vs_invaders.pdf" class="pdfemb-viewer" style="" data-width="max" data-height="max" data-mobile-width="500"  data-scrollbar="none" data-download="on" data-tracking="on" data-newwindow="on" data-pagetextbox="off" data-scrolltotop="off" data-startzoom="100" data-startfpzoom="100" data-toolbar="bottom" data-toolbar-fixed="off">bayes_vs_invaders<br/></a>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2022/11/20/whisperings-in-the-academy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4385</post-id>	</item>
		<item>
		<title>Missing Links: Density of Bigfoot Sightings in North America</title>
		<link>https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/</link>
					<comments>https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/#respond</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Sun, 14 Oct 2018 22:15:40 +0000</pubDate>
				<category><![CDATA[cryptozoology]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[scraping]]></category>
		<category><![CDATA[spatial analysis]]></category>
		<guid isPermaLink="false">http://www.weirddatascience.net/blog/?p=406</guid>

					<description><![CDATA[<div class="mh-excerpt">Sightings of Homo sapiens cognatus, or Homo sylvestris, are well-recorded, with a particular prevalence in North America. Bigfoot, otherwise known as the Sasquatch, is one of the most widely-reported cryptids in the world; it is the subject of documentaries, film, music, and countless books. The Bigfoot Field Research <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/" title="Missing Links: Density of Bigfoot Sightings in North America">[...]</a></div>]]></description>
										<content:encoded><![CDATA[<p>Sightings of <a href="http://sasquatchgenomeproject.org/sasquatch_genome_project_011.htm" rel="noopener noreferrer" target="_blank"><em>Homo sapiens cognatus</em></a>, or <a href="https://books.google.co.uk/books?id=Q1YF8WSor-AC&#038;lpg=PA123&#038;ots=AJejG0W58F&#038;dq=homo%20sylvestris%20linnaeus&#038;pg=PA123#v=onepage&#038;q=homo%20sylvestris%20linnaeus&#038;f=false" rel="noopener noreferrer" target="_blank"><em>Homo sylvestris</em></a>, are well-recorded, with a particular prevalence in North America. Bigfoot, otherwise known as the Sasquatch, is one of the most widely-reported cryptids in the world; it is the subject of <a href="http://bfro.net/nimoy2.asp" rel="noopener noreferrer" target="_blank">documentaries</a>, <a href="https://en.wikipedia.org/wiki/The_Abominable_Snowman_(film)" rel="noopener noreferrer" target="_blank">film</a>, <a href="https://www.youtube.com/watch?v=X9b78kM4x0w" rel="noopener noreferrer" target="_blank">music</a>, and countless <a href="https://www.amazon.com/Sasquatch-Legend-Science-Jeff-Meldrum/dp/0765312174" rel="noopener noreferrer" target="_blank">books</a>.</p>
<p>The <a href="http://www.bfro.net" rel="noopener noreferrer" target="_blank">Bigfoot Field Research Organisation</a> has compiled a detailed database of Bigfoot sightings going back to the 1920s. Each sighting is dated, located to the nearest town or road, and contains a full description of the sighting. In many cases, sightings are accompanied by a follow-up report from the organisation itself.</p>
<p>As previously with <a href="http://www.weirddatascience.net/index.php/2018/02/27/are-ufos-more-commonly-seen-near-us-military-bases/" rel="noopener noreferrer" target="_blank">UFO sightings</a> and <a href="http://www.weirddatascience.net/index.php/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/" rel="noopener noreferrer" target="_blank">paranormal manifestations</a>, our first step is to retrieve the data and parse it for analysis. Thankfully, the <code>bfro.net</code> dataset is relatively well-formatted; reports are broken down by region, with each report following a mainly standard format.</p>
<p>As before, we rely on the <a href="https://github.com/hadley/rvest" rel="noopener noreferrer" target="_blank"><code>rvest</code></a> package in R to explore and scrape the website. In this case, the key elements were to retrieve each state&#8217;s set of reports from the top level page, and retrieve the link for each report. Conveniently, these are in a standard format; the website also allows a printer-friendly mode that greatly simplifies scraping.</p>
<p>The scraping code is given here:</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show scraping code.</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
[code language=&#8221;r&#8221;]
<p>library(tidyverse)<br />
library(progress)<br />
library(rvest)</p>
<p># Base URLs for scraping<br />
index_url &amp;lt;- &amp;quot;https://www.bfro.net/GDB/&amp;quot;<br />
base_url &amp;lt;- &amp;quot;https://www.bfro.net&amp;quot;<br />
report_base_url_pattern &amp;lt;- &amp;quot;https:\\/\\/www.bfro.net\\/GDB\\/show_report.asp\\?id=&amp;quot;</p>
<p># Retrieve list of state-level county report pages<br />
get_state_listing_urls &amp;lt;- function( url ) {</p>
<p>	read_html( url ) %&amp;gt;%<br />
		html_nodes( &#8216;a&#8217; ) %&amp;gt;%<br />
		html_attr( &#8216;href&#8217; ) %&amp;gt;%<br />
		str_match( &#8216;.*state_listing.asp\\?state=.*&#8217; ) %&amp;gt;%<br />
		na.omit %&amp;gt;%<br />
		unique %&amp;gt;%<br />
		{ paste0( base_url, . ) }</p>
<p>}</p>
<p># Return all URLs pointing to a county-level list of reports<br />
get_county_report_urls &amp;lt;- function( url ) {</p>
<p>	read_html( url ) %&amp;gt;%<br />
		html_nodes( &#8216;a&#8217; ) %&amp;gt;%<br />
		html_attr( &#8216;href&#8217; ) %&amp;gt;%<br />
		str_match( &#8216;.*show_county_reports.asp\\?state=.*&#8217; ) %&amp;gt;%<br />
		na.omit %&amp;gt;%<br />
		unique %&amp;gt;%<br />
		{ paste0( index_url, . ) }</p>
<p>}</p>
<p># Return all URLs pointing to a report in this page.<br />
get_report_urls &amp;lt;- function( url ) {</p>
<p>	read_html( url ) %&amp;gt;%<br />
		html_nodes( &#8216;a&#8217; ) %&amp;gt;%<br />
		html_attr( &#8216;href&#8217; ) %&amp;gt;%<br />
		str_match( &#8216;.*show_report.asp\\?id=[0-9]+&#8217; ) %&amp;gt;%<br />
		na.omit %&amp;gt;%<br />
		unique %&amp;gt;%<br />
		{ paste0( index_url, . ) }</p>
<p>}</p>
<p>progressive_get_county_report_urls &amp;lt;- function( url, progress_bar ) {</p>
<p>	progress_bar$tick()$print()<br />
	cat( paste(url, &amp;quot;\n&amp;quot;) , file=&amp;quot;work/progress.log&amp;quot;, append=TRUE )<br />
	chime()<br />
	get_county_report_urls( url )</p>
<p>}</p>
<p>progressive_get_report_urls &amp;lt;- function( url, progress_bar ) {</p>
<p>	progress_bar$tick()$print()<br />
	cat( paste(url, &amp;quot;\n&amp;quot;) , file=&amp;quot;work/progress.log&amp;quot;, append=TRUE )<br />
	get_report_urls( url )</p>
<p>}</p>
<p># Pull the report listing from a page.<br />
store_report &amp;lt;- function( url ) {</p>
<p>	report_id &amp;lt;-<br />
		url %&amp;gt;%<br />
		str_replace( report_base_url_pattern, &amp;quot;&amp;quot; ) %&amp;gt;%<br />
		str_replace( &amp;quot;/&amp;quot;, &amp;quot;-&amp;quot; ) %&amp;gt;%<br />
		str_replace( &amp;quot;.html&amp;quot;, &amp;quot;&amp;quot; )</p>
<p>	#message( paste0(&amp;quot;Processing report &amp;quot;, report_id, &amp;quot;&#8230; &amp;quot; ), appendLF=FALSE )</p>
<p>	# Check if this report has already been stored.<br />
	if( file.exists( paste0( &amp;quot;data/&amp;quot;, report_id, &amp;quot;.rds&amp;quot; ) ) ) {<br />
		message( paste0( &amp;quot;Report already retrieved: &amp;quot;, report_id ) )<br />
		return()<br />
	}</p>
<p>	url_pf &amp;lt;- paste0( url, &amp;quot;&amp;amp;PrinterFriendly=True&amp;quot; )</p>
<p>	report &amp;lt;-<br />
		tryCatch(<br />
					{<br />
						# Fetch and parse HTML of current page.<br />
						read_html( url_pf ) %&amp;gt;%<br />
							as.character<br />
					},<br />
					error=function( cond ) {<br />
						message( paste( &amp;quot;URL caused an error:&amp;quot;, url ))<br />
						message( &amp;quot;Error message:&amp;quot;)<br />
						message( cond )<br />
						return( NULL )<br />
					},<br />
					warning=function( cond ) {<br />
						message( paste( &amp;quot;URL caused a warning:&amp;quot;, url ))<br />
						message( &amp;quot;Warning message:&amp;quot;)<br />
						message( cond )<br />
						return( NULL )<br />
					},<br />
					finally={<br />
					}<br />
					)</p>
<p>	# Write report result to disk<br />
	saveRDS( report, paste0(&amp;quot;data/&amp;quot;, report_id, &amp;quot;.rds&amp;quot;) )</p>
<p>}</p>
<p># Progressive version of store_report<br />
progressive_store_report &amp;lt;- function( url, progress_bar ) {</p>
<p>	progress_bar$tick()$print()<br />
	cat( paste(url, &amp;quot;\n&amp;quot;) , file=&amp;quot;work/progress.log&amp;quot;, append=TRUE )<br />
	store_report( url )</p>
<p>}</p>
<p># The key to this is that links of the form<br />
# &amp;lt;https://www.bfro.net/GDB/show_county_reports.asp?state=&#8230;&amp;gt;<br />
# link to each state&#8217;s data. At the top level, then, we can just get all links matching that form.</p>
<p># At each sub-page, the links are:<br />
# &amp;lt;https://www.bfro.net/GDB/show_report.asp?id=&#8230;&amp;gt;<br />
# We can just pull all of those for each state.<br />
# NOTE: There are also non-US reports linked like this directly from the main GDB page.</p>
<p># Finally, it seems that adding &amp;quot;&amp;amp;PrinterFriendly=True&amp;quot; will strip a lot of<br />
# unnecessary formatting.</p>
<p># From the top-level page, get every URL that matches &#8216;show_county_reports.asp?state=&#8217;, make<br />
# the list unique, then download the pages.</p>
<p># Get all non-US state indices<br />
message(&amp;quot;Getting state report lists&#8230;&amp;quot;, appendLF=FALSE )<br />
bfro_state_indices &amp;lt;- get_state_listing_urls( index_url )<br />
message(&amp;quot;done.&amp;quot; )<br />
saveRDS( bfro_state_indices, &amp;quot;work/bfro_state_indices.rds&amp;quot; )</p>
<p># Get all US county-level indices<br />
message(&amp;quot;Getting county-level report urls&#8230; &amp;quot; )<br />
pb &amp;lt;- progress_estimated( length( bfro_state_indices ) )<br />
bfro_county_urls &amp;lt;-<br />
	bfro_state_indices %&amp;gt;%<br />
	map( progressive_get_county_report_urls, pb ) %&amp;gt;%<br />
	unlist %&amp;gt;%<br />
	unique<br />
saveRDS( bfro_county_urls, &amp;quot;work/bfro_county_urls.rds&amp;quot; )</p>
<p># Get URLs of US reports from county pages.<br />
# (Final subset line handles cases where pages are empty of reports, but<br />
# contain other links such as media articles.)<br />
pb &amp;lt;- progress_estimated( length( bfro_county_urls ) )<br />
bfro_report_urls &amp;lt;-<br />
	bfro_county_urls %&amp;gt;%<br />
	map( progressive_get_report_urls, pb ) %&amp;gt;%<br />
	unlist %&amp;gt;%<br />
	unique %&amp;gt;%<br />
	str_subset( &amp;quot;GDB\\/.&amp;quot; )<br />
saveRDS( bfro_report_urls, &amp;quot;work/bfro_report_urls.rds&amp;quot; )</p>
<p># Store all US reports<br />
pb &amp;lt;- progress_estimated( length( bfro_report_urls ) )<br />
bfro_report_urls %&amp;gt;%<br />
	map( progressive_store_report, pb )</p>
<p># Get all non-US indices<br />
message(&amp;quot;Getting non-US top-level report lists&#8230;&amp;quot;, appendLF=FALSE )<br />
bfro_nonus_indices &amp;lt;-<br />
	get_county_report_urls( index_url ) %&amp;gt;%<br />
	str_replace( &amp;quot;GDB\\/\\/&amp;quot;, &amp;quot;\\/&amp;quot; )<br />
message(&amp;quot;done.&amp;quot; )<br />
saveRDS( bfro_nonus_indices, &amp;quot;work/bfro_nonus_indices.rds&amp;quot; )</p>
<p># Get URLs of US reports from county pages<br />
message(&amp;quot;Getting non-US report lists&#8230;&amp;quot;, appendLF=FALSE )<br />
pb &amp;lt;- progress_estimated( length( bfro_nonus_indices ) )<br />
bfro_nonus_report_urls &amp;lt;-<br />
	bfro_nonus_indices %&amp;gt;%<br />
	map( progressive_get_report_urls, pb ) %&amp;gt;%<br />
	unlist %&amp;gt;%<br />
	unique  %&amp;gt;%<br />
	str_subset( &amp;quot;GDB\\/.&amp;quot; )<br />
saveRDS( bfro_nonus_report_urls, &amp;quot;work/bfro_nonus_report_urls.rds&amp;quot; )</p>
<p># Store all US reports<br />
pb &amp;lt;- progress_estimated( length( bfro_nonus_report_urls ) )<br />
bfro_nonus_report_urls %&amp;gt;%<br />
	map( progressive_store_report, pb )</p>
[/code]
</div></div>
</div>
<p>With each page retrieved, we step through and parse each report. Again, each page is fairly well-formatted, and uses a standard set of tags for date, location, and similar. The report parsing code is given here:</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show parsing code.</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
[code language=&#8221;r&#8221;]
<p># NOTES</p>
<p># Process entire list to check for standardised headers. These are in capitals, and located in &amp;lt;span class=&amp;quot;field&amp;quot;&amp;gt; tags.</p>
<p># Report starts with:<br />
# &amp;lt;span class=&amp;quot;reportheader&amp;quot;&amp;gt;<br />
# &amp;lt;span class=\&amp;quot;reportclassification\&amp;quot;&amp;gt; (Look up what these mean.)<br />
# Some following &amp;lt;span class=&amp;quot;field&amp;quot;&amp;gt; types contain general summary information, eg:<br />
# &amp;quot; &amp;lt;span class=\&amp;quot;field\&amp;quot;&amp;gt;Submitted  by  witness   on Thursday, November 1, 2007.&amp;lt;/span&amp;gt;&amp;quot;<br />
# Following fields are in span tags separated by paragraph tags, eg:<br />
# &amp;lt;p&amp;gt;&amp;lt;span class=\&amp;quot;field\&amp;quot;&amp;gt;YEAR:&amp;lt;/span&amp;gt; 2007&amp;lt;/p&amp;gt;<br />
# STATE and COUNTY fields are typically links; we should pull their text. (I can&#8217;t see a good reason to parse links to anything other than the link text for our purposes.)</p>
<p>library(tidyverse)<br />
library(magrittr)<br />
library(progress)<br />
library(rvest)<br />
library(lubridate)</p>
<p># Exploratory functions</p>
<p># List all capitalised fields seen in any file<br />
list_all_fields &amp;lt;- function() {</p>
<p>	filenames &amp;lt;- list.files( &amp;quot;data&amp;quot;, pattern=&amp;quot;*.rds&amp;quot;, full.names=TRUE)</p>
<p>	# In each file, select the &amp;lt;span&amp;gt; classes, match the  uppercase field names, and extract text.<br />
	all_fields &amp;lt;-<br />
		filenames %&amp;gt;%<br />
		map( list_report_fields ) %&amp;gt;%<br />
		unlist %&amp;gt;%<br />
		unique</p>
<p>	saveRDS( all_fields, &amp;quot;work/fields.rds&amp;quot; )</p>
<p>	return( all_fields )</p>
<p>}</p>
<p>fields_to_colnames &amp;lt;- function( fields ) {</p>
<p>	# In total there are 18 fields reported in the data, with the final one<br />
	# being an apparently miscoded date and place from a report.</p>
<p>	# Format the text appropriately for dataframe column names<br />
	fields %&amp;gt;%<br />
		head( 17 ) %&amp;gt;%<br />
		str_remove( &amp;quot;:&amp;quot; ) %&amp;gt;%<br />
		str_replace_all( &amp;quot; &amp;quot;, &amp;quot;_&amp;quot; ) %&amp;gt;%<br />
		str_to_lower()</p>
<p>}</p>
<p>list_report_fields &amp;lt;- function( report ) {</p>
<p>	to_process &amp;lt;- readRDS( report )</p>
<p>	bfro_fields &amp;lt;- NULL</p>
<p>	if( !is.null( to_process ) ) {<br />
			bfro_fields &amp;lt;-<br />
				to_process %&amp;gt;%<br />
				read_html %&amp;gt;%<br />
				html_nodes( &amp;quot;span&amp;quot; ) %&amp;gt;%<br />
				html_nodes(xpath = &#8216;//*[@class=&amp;quot;field&amp;quot;]&#8217;) %&amp;gt;%<br />
				html_text %&amp;gt;%<br />
				str_subset( &amp;quot;[A-Z]+:&amp;quot; )<br />
	}</p>
<p>	return( bfro_fields )<br />
}</p>
<p># Extract node date<br />
parse_report_data &amp;lt;- function( report_data ) {</p>
<p>	# report_data should be an xml_nodeset</p>
<p>	# Metadata<br />
	metadata_list &amp;lt;-<br />
		report_data %&amp;gt;%<br />
		html_text %&amp;gt;%<br />
		str_subset( &amp;quot;^[A-Z ]+: &amp;quot; ) %&amp;gt;%<br />
		str_split_fixed( &amp;quot;: &amp;quot;, 2 ) %&amp;gt;%<br />
		as.tibble %&amp;gt;%<br />
		spread( key=V1, value=V2 ) %&amp;gt;%<br />
		set_colnames( fields_to_colnames( colnames(.) ) )</p>
<p>	# Extra details<br />
	extra_text &amp;lt;-<br />
		report_data %&amp;gt;%<br />
		html_text %&amp;gt;%<br />
		str_remove( &amp;quot;^[A-Z ]+:.*&amp;quot; ) %&amp;gt;%<br />
		str_flatten( &amp;quot; &amp;quot; ) %&amp;gt;%<br />
		str_trim</p>
<p>	# Add extra details as a column<br />
	metadata_list$extra &amp;lt;- extra_text</p>
<p>	# Note whether date is rough or accurately reported<br />
	metadata_list$rough_date &amp;lt;- FALSE</p>
<p>	# &amp;quot;Fix&amp;quot; missing date or month columns<br />
	if( &amp;quot;date&amp;quot; %in% colnames( metadata_list ) == FALSE ) {<br />
		metadata_list$date &amp;lt;- &amp;quot;1&amp;quot;<br />
		metadata_list$rough_date &amp;lt;- TRUE<br />
	}</p>
<p>	if( &amp;quot;month&amp;quot; %in% colnames( metadata_list ) == FALSE ) {<br />
		metadata_list$month &amp;lt;- &amp;quot;January&amp;quot;<br />
		metadata_list$rough_date &amp;lt;- TRUE<br />
	}</p>
<p>	# Combine date columns (year, month, date) to a true date.<br />
	metadata_list &amp;lt;-<br />
		metadata_list %&amp;gt;%<br />
		mutate( year = str_replace( year, &amp;quot;.*([0-9]{4}).*&amp;quot;, &amp;quot;\\1&amp;quot; ) ) %&amp;gt;%<br />
		mutate( date = paste0( year, &amp;quot;-&amp;quot;, month, &amp;quot;-&amp;quot;, date ), year=NULL, month=NULL ) %&amp;gt;%<br />
		mutate( date = as.POSIXct( date, format=&amp;quot;%Y-%B-%d&amp;quot; ) )</p>
<p>}</p>
<p># Read a file and pass to `post_get_all_thread`<br />
process_file &amp;lt;- function( filename ) {</p>
<p>	# Read stored file<br />
	to_process &amp;lt;- readRDS( filename )</p>
<p>	# Don&#8217;t process null files<br />
	if( is.null( to_process ) )<br />
		return( NULL )</p>
<p>	if( length( to_process ) == 0 )<br />
		return( NULL )</p>
<p>	# Produce an xml_nodeset for parsing<br />
	xml_thread &amp;lt;-<br />
		to_process %&amp;gt;%<br />
		read_html %&amp;gt;%<br />
		html_nodes( &amp;quot;p&amp;quot; )</p>
<p>	parse_report_data( xml_thread )</p>
<p>}</p>
<p># Progressive version of process_file<br />
progressive_process_file &amp;lt;- function( filename, progress_bar ) {</p>
<p>	progress_bar$tick()$print()<br />
	cat( paste(filename, &amp;quot;\n&amp;quot;) , file=&amp;quot;progress.log&amp;quot;, append=TRUE )</p>
<p>	report &amp;lt;-<br />
		tryCatch(<br />
					{<br />
						process_file( filename )<br />
					},<br />
					error=function( cond ) {<br />
						message( paste( &amp;quot;File caused an error:&amp;quot;, filename ))<br />
						message( &amp;quot;Error message:&amp;quot;)<br />
						message( cond )<br />
						return( NULL )<br />
					},<br />
					warning=function( cond ) {<br />
						message( paste( &amp;quot;URL caused a warning:&amp;quot;, url ))<br />
						message( &amp;quot;Warning message:&amp;quot;)<br />
						message( cond )<br />
						return( NULL )<br />
					},<br />
					finally={<br />
					}<br />
					)</p>
<p>	return( report )</p>
<p>}</p>
<p>## Processing starts here</p>
<p># Read all .rds data files and process into a thread<br />
filenames &amp;lt;- list.files(&amp;quot;data&amp;quot;, pattern=&amp;quot;*.rds&amp;quot;, full.names=TRUE)<br />
pb &amp;lt;- progress_estimated( length( filenames ) )</p>
<p># Begin logging<br />
cat( &amp;quot;Processing&#8230; &amp;quot;, file=&amp;quot;progress.log&amp;quot;, append=FALSE )</p>
<p>bfro_tbl &amp;lt;-<br />
	filenames %&amp;gt;%<br />
	map( progressive_process_file, pb ) %&amp;gt;%<br />
	bind_rows</p>
<p>saveRDS( bfro_tbl, &amp;quot;data/bfro_processed.rds&amp;quot; )</p>
[/code]
</div></div>
</div>
<p>With each report parsed into a form suitable for analysis, the final step in scraping the site is to geolocate the reports. As in previous posts, we rely on Google&#8217;s geolocation API. For each report, we extract an appropriate address and parse it into a set of latitude and longitude coordinates. For the purposes of this initial scrape we restrict ourselves to North America, which compromises a large majority of reports on <code>bfro.net</code>. Geolocation code is included below. (Note that a Google Geolocation API key is required for this code to run.)</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show geolocation code.</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
[code language=&#8221;r&#8221;]
<p>library(googleway)<br />
library(progress)<br />
library(tidyverse)<br />
library(magrittr)</p>
<p># weird.data.science Google API key (Geocoding API enabled)<br />
key &amp;lt;- &amp;lt;INSERT API KEY HERE&amp;gt;</p>
<p># Load bfro tibble<br />
bfro_data &amp;lt;- readRDS( &amp;quot;data/bfro_processed.rds&amp;quot; )</p>
<p># Geocode entries</p>
<p># BFRO entries contain some, all, or none of:<br />
# country, province, state, county, nearest_town</p>
<p># Country is only used for Canada, in which case a province is given.<br />
# Country and province are NA for the US.</p>
<p># Best plan, then is to create a string of (nearest_town, province, country) for Canadian results, and (nearest_town, county, state, &amp;quot;US&amp;quot;) for US results.</p>
<p># Bound the request to be only in North America.<br />
# (Used: &amp;lt;https://boundingbox.klokantech.com&amp;gt;)<br />
# (SW-&amp;gt;NE latitude and longitude.)<br />
bounding_box &amp;lt;- list( c( -170.3, 	24.4),<br />
							 c(  -52.3,		83.3) )</p>
<p>form_location_string &amp;lt;- function( country, province, state, county, nearest_town ) {</p>
<p>	location_string &amp;lt;- NA</p>
<p>	# US case, then Canadian<br />
	if( is.na( country ) )<br />
		location_string &amp;lt;- paste0( nearest_town, &amp;quot;, &amp;quot;, county, &amp;quot;, &amp;quot;, state, &amp;quot;, US&amp;quot; )<br />
	else<br />
		location_string &amp;lt;- paste0( nearest_town, &amp;quot;, &amp;quot;, province, &amp;quot;, &amp;quot;, &amp;quot;, Canada&amp;quot; )</p>
<p>	# Strip double commas caused by NA values and remove bracketed clauses.<br />
	location_string %&amp;lt;&amp;gt;%<br />
		str_remove_all( &amp;quot;\\([^\\)]*\\)&amp;quot; ) %&amp;gt;%<br />
		str_replace_all( &amp;quot;, , &amp;quot;, &amp;quot;, &amp;quot; ) %&amp;gt;%<br />
		str_replace_all( &amp;quot; ,&amp;quot;, &amp;quot;,&amp;quot; ) %&amp;gt;%<br />
		str_remove_all( &amp;quot;NA, &amp;quot; )</p>
<p>}</p>
<p># Create a safe version of google_geocode<br />
safe_geocode &amp;lt;- safely( google_geocode )</p>
<p># Wrap google_geocode with a progress bar call.<br />
# Also, optionally remove any bracketed substrings entirely (strip_brackets)<br />
progressive_geocode &amp;lt;- function( location_string, progress_bar ) {</p>
<p>	# Write status to log file.<br />
	progress_bar$tick()$print()</p>
<p>	cat( paste0( location_string, &amp;quot;\n&amp;quot; ), file=&amp;quot;progress.log&amp;quot;, append=TRUE )</p>
<p>	result &amp;lt;-<br />
		safe_geocode(<br />
						 address = location_string,<br />
						 key = key,<br />
						 bounds = bounding_box,<br />
						 simplify = TRUE ) </p>
<p>	# Note that this can be NULL<br />
	return( result$result )</p>
<p>}</p>
<p># Logging and output<br />
## Clear the screen first<br />
cat(c(&amp;quot;&#92;&#48;33[2J&amp;quot;,&amp;quot;&#92;&#48;33[0;0H&amp;quot;))<br />
cat(&amp;quot;Geolocating entries&#8230;\n&amp;quot;)<br />
cat( &amp;quot;Geolocating entries&#8230;\n&amp;quot;, file=&amp;quot;progress.log&amp;quot;, append=FALSE )</p>
<p># Create the location string<br />
bfro_data %&amp;lt;&amp;gt;%<br />
	mutate( location = form_location_string( country, province, state, county, nearest_town ) )</p>
<p># Geolocate each location.<br />
pb &amp;lt;- progress_estimated(nrow(bfro_data))<br />
bfro_data$geolocation &amp;lt;-<br />
	map( bfro_data$location, progressive_geocode, progress_bar = pb )</p>
<p>cat(&amp;quot;\nComplete.\n&amp;quot;)</p>
<p>## With all values scraped, save geolocated data.<br />
saveRDS( bfro_data, file=&amp;quot;work/bfro_data_geolocated.rds&amp;quot;)</p>
[/code]
</div></div>
</div>
<p>With geolocated data in hand, we can now venture into the wilds. In which areas of North America are Sasquatch most commonly seen to roam? The plot below shows the overall density of Bigfoot sightings, with individual reports marked.</p>
<figure id="attachment_414" aria-describedby="caption-attachment-414" style="width: 1024px" class="wp-caption aligncenter"><a href="http://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density.png"><img fetchpriority="high" decoding="async" data-attachment-id="414" data-permalink="https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/bigfoot-density-2/" data-orig-file="https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density.png" data-orig-size="1920,1080" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Bigfoot Density Plot" data-image-description="" data-image-caption="&lt;p&gt;Density of Bigfoot sightings in North America.&lt;/p&gt;
" data-large-file="https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-1024x576.png" src="http://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-1024x576.png" alt="Density plot of Bigfoot sightings in North America" width="1024" height="576" class="size-large wp-image-414" srcset="https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-1024x576.png 1024w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-640x360.png 640w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-300x169.png 300w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-768x432.png 768w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-64x36.png 64w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption id="caption-attachment-414" class="wp-caption-text">Density of Bigfoot sightings in North America. (<a href="http://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density.pdf">PDF Version</a>)</figcaption></figure>
<p>There are particular clusters on the Great Lakes, particularly in Southern Ontario; as well as in the Pacific Northwest. Smaller notable clusters exist in Florida, centered around Orlando. As with most report-based datasets, sightings are skewed towards areas of high population density.</p>
<p>The obvious first question to ask of such data is which, if any, environmental features correlate with these sightings. Other analyses of Bigfoot sightings, such as the seminal work of Lozier et al.<span id='easy-footnote-1-406' class='easy-footnote-margin-adjust'></span><span class='easy-footnote'><a href='https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/#easy-footnote-bottom-1-406' title='Lozier, J. D., Aniello, P. and Hickerson, M. J. (2009), Predicting the distribution of Sasquatch in western North America: anything goes with ecological niche modelling. Journal of Biogeography, 36: 1623-1627. doi:10.1111/j.1365-2699.2009.02152.x (&lt;a href=&quot;http://onlinelibrary.wiley.com/doi/abs/10.1111/j.1365-2699.2009.02152.x&quot;&gt;http://onlinelibrary.wiley.com/doi/abs/10.1111/j.1365-2699.2009.02152.x&lt;/a&gt;)'><sup>1</sup></a></span>, have suggested that forested regions are natural habitats for Sasquatch.</p>
<p>To answer this, we combine the underlying mapping data and Bigfoot sightings, with bioclimatic data taken from the <a href="http://www.landcover.org">Global Land Cover Facility</a>. Amongst other datasets, this provides us with an accurate, high-resolution <a href="http://www.landcover.org/data/lc/">land cover</a> raster map, detailing vegetation for each 5-arcminute cell in the country &#8212; approximately one cell per 10km² .</p>
<p>There are a range of bioclimatic variables in this dataset. The diagram below overlays all areas that are some form of forest onto the previous density plot.</p>
<figure id="attachment_416" aria-describedby="caption-attachment-416" style="width: 1024px" class="wp-caption aligncenter"><a href="http://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest.png"><img loading="lazy" decoding="async" data-attachment-id="416" data-permalink="https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/bigfoot-density-forest-2/" data-orig-file="https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest.png" data-orig-size="1920,1080" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Bigfoot Density Forest Cover" data-image-description="" data-image-caption="&lt;p&gt;Density of Bigfoot sightings in North America (Yellow) with forested areas overlaid (green).&lt;/p&gt;
" data-large-file="https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-1024x576.png" src="http://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-1024x576.png" alt="Density plot of Bigfoot sightings showing forest cover" width="1024" height="576" class="size-large wp-image-416" srcset="https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-1024x576.png 1024w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-640x360.png 640w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-300x169.png 300w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-768x432.png 768w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest-64x36.png 64w, https://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption id="caption-attachment-416" class="wp-caption-text">Density of Bigfoot sightings in North America (yellow) with forested areas overlaid (green). (<a href="http://www.weirddatascience.net/wp-content/uploads/2018/10/bigfoot-density-forest.pdf">PDF Version</a>)</figcaption></figure>
<p>The code for producing both of the above plots is given here:</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show density plotting code.</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
[code language=&#8221;r&#8221;]
<p>library(spatstat)</p>
<p>library(rgdal)<br />
library(maptools)</p>
<p>library(tidyverse)<br />
library(magrittr)<br />
library(ggplot2)<br />
library(ggthemes)<br />
library(raster)<br />
library(viridis)<br />
library(scales)</p>
<p>library(sf) </p>
<p>library(showtext)</p>
<p>library(grid)</p>
<p>library(cowplot)<br />
library(magick)</p>
<p># Load font<br />
font_add( &amp;quot;mapfont&amp;quot;, &amp;quot;/usr/share/fonts/TTF/weird/alchemy/1689 GLC Garamond Pro/1689GLCGaramondProNormal.otf&amp;quot; )<br />
showtext_auto()</p>
<p># Read world shapefile data and tranform to an appropriate projection.<br />
world &amp;lt;- readOGR( dsn=&#8217;data/ne/10m_cultural&#8217;, layer=&#8217;ne_10m_admin_0_countries&#8217; )<br />
world_subset &amp;lt;- world[ world$iso_a2 %in% c(&amp;quot;US&amp;quot;,&amp;quot;CA&amp;quot;), ]
world_subset &amp;lt;- spTransform(world_subset,CRS(&amp;quot;+init=epsg:4326 +lon_wrap=170&amp;quot;))<br />
world_df &amp;lt;- fortify( world_subset )</p>
<p># Read bfro database, filtering out locations with &amp;quot;NA&amp;quot; latitude or longitude.<br />
# Also filter results that have been geolocated to &amp;quot;56.13037, -106.3468&amp;quot;, which is the centroid of Canada, and results from locations having no more specific result.<br />
bfro_tbl &amp;lt;-<br />
	readRDS( &amp;quot;data/bfro_locations.rds&amp;quot; ) %&amp;gt;%<br />
	filter( !is.na( lat ) &amp;amp; !is.na( lng ) ) %&amp;gt;%<br />
	filter( not( lat == modal( lat ) &amp;amp; lng == modal( lng ) ) )</p>
<p># Convert the bfro dataframe to a spatial dataframe that contains<br />
# explicit longitude and latitude projected appropriately for plotting.<br />
coordinates( bfro_tbl ) &amp;lt;- ~lng+lat<br />
proj4string( bfro_tbl ) &amp;lt;- CRS(&amp;quot;+init=epsg:4326 +lon_wrap=170&amp;quot;)<br />
bfro_tbl_spatial &amp;lt;- spTransform(bfro_tbl,CRS(proj4string(bfro_tbl)))</p>
<p># Restrict bfro_tbl to those points in the polygons defined by world_subset<br />
bfro_tbl_rows &amp;lt;- bfro_tbl_spatial %&amp;gt;%<br />
	over( world_subset ) %&amp;gt;%<br />
	is.na() %&amp;gt;%<br />
	not() %&amp;gt;%<br />
	rowSums() %&amp;gt;%<br />
	`!=`(0) %&amp;gt;%<br />
	which</p>
<p>bfro_tbl &amp;lt;- as.tibble( bfro_tbl_spatial[ bfro_tbl_rows, ] )</p>
<p># Create window for spatial analysis<br />
bfro_owin &amp;lt;- as.owin.SpatialPolygons(world_subset)</p>
<p># Function to plot density of a specific manifestation type.<br />
# plot_resolution is for the density raster, and is mainly used for quick prototyping of the output.<br />
density_plot &amp;lt;- function( density_res ) {</p>
<p>	cat( paste0( &amp;quot;Plotting density: &#8230; &amp;quot; ) )</p>
<p>	bfro_ppp &amp;lt;-<br />
		ppp(<br />
			 x=coordinates(bfro_tbl_spatial)[,1],<br />
			 y=coordinates(bfro_tbl_spatial)[,2],<br />
			 window = bfro_owin<br />
			 )</p>
<p>	# This discards &#8216;illegal&#8217; points outside of the window<br />
	bfro_ppp &amp;lt;- as.ppp(bfro_ppp)</p>
<p>	bfro_density &amp;lt;- density( bfro_ppp, diggle=T, sigma=2, dimyx = c( density_res, density_res ) )</p>
<p>	# Make density image object usable by ggplot as a raster<br />
	bfro_density_raster &amp;lt;- raster( bfro_density )<br />
	bfro_raster_tbl &amp;lt;- as.tibble( rasterToPoints( bfro_density_raster ) )</p>
<p>	# Show the map<br />
	gp &amp;lt;- ggplot()  </p>
<p>	# Add density of sightings as raster.<br />
	gp &amp;lt;- gp +<br />
		geom_raster( data = bfro_raster_tbl, aes( x=x, y=y, fill = layer ), alpha=0.8, show.legend=FALSE ) +<br />
		scale_fill_viridis( option = &amp;quot;cividis&amp;quot;, direction=1 )</p>
<p>		# Add sightings as points.<br />
	gp &amp;lt;- gp +<br />
		geom_point( data = as.tibble( bfro_ppp ), aes( x=x, y=y ), colour=&amp;quot;yellow&amp;quot;, size=0.1, alpha=0.5, show.legend=FALSE ) </p>
<p>	gp &amp;lt;- gp +<br />
		geom_map( data = world_df, aes( map_id=id ), colour=&amp;quot;#3c3f4a&amp;quot;, fill = &amp;quot;transparent&amp;quot;, size = 0.4, map = world_df ) </p>
<p>	# Theming<br />
	gp &amp;lt;- gp +<br />
		theme_map() </p>
<p>	gp &amp;lt;- gp +<br />
		theme(<br />
				plot.background = element_rect(fill = &amp;quot;transparent&amp;quot;, colour = &amp;quot;transparent&amp;quot;),<br />
				panel.border = element_blank(),<br />
				) </p>
<p>	gp &amp;lt;- gp +<br />
		guides( fill = guide_colourbar( title.position=&amp;quot;top&amp;quot;, direction=&amp;quot;horizontal&amp;quot;, barwidth=6, barheight=0.4 ) )</p>
<p>	cat(&amp;quot;done.\n&amp;quot; )<br />
	return(gp)</p>
<p>}</p>
<p># Add bioclimatic points to an existing plot<br />
add_bioclimatic_variables &amp;lt;- function( gp, bioclim = seq( 1, 16 ) ) {</p>
<p>	# This gets climatic variables for global range.<br />
	# (res=0.5 requires latitude and longitude to define a tile to download,<br />
	# but 2.5 minutes of a degree is ~5 miles, so probably good enough.)<br />
	#wc &amp;lt;- getData( &#8216;worldclim&#8217;, res=2.5, var=&#8217;bio&#8217; )</p>
<p>	# Value	Label<br />
	#	0		Water<br />
	#	1		Evergreen Needleleaf forest<br />
	#	2		Evergreen Broadleaf forest<br />
	#	3		Deciduous Needleleaf forest<br />
	#	4		Deciduous Broadleaf forest<br />
	#	5		Mixed forest<br />
	#	6		Closed shrublands<br />
	#	7		Open shrublands<br />
	#	8		Woody savannas<br />
	#	9		Savannas<br />
	#	10		Grasslands<br />
	#	11		Permanent wetlands<br />
	#	12		Croplands<br />
	#	13		Urban and built-up<br />
	#	14		Cropland/Natural vegetation mosaic<br />
	#	15		Snow and ice<br />
	#	16		Barren or sparsely vegetated<br />
	#	254	Unclassified<br />
	#	255	Fill Value                     </p>
<p>	glcf &amp;lt;- raster( &amp;quot;~/opt/datasets/gis/landcover/glcf/LC_5min_global_2012.tif&amp;quot; )</p>
<p>	# We can&#8217;t just reproject a raster to wrap differently.<br />
	# This splits and merges the two edges.<br />
	# (This is fragile, unfortunately, but works here.)<br />
	# (Reprojecting is best done as the last step, apparently.)<br />
	glcf_west &amp;lt;- crop(glcf, extent(-180, 0, 18, 84))<br />
	glcf_east &amp;lt;- crop(glcf, extent(0, 180, 18, 84))<br />
	extent(glcf_west) &amp;lt;- c(180, 360, 18, 84)<br />
	glcf  &amp;lt;- merge(glcf_west, glcf_east )</p>
<p>	glcf &amp;lt;- crop( glcf, extent( world_subset ) )<br />
	glcf &amp;lt;- projectRaster( glcf, crs = CRS(&amp;quot;+init=epsg:4326&amp;quot;) )</p>
<p>	# Make density image object usable by ggplot as a raster<br />
	glcf_raster_tbl &amp;lt;- as.tibble( rasterToPoints( glcf ) )<br />
	colnames( glcf_raster_tbl ) &amp;lt;- c (&amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;layer&amp;quot; )</p>
<p>	# Add bioclimatic variables<br />
	gp &amp;lt;- gp +<br />
		geom_raster( data = glcf_raster_tbl[ which( glcf_raster_tbl$layer %in% bioclim ), ], alpha=0.8, aes( x=x, y=y ), fill=&amp;quot;#7cfc00&amp;quot;, show.legend=FALSE ) </p>
<p>	gp</p>
<p>}</p>
<p># Cowplot for full-panel plotting. (Parchment background).<br />
theme_set(theme_cowplot(font_size=4, font_family = &amp;quot;mapfont&amp;quot; ) )</p>
<p># Only calculate the density plot if it isn&#8217;t already stored on disk.<br />
if( not( file.exists( &amp;quot;work/density_plot.rds&amp;quot; ) ) ) {<br />
	gp &amp;lt;- density_plot( 1024 )<br />
	saveRDS( gp, &amp;quot;work/density_plot.rds&amp;quot; )<br />
} else {<br />
	gp &amp;lt;- readRDS( &amp;quot;work/density_plot.rds&amp;quot; )<br />
}</p>
<p># Create a plot including the bioclimatic variables.<br />
bioclim_gp &amp;lt;-<br />
	add_bioclimatic_variables( gp, seq( 1, 5 ) )</p>
<p># Construct full plot, with title and backdrop.<br />
title &amp;lt;- ggdraw() +<br />
	draw_label(&amp;quot;Bigfoot Sightings in North America&amp;quot;, fontfamily=&amp;quot;mapfont&amp;quot;, colour = &amp;quot;#3c3f4a&amp;quot;, size=20, hjust=0, vjust=1, x=0.02, y=0.88) +<br />
	draw_label(&amp;quot;http://www.weirddatascience.net | @WeirdDataSci&amp;quot;, fontfamily=&amp;quot;mapfont&amp;quot;, colour = &amp;quot;#3c3f4a&amp;quot;, size=12, hjust=0, vjust=1, x=0.02, y=0.40)</p>
<p>data_label &amp;lt;- ggdraw() +<br />
	draw_label(&amp;quot;Data: http://www.bfro.net&amp;quot;, fontfamily=&amp;quot;mapfont&amp;quot;, colour = &amp;quot;#3c3f4a&amp;quot;, size=12, hjust=1, x=0.98 )</p>
<p>tgp &amp;lt;- plot_grid(title, gp, data_label, ncol=1, rel_heights=c(0.1, 1, 0.1)) </p>
<p>parchment_plot &amp;lt;- ggdraw() +<br />
	draw_image(&amp;quot;img/parchment.jpg&amp;quot;, scale=1.4 ) +<br />
	draw_plot(tgp)</p>
<p>save_plot(&amp;quot;output/bigfoot-density.pdf&amp;quot;,<br />
							parchment_plot,<br />
							base_width = 16,<br />
							base_height = 9,<br />
			           	base_aspect_ratio = 1.78 )</p>
<p># Add bioclimatic variables to plot.<br />
title &amp;lt;- ggdraw() +<br />
	draw_label(&amp;quot;Bigfoot Sightings in North America Showing Forest Cover&amp;quot;, fontfamily=&amp;quot;mapfont&amp;quot;, colour = &amp;quot;#3c3f4a&amp;quot;, size=20, hjust=0, vjust=1, x=0.02, y=0.88) +<br />
	draw_label(&amp;quot;http://www.weirddatascience.net | @WeirdDataSci&amp;quot;, fontfamily=&amp;quot;mapfont&amp;quot;, colour = &amp;quot;#3c3f4a&amp;quot;, size=12, hjust=0, vjust=1, x=0.02, y=0.40)</p>
<p>data_label &amp;lt;- ggdraw() +<br />
	draw_label(&amp;quot;Data: http://www.bfro.net&amp;quot;, fontfamily=&amp;quot;mapfont&amp;quot;, colour = &amp;quot;#3c3f4a&amp;quot;, size=12, hjust=1, x=0.98 )</p>
<p>tgp &amp;lt;- plot_grid(title, bioclim_gp, data_label, ncol=1, rel_heights=c(0.1, 1, 0.1)) </p>
<p>parchment_plot &amp;lt;- ggdraw() +<br />
	draw_image(&amp;quot;img/parchment.jpg&amp;quot;, scale=1.4 ) +<br />
	draw_plot(tgp)</p>
<p>save_plot(&amp;quot;output/bigfoot-density-forest.pdf&amp;quot;,<br />
							parchment_plot,<br />
							base_width = 16,<br />
							base_height = 9,<br />
			           	base_aspect_ratio = 1.78 )</p>
[/code]
</div></div>
</div>
<p>From this initial plot we can see that, whilst tree cover is certainly not a bad predictor of Bigfoot sightings, it is far from a definitive correlation. The largest cluster, around the US-Canada border near Toronto, is principally lakes; whilst the secondary cluster in Florida is neither significantly forested or even close to the Everglades, which might have been expected. From the other perspective, there are significant forested areas for which sightings are reasonably rare.</p>
<p>The mystery of Bigfoot&#8217;s natural habitat and preferences is, therefore, very much unanswered from our initial analysis. With a broad range of variables still to explore &#8212; climate, altitude, food sources &#8212; future posts will attempt to determine what conditions lend themselves to strange survivals of pre-human primate activity. Perhaps changing conditions have pushed our far-distant cousins to previously unsuspected regions.</p>
<p>Until then, we keep following these trails into data unknown.</p>
<p><strong>References</strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2018/10/14/missing-links-density-of-bigfoot-sightings-in-north-america/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">406</post-id>	</item>
		<item>
		<title>Mapping Paranormal Manifestations in the British Isles</title>
		<link>https://www.weirddatascience.net/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/</link>
					<comments>https://www.weirddatascience.net/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/#comments</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Tue, 10 Apr 2018 20:08:23 +0000</pubDate>
				<category><![CDATA[cryptozoology]]></category>
		<category><![CDATA[ghosts]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[paranormal]]></category>
		<category><![CDATA[spatial analysis]]></category>
		<category><![CDATA[ufo]]></category>
		<guid isPermaLink="false">http://www.weirddatascience.net/blog/?p=284</guid>

					<description><![CDATA[<div class="mh-excerpt">In our last entry we analysed the relative frequency of paranormal manifestations in the British Isles according to the Paranormal Database. The results of that analysis showed that hauntings of various forms are by far the most commonly-reported paranormal encounter in the British Isles, followed by cryptozoological sightings. <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/" title="Mapping Paranormal Manifestations in the British Isles">[...]</a></div>]]></description>
										<content:encoded><![CDATA[<p>In our <a href="http://www.weirddatascience.net/index.php/2018/03/17/paranormal-manifestations-in-the-british-isles/" rel="noopener noreferrer" target="_blank">last entry</a> we analysed the relative frequency of paranormal manifestations in the British Isles according to the <a href="http://www.paranormaldatabase.com" rel="noopener noreferrer" target="_blank">Paranormal Database</a>. The results of that analysis showed that hauntings of various forms are by far the most commonly-reported paranormal encounter in the British Isles, followed by cryptozoological sightings.</p>
<p>This is, however, relatively unsatisfactory. It is much more interesting to know where such sightings and events occur. Are there particular haunts of restless spirits? Do mysterious beasts roam in particular regions more than others? To answer these questions, we need to delve into the specific locations of different reports.</p>
<p>The Paranormal Database does contain location information, but it is given very informally. To map this we can make use of <a href="https://developers.google.com/maps/documentation/geolocation/intro">Google&#8217;s Geolocation API</a> to convert free text strings, such as &#8220;<a href="https://www.nationaltrust.org.uk/features/a-haunted-library-and-a-bookish-ghost" rel="noopener noreferrer" target="_blank">Felbrigg Hall, Norfolk</a>&#8221; into usable latitude and longitude coordinates. (In this case: <a href="https://goo.gl/maps/xr3vZHB4Kwq">52.907479, 1.259443</a>.)</p>
<p>The geolocation is not perfect, but with sufficient manipulation of the service it was possible to produce geolocated coordinates for most of the entries in the database. In order to represent these meaningfully, we have also subdivided the entries into a different types. The original Paranormal Database data is subdivided into twenty categories, which we have reduced to six for easier presentation. This includes collapsing the various kinds of haunting, from poltergeists to &#8216;post-mortem manifestions&#8217;, simply to hauntings. Similarly, we combine alien big cats and <a href="https://en.wikipedia.org/wiki/Black_Shuck" rel="noopener noreferrer" target="_blank">shuck</a> into the broader family of cryptozoology.</p>
<p>With this in place, we can see the overall distribution of paranormal events in the British Isles.</p>
<figure id="attachment_289" aria-describedby="caption-attachment-289" style="width: 1024px" class="wp-caption aligncenter"><a href="http://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal.png"><img loading="lazy" decoding="async" data-attachment-id="289" data-permalink="https://www.weirddatascience.net/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/paranormal-2/" data-orig-file="https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal.png" data-orig-size="1920,1080" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="paranormal" data-image-description="" data-image-caption="&lt;p&gt;Paranormal manifestations in the British Isles.&lt;/p&gt;
" data-large-file="https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-1024x576.png" src="http://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-1024x576.png" class="wp-image-289 size-large" width="1024" height="576" alt="" srcset="https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-1024x576.png 1024w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-640x360.png 640w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-300x169.png 300w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-768x432.png 768w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-64x36.png 64w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption id="caption-attachment-289" class="wp-caption-text">Paranormal manifestations in the British Isles. (<a href="http://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal.pdf" rel="noopener noreferrer" target="_blank">PDF Version</a>.)</figcaption></figure>
<p>As might be expected, London is a dark and sinister nexus of paranormal activity. Hauntings, as might be expected from their overall frequency, dominate the majority of the British Isles. Moving north, particularly as we reach the Scottish Highlands, cryptozoological sightings begin to challenge hauntings as the most common supernatural event. We can also see significant cryptozoology in the Hebrides, Orkney, and Shetland &#8212; the archipelagos that surround the Scottish mainland.</p>
<p>Both Wales, Ireland, and Cornwall are significantly less densely haunted in the Paranormal Database, with the majority of sightings falling in England.</p>
<p>This overall view, however, combines a number of very different phenomena. Where, for example, are we most likely to receive a visitation from a restless spectre as opposed to being pursued by a savage and unnatural beast?</p>
<p>By breaking down the sightings into different types, and plotting a heatmap of event density over each, we can identify the regions in which different manifestations cluster.</p>
<figure id="attachment_292" aria-describedby="caption-attachment-292" style="width: 1024px" class="wp-caption aligncenter"><a href="http://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density.png"><img loading="lazy" decoding="async" data-attachment-id="292" data-permalink="https://www.weirddatascience.net/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/paranormal-density/" data-orig-file="https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density.png" data-orig-size="1920,1080" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="paranormal-density" data-image-description="" data-image-caption="&lt;p&gt;Density plot of paranormal manifestations in the British Isles&lt;/p&gt;
" data-large-file="https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-1024x576.png" src="http://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-1024x576.png" class="size-large wp-image-292" width="1024" height="576" alt="" srcset="https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-1024x576.png 1024w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-640x360.png 640w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-300x169.png 300w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-768x432.png 768w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density-64x36.png 64w, https://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption id="caption-attachment-292" class="wp-caption-text">Density plot of paranormal manifestations in the British Isles. (<a href="http://www.weirddatascience.net/wp-content/uploads/2018/04/paranormal-density.pdf" rel="noopener noreferrer" target="_blank">PDF Version</a>.)</figcaption></figure>
<p>This view highlights several points of interest.</p>
<p>Firstly, London&#8217;s preeminent position is not for all forms of paranormal activity. Hauntings are extremely dense in London, however the rest of England is also well-populated. As might be expected from the first diagram, the less population-dense regions further north have produced fewer sad echoes of mortality. Despite its general reputation Edinburgh, while noticeably haunted, cannot compare with many regions of England.</p>
<p>Cryptozoologically, however, London is far from dominant. Whilst unknown beings may lurk in the foetid sewers of the capital, they clearly prefer the wide open spaces &#8212; both the Norfolk and Suffolk Broads are rife with cryptids, as are the Hebrides, Orkney, and Shetland that were noticeable earlier. Finally, visitors to Cornwall will pass through areas of increasing <a href="https://en.wikipedia.org/wiki/Beast_of_Bodmin_Moor" rel="noopener noreferrer" target="_blank">monstrous activity</a>.</p>
<p>UFO&#8217;s also appear to be attracted to East Anglia most strongly, and are otherwise most common in the large population centres of England. Less obviously, there is a noticeable density of UFO activity on the Pembrokeshire Coast, in the south-west of Wales.</p>
<p>Monsters, which in this classification includes werewolves, vampires, and dragons, produce a surprising cluster in North Wales, around Snowdonia. The most significant monstrous sightings, however, appear to be in Exmoor; again on the south-western tip of the British Isles.</p>
<p>The final categories of manifestation include legends, fairies, and a catch-all category of &#8216;other manifestations&#8217; that include mysterious orbs, talking trees, bleeding stones, and the supernatural impressions left by the work of <a href="https://en.wikipedia.org/wiki/John_Dee" rel="noopener noreferrer" target="_blank">John Dee</a>. As might be expected, this last category is more uniformly distributed across the country, matching high-density population areas. There is, however, another notable cluster in Cornwall for this category.</p>
<p>In conclusion, then, the British Isles are teeming with paranormal activity. Entities from beyond the grave lie close at all times, with twisted monstrosities roaming the wild spaces. UFOs descend from the night sky to terrorise the coastal regions.</p>
<p>From this analysis, ghost hunters should concentrate on London for the best chance of a sighting, although almost any of the large centres of population provide a reasonable chance of spectral apparitions. Cryptid researchers should concentrate in East Anglia or head north to the islands beyond Scotland. Those seeking contact with extraterrestrials should focus particularly on the east coast of Suffolk, or travel to the south-west of Wales. Paranormal investigators whose interests lie in legends or monsters, or less specific strange entities, would be well-advised to visit Cornwall.</p>
<p>Code for the plotting elements of this analyis are given below, following on from the scraping and parsing code in our <a href="http://www.weirddatascience.net/index.php/2018/03/17/paranormal-manifestations-in-the-british-isles/" rel="noopener noreferrer" target="_blank">previous post</a>. The geolocation step required a more significant effort, and will be the focus of a future code-based post.</p>
<p>You can keep up to date with our latest paranormal data mining on Twitter at <a href="https://twitter.com/weirddatasci" rel="noopener noreferrer" target="_blank">@WeirdDataSci</a>.</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show analysis code</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
<p><strong>Data:</strong></p>
<ul>
<li>The Paranormal Database: <a href="http://www.paranormaldatabase.com">http://www.paranormaldatabase.com</a></li>
</ul>
<p><strong>Other:</strong></p>
<ul>
<li>JSL Ancient font: <a href="http://www.1001fonts.com/jsl-ancient-font.html">http://www.1001fonts.com/jsl-ancient-font.html</a></li>
<li>Cowplot: <a href="https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html">https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html</a></li>
</ul>
<p><strong>Combined Plot Code:</strong></p>
[code language=&#8221;r&#8221;]
library(spatstat)</p>
<p>library(rgdal)<br />
library(maptools)</p>
<p>library(tidyverse)<br />
library(magrittr)<br />
library(ggplot2)<br />
library(ggthemes)<br />
library(raster)<br />
library(viridis)<br />
library(scales)</p>
<p>library(sf) </p>
<p>library(showtext)</p>
<p>library(grid)</p>
<p>library(cowplot)<br />
library(magick)</p>
<p># Function to combine certain paranormal report types into broader categories<br />
combine_paranormal_types &lt;- function( type ) {</p>
<p>	# levels( paranormal_tbl$type )<br />
	# [1] &quot;Alien Big Cat&quot;                &quot;Crisis Manifestation&quot;<br />
	# [3] &quot;Cryptozoology&quot;                &quot;Curse&quot;<br />
	# [5] &quot;Dragon&quot;                       &quot;Environmental Manifestation&quot;<br />
	# [7] &quot;Experimental Manifestation&quot;   &quot;Fairy&quot;<br />
	# [9] &quot;Haunting Manifestation&quot;       &quot;Legend&quot;<br />
	# [11] &quot;Manifestation of the Living&quot;  &quot;Other&quot;<br />
	# [13] &quot;Poltergeist&quot;                  &quot;Post-Mortem Manifestation&quot;<br />
	# [15] &quot;Shuck&quot;                        &quot;Spontaneous Human Combustion&quot;<br />
	# [17] &quot;UFO&quot;                          &quot;Unknown Ghost Type&quot;<br />
	# [19] &quot;Vampire&quot;                      &quot;Werewolf&quot;                   </p>
<p>	# Simple lookup<br />
	case_when(<br />
				 type %in% c(&quot;Alien Big Cat&quot;, &quot;Cryptozoology&quot;, &quot;Shuck&quot;) ~ &quot;Cryptozoology&quot;,<br />
				 type %in% c(&quot;Dragon&quot;, &quot;Vampire&quot;, &quot;Werewolf&quot; ) ~ &quot;Monster&quot;,<br />
				 type %in% c(&quot;Crisis Manifestation&quot;, &quot;Environmental Manifestation&quot;, &quot;Experimental Manifestation&quot;, &quot;Haunting Manifestation&quot;, &quot;Manifestation of the Living&quot;, &quot;Poltergeist&quot;, &quot;Post-Mortem Manifestation&quot;, &quot;Unknown Ghost Type&quot;) ~ &quot;Haunting&quot;,<br />
				 type %in% c(&quot;Legend&quot;, &quot;Fairy&quot;, &quot;Curse&quot;) ~ &quot;Legend&quot;,<br />
				 type %in% c(&quot;Spontaneous Human Combustion&quot;, &quot;Other&quot;) ~ &quot;Other&quot;,<br />
				 type %in% c(&quot;UFO&quot;) ~ &quot;UFO&quot;<br />
				 )</p>
<p>}</p>
<p># Load font<br />
font_add( &quot;mapfont&quot;, &quot;/usr/share/fonts/TTF/weird/JANCIENT.TTF&quot; )<br />
showtext_auto()</p>
<p># Read world shapefile data and tranform to an appropriate projection.<br />
# Limit to the UK, Ireland, and the Isle of Man<br />
world &lt;- readOGR( dsn=&#8217;data/ne/10m_cultural&#8217;, layer=&#8217;ne_10m_admin_0_countries&#8217; )<br />
world_subset &lt;- world[ world$iso_a2 %in% c(&quot;GB&quot;,&quot;IE&quot;,&quot;IM&quot;), ]
world_subset &lt;- spTransform(world_subset,CRS(&quot;+init=epsg:4326&quot;))<br />
world_df &lt;- fortify( world_subset )</p>
<p># Read paranormal database<br />
paranormal_tbl &lt;- as.tibble( read.csv( file=&quot;data/paranormal_database.csv&quot; ) )</p>
<p># Convert the paranormal dataframe to a spatial dataframe that contains<br />
# explicit longitude and latitude projected appropriately for plotting.<br />
coordinates( paranormal_tbl ) &lt;- ~lng+lat<br />
proj4string( paranormal_tbl )&lt;-CRS(&quot;+init=epsg:4326&quot;)<br />
paranormal_tbl &lt;- spTransform(paranormal_tbl,CRS(proj4string(paranormal_tbl)))</p>
<p># Restrict paranormal_tbl to those points in the polygons defined by world_subset<br />
paranormal_tbl_rows &lt;- paranormal_tbl %&gt;%<br />
	over( world_subset ) %&gt;%<br />
	is.na() %&gt;%<br />
	not() %&gt;%<br />
	rowSums() %&gt;%<br />
	`!=`(0) %&gt;%<br />
	which</p>
<p>paranormal_tbl &lt;- as.tibble( paranormal_tbl[ paranormal_tbl_rows, ] )</p>
<p>paranormal_tbl$combined_type &lt;- paranormal_tbl$type %&gt;%<br />
	map( combine_paranormal_types ) %&gt;%<br />
	unlist</p>
<p># Show the map<br />
gp &lt;- ggplot() + </p>
<p>	geom_map( data = world_df, aes( map_id=id ), colour = &quot;#3c3f4a&quot;, fill = &quot;transparent&quot;, size = 0.5, map = world_df )</p>
<p># Display each sighting as geom_point. Use a level of transparency to highlight<br />
# more common areas. (On the 20180401 dataset, this reports that 16035 out of<br />
# the original 19387 points lie in the appropriate area. Several are geolocated<br />
# outside of the UK &#8212; the geolocation should be run again with better bounds<br />
# checking and region preference.)<br />
gp &lt;- gp + geom_point(data=paranormal_tbl, aes(x=lng, y=lat, colour=combined_type ), size=0.5, shape=17, alpha=0.9) +<br />
	expand_limits(x = world_df$long, y = world_df$lat)  </p>
<p>gp &lt;- gp +	</p>
<p>	# Theming<br />
	theme_map() +<br />
	theme(<br />
			plot.background = element_rect(fill = &quot;transparent&quot;, colour = &quot;transparent&quot;),<br />
			panel.border = element_blank(),<br />
			plot.title = element_text( size=24, colour=&quot;#3c3f4a&quot;, family=&quot;mapfont&quot; ),<br />
			text = element_text( size=14, color=&quot;#3c3f4a&quot;, family=&quot;mapfont&quot; ),<br />
			) +</p>
<p>	theme(<br />
			legend.background = element_rect( colour =&quot;transparent&quot;, fill = &quot;transparent&quot; ),<br />
			legend.key = element_rect(fill = &quot;transparent&quot;, colour=&quot;transparent&quot;),<br />
			legend.position = &quot;left&quot;,<br />
			legend.justification = c(0,0)<br />
			) +</p>
<p>	guides( fill = guide_colourbar( title.position=&quot;top&quot;, direction=&quot;vertical&quot;, barwidth=32, nrow=1 ) ) +<br />
	guides(colour = guide_legend(override.aes = list(size=2)) ) +<br />
	scale_colour_manual(<br />
		values = c(&quot;#00EA38&quot;,&quot;#417CCC&quot;,&quot;#B79F00&quot;,&quot;#F564E3&quot;,&quot;#00BFC4&quot;,&quot;#F8766D&quot;),<br />
		breaks = c(&quot;Haunting&quot;, &quot;Cryptozoology&quot;, &quot;Monster&quot;, &quot;Legend&quot;, &quot;UFO&quot;, &quot;Other&quot; ),<br />
		name = &quot;Manifestation&quot; ) +<br />
	coord_fixed( ratio=1.2 )</p>
<p># Cowplot trick for ggtitle<br />
title &lt;- ggdraw() +<br />
	draw_label(&quot;Paranormal Manifestations in the British Isles&quot;, fontfamily=&quot;mapfont&quot;, colour = &quot;#3c3f4a&quot;, size=24, hjust=0, vjust=1, x=0.02, y=0.88) +<br />
	draw_label(&quot;http://www.weirddatascience.net | @WeirdDataSci&quot;, fontfamily=&quot;mapfont&quot;, colour = &quot;#3c3f4a&quot;, size=14, hjust=0, vjust=1, x=0.02, y=0.40)</p>
<p>data_label &lt;- ggdraw() +<br />
	draw_label(&quot;Data from: http://www.paranormaldatabase.com&quot;, fontfamily=&quot;mapfont&quot;, colour = &quot;#3c3f4a&quot;, size=12, hjust=1, x=0.98 ) </p>
<p>paranormal_legend &lt;- get_legend(gp)</p>
<p># Remove legend from internal plot<br />
gp &lt;- gp + theme(legend.position=&#8217;none&#8217;)</p>
<p>tgp &lt;- plot_grid(title, gp, data_label, ncol=1, rel_heights=c(0.1, 1, 0.1)) </p>
<p>vellum_plot &lt;- ggdraw() +<br />
	draw_image(&quot;img/vellum.jpg&quot;, scale=1.4 ) +<br />
	draw_plot(tgp) +<br />
	draw_plot( paranormal_legend, 0.02, 0.03 )</p>
<p>save_plot(&quot;output/paranormal.pdf&quot;,<br />
			vellum_plot,<br />
			base_width = 16,<br />
			base_height = 9,<br />
			base_aspect_ratio = 1.78 )<br />
[/code]
<p><strong>Per-Manifestation Density Plot Code:</strong></p>
[code language=&#8221;r&#8221;]
library(spatstat)</p>
<p>library(rgdal)<br />
library(maptools)</p>
<p>library(tidyverse)<br />
library(magrittr)<br />
library(ggplot2)<br />
library(ggthemes)<br />
library(raster)<br />
library(viridis)<br />
library(scales)</p>
<p>library(sf) </p>
<p>library(showtext)</p>
<p>library(grid)</p>
<p>library(cowplot)<br />
library(magick)</p>
<p># Function to combine certain paranormal report types into broader categories<br />
combine_paranormal_types &lt;- function( type ) {</p>
<p>	# levels( paranormal_tbl$type )<br />
	# [1] &quot;Alien Big Cat&quot;                &quot;Crisis Manifestation&quot;<br />
	# [3] &quot;Cryptozoology&quot;                &quot;Curse&quot;<br />
	# [5] &quot;Dragon&quot;                       &quot;Environmental Manifestation&quot;<br />
	# [7] &quot;Experimental Manifestation&quot;   &quot;Fairy&quot;<br />
	# [9] &quot;Haunting Manifestation&quot;       &quot;Legend&quot;<br />
	# [11] &quot;Manifestation of the Living&quot;  &quot;Other&quot;<br />
	# [13] &quot;Poltergeist&quot;                  &quot;Post-Mortem Manifestation&quot;<br />
	# [15] &quot;Shuck&quot;                        &quot;Spontaneous Human Combustion&quot;<br />
	# [17] &quot;UFO&quot;                          &quot;Unknown Ghost Type&quot;<br />
	# [19] &quot;Vampire&quot;                      &quot;Werewolf&quot;                   </p>
<p>	# Simple lookup<br />
	case_when(<br />
				 type %in% c(&quot;Alien Big Cat&quot;, &quot;Cryptozoology&quot;, &quot;Shuck&quot;) ~ &quot;Cryptozoology&quot;,<br />
				 type %in% c(&quot;Dragon&quot;, &quot;Vampire&quot;, &quot;Werewolf&quot; ) ~ &quot;Monster&quot;,<br />
				 type %in% c(&quot;Crisis Manifestation&quot;, &quot;Environmental Manifestation&quot;, &quot;Experimental Manifestation&quot;, &quot;Haunting Manifestation&quot;, &quot;Manifestation of the Living&quot;, &quot;Poltergeist&quot;, &quot;Post-Mortem Manifestation&quot;, &quot;Unknown Ghost Type&quot;) ~ &quot;Haunting&quot;,<br />
				 type %in% c(&quot;Legend&quot;, &quot;Fairy&quot;, &quot;Curse&quot;) ~ &quot;Legend&quot;,<br />
				 type %in% c(&quot;Spontaneous Human Combustion&quot;, &quot;Other&quot;) ~ &quot;Other Manifestation&quot;,<br />
				 type %in% c(&quot;UFO&quot;) ~ &quot;UFO&quot;<br />
				 )</p>
<p>}</p>
<p># Load font<br />
font_add( &quot;mapfont&quot;, &quot;/usr/share/fonts/TTF/weird/JANCIENT.TTF&quot; )<br />
showtext_auto()</p>
<p># Read world shapefile data and tranform to an appropriate projection.<br />
# Limit to the UK, Ireland, and the Isle of Man<br />
world &lt;- readOGR( dsn=&#8217;data/ne/10m_cultural&#8217;, layer=&#8217;ne_10m_admin_0_countries&#8217; )<br />
world_subset &lt;- world[ world$iso_a2 %in% c(&quot;GB&quot;,&quot;IE&quot;, &quot;IM&quot;), ]
world_subset &lt;- spTransform(world_subset,CRS(&quot;+init=epsg:4326&quot;))<br />
world_df &lt;- fortify( world_subset )</p>
<p># Read UK Major Cities datafile<br />
#cities &lt;- readOGR( dsn=&#8217;data/ons_uk_cities&#8217;, layer=&#8217;Major_Towns_and_Cities_December_2015_Boundaries&#8217; )<br />
#cities &lt;- spTransform(cities,CRS(&quot;+init=epsg:4326&quot;))<br />
#cities_fortified &lt;- fortify( cities )<br />
#cities_centroids_tbl &lt;- as.tibble( coordinates( cities ) )<br />
#cities_tbl &lt;- as.tibble( cbind( cities@data$tcity15nm, cities_centroids_tbl ))<br />
#colnames(cities_tbl) &lt;- c( &quot;city&quot;, &quot;lng&quot;, &quot;lat&quot; )</p>
<p># As the polygons are more confusing than useful, instead label centroids</p>
<p># Read paranormal database<br />
paranormal_tbl &lt;- as.tibble( read.csv( file=&quot;data/paranormal_database.csv&quot; ) )</p>
<p>paranormal_tbl$combined_type &lt;- paranormal_tbl$type %&gt;%<br />
	map( combine_paranormal_types ) %&gt;%<br />
	unlist</p>
<p># Convert the paranormal dataframe to a spatial dataframe that contains<br />
# explicit longitude and latitude projected appropriately for plotting.<br />
coordinates( paranormal_tbl ) &lt;- ~lng+lat<br />
proj4string( paranormal_tbl )&lt;-CRS(&quot;+init=epsg:4326&quot;)<br />
paranormal_tbl_spatial &lt;- spTransform(paranormal_tbl,CRS(proj4string(paranormal_tbl)))</p>
<p># Restrict paranormal_tbl to those points in the polygons defined by world_subset<br />
paranormal_tbl_rows &lt;- paranormal_tbl_spatial %&gt;%<br />
	over( world_subset ) %&gt;%<br />
	is.na() %&gt;%<br />
	not() %&gt;%<br />
	rowSums() %&gt;%<br />
	`!=`(0) %&gt;%<br />
	which</p>
<p>#paranormal_tbl &lt;- as.tibble( paranormal_tbl_spatial[ paranormal_tbl_rows, ] )</p>
<p># Create window for spatial analysis<br />
paranormal_owin &lt;- as.owin.SpatialPolygons(world_subset)</p>
<p># Function to plot density of a specific manifestation type.<br />
# plot_resolution is for the density raster, and is mainly used for quick prototyping of the output.<br />
density_plot &lt;- function( paranormal_type, plot_resolution = 1024 ) {</p>
<p>	cat( paste0( &quot;Plotting density: &quot;, paranormal_type, &quot;&#8230; &quot; ) )</p>
<p>	paranormal_tbl_spatial &lt;- paranormal_tbl_spatial[ which( paranormal_tbl_spatial$combined_type == paranormal_type ), ]
<p>	paranormal_ppp &lt;-<br />
		ppp( 	x=coordinates(paranormal_tbl_spatial)[,1],<br />
			 y=coordinates(paranormal_tbl_spatial)[,2],<br />
			 window = paranormal_owin )</p>
<p>	# This discards &#8216;illegal&#8217; points outside of the window<br />
	paranormal_ppp &lt;- as.ppp(paranormal_ppp)</p>
<p>	paranormal_density &lt;- density( paranormal_ppp, diggle=T, sigma=0.4, dimyx=c(plot_resolution,plot_resolution) )</p>
<p>	# Make density image object usable by ggplot as a raster<br />
	paranormal_density_raster &lt;- raster( paranormal_density )<br />
	raster_tbl &lt;- as.tibble( rasterToPoints( paranormal_density_raster ) )</p>
<p>	# Show the map<br />
	gp &lt;- ggplot() + </p>
<p>		geom_map( data = world_df, aes( map_id=id ), colour = &quot;#3c3f4a&quot;, fill = &quot;transparent&quot;, size = 0.8, map = world_df ) +</p>
<p>		# Add density of sightings as raster.<br />
		geom_raster( data = raster_tbl, alpha=0.8, aes( x=x, y=y, fill=layer), show.legend=TRUE ) +<br />
		scale_fill_viridis( option=&quot;magma&quot;, direction = -1, name=&quot;Density&quot; ) </p>
<p>	gp &lt;- gp +	</p>
<p>		# Theming<br />
		theme_map() + </p>
<p>		theme(<br />
				plot.background = element_rect(fill = &quot;transparent&quot;, colour = &quot;transparent&quot;),<br />
				panel.border = element_blank(),<br />
				plot.title = element_text( size=12, colour=&quot;#3c3f4a&quot;, family=&quot;mapfont&quot; ),<br />
				text = element_text( size=12, color=&quot;#3c3f4a&quot;, family=&quot;mapfont&quot; ),<br />
				) +</p>
<p>		theme(<br />
				legend.background = element_rect( colour =&quot;transparent&quot;, fill = &quot;transparent&quot; ),<br />
				legend.key = element_rect(fill = &quot;transparent&quot;, colour=&quot;transparent&quot;),<br />
				legend.position = c(0,0),<br />
				legend.justification = c(0,0)<br />
		) +</p>
<p>		guides( fill = guide_colourbar( title.position=&quot;top&quot;, direction=&quot;horizontal&quot;, barwidth=6, barheight=0.4 ) ) +</p>
<p>                # Fix the ratio of the plot to avoid distorting the UK<br />
		coord_fixed( ratio=1.2 )</p>
<p>	cat(&quot;done.\n&quot; )<br />
	return(gp)<br />
}</p>
<p># Calculate densities for each phenomenon<br />
phenomena &lt;- unique( paranormal_tbl$combined_type )</p>
<p>gp_list &lt;- phenomena %&gt;%<br />
	map( density_plot, 1024 )</p>
<p># Plot as a grid with cowplot<br />
theme_set(theme_cowplot(font_size=4, font_family = &quot;mapfont&quot; ) )<br />
gp &lt;- plot_grid( plotlist=gp_list,<br />
			labels = phenomena,<br />
			label_colour = &quot;#3c3f4a&quot; )</p>
<p># Cowplot trick for ggtitle<br />
title &lt;- ggdraw() +<br />
	draw_label(&quot;Density of Paranormal Manifestations in the British Isles&quot;, fontfamily=&quot;mapfont&quot;, colour = &quot;#3c3f4a&quot;, size=24, hjust=0, vjust=1, x=0.02, y=0.88) +<br />
	draw_label(&quot;http://www.weirddatascience.net | @WeirdDataSci&quot;, fontfamily=&quot;mapfont&quot;, colour = &quot;#3c3f4a&quot;, size=14, hjust=0, vjust=1, x=0.02, y=0.40)</p>
<p>data_label &lt;- ggdraw() +<br />
	draw_label(&quot;Data from: http://www.paranormaldatabase.com&quot;, fontfamily=&quot;mapfont&quot;, colour = &quot;#3c3f4a&quot;, size=12, hjust=1, x=0.98 )</p>
<p>tgp &lt;- plot_grid(title, gp, data_label, ncol=1, rel_heights=c(0.1, 1, 0.1)) </p>
<p>vellum_plot &lt;- ggdraw() +<br />
	draw_image(&quot;img/vellum.jpg&quot;, scale=1.4 ) +<br />
	draw_plot(tgp)</p>
<p>save_plot(&quot;output/paranormal-density.pdf&quot;,<br />
				vellum_plot,<br />
				base_width = 16,<br />
				base_height = 9,<br />
			        base_aspect_ratio = 1.78 )<br />
[/code]
</div></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2018/04/10/mapping-paranormal-manifestations-in-the-british-isles/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">284</post-id>	</item>
		<item>
		<title>Are UFOs more commonly seen near US military bases?</title>
		<link>https://www.weirddatascience.net/2018/02/27/are-ufos-more-commonly-seen-near-us-military-bases/</link>
					<comments>https://www.weirddatascience.net/2018/02/27/are-ufos-more-commonly-seen-near-us-military-bases/#respond</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Tue, 27 Feb 2018 21:30:38 +0000</pubDate>
				<category><![CDATA[maps]]></category>
		<category><![CDATA[spatial analysis]]></category>
		<category><![CDATA[ufo]]></category>
		<guid isPermaLink="false">http://www.weirddatascience.net/blog/?p=174</guid>

					<description><![CDATA[<div class="mh-excerpt">What do they know? Since the Roswell Incident in 1947, UFO&#8217;s have been associated with secretive military installations where mysterious craft dart across the night sky. Skeptics might hold that many UFO sightings, far from being extraterrestrial visitors, are better explained as experimental or conventional military craft. Does <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2018/02/27/are-ufos-more-commonly-seen-near-us-military-bases/" title="Are UFOs more commonly seen near US military bases?">[...]</a></div>]]></description>
										<content:encoded><![CDATA[<p>What do they know?</p>
<p>Since the Roswell Incident in 1947, UFO&#8217;s have been associated with secretive military installations where mysterious craft dart across the night sky. Skeptics might hold that many UFO sightings, far from being extraterrestrial visitors, are better explained as experimental or conventional military craft. Does this association hold, though, in light of the wealth of UFO sightings collated by <a href="http://www.nuforc.org/" target="_blank" rel="noopener">NUFORC</a>? Are UFO&#8217;s more likely to be seen when in close proximity to a US airforce base?</p>
<figure id="attachment_176" aria-describedby="caption-attachment-176" style="width: 1024px" class="wp-caption aligncenter"><a href="http://www.weirddatascience.net/wp-content/uploads/2018/02/base-density.png"><img loading="lazy" decoding="async" data-attachment-id="176" data-permalink="https://www.weirddatascience.net/2018/02/27/are-ufos-more-commonly-seen-near-us-military-bases/base-density/" data-orig-file="https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density.png" data-orig-size="1920,1080" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ufo-density-us-airforce" data-image-description="&lt;p&gt;Density plot of US-based UFO sightings plotted against locations of US airforce installations.&lt;/p&gt;
" data-image-caption="&lt;p&gt;UFO Sightings Density against US Airforce Installations&lt;/p&gt;
" data-large-file="https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-1024x576.png" src="http://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-1024x576.png" class="size-large wp-image-176" width="1024" height="576" alt="" srcset="https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-1024x576.png 1024w, https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-640x360.png 640w, https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-300x169.png 300w, https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-768x432.png 768w, https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-64x36.png 64w, https://www.weirddatascience.net/wp-content/uploads/2018/02/base-density.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption id="caption-attachment-176" class="wp-caption-text">UFO Sightings Density against US Airforce Installations. (<a href="http://www.weirddatascience.net/wp-content/uploads/2018/02/base-density.pdf">PDF</a> | <a href="http://www.weirddatascience.net/wp-content/uploads/2018/02/base-density-print.pdf">Print-Friendly PDF</a>)</figcaption></figure>
<p>As a first step to approaching this question, we can rely on the reported NUFORC data of UFO sightings, and the US government&#8217;s <a href="https://catalog.data.gov/dataset/military-bases-national" target="_blank" rel="noopener">conveniently thorough dataset of military installations</a>.</p>
<p>Before performing a more robust statistical analysis, we can quickly combine these two datasets to see if any obvious visual patterns emerge. As always, visual analysis comes with the strong caveat that apparent patterns must be backed up with real statistics. Beware eyeballs.</p>
<p>We will focus only on sightings in the United States. Whilst the NUFORC dataset is creditably global the reports are overwhelmingly from the US, reflecting the fact that NUFORC is largely a US-based endeavour and is much less likely to receive reports from elsewhere in the world.</p>
<p>For this quick visual exploration, we will produce a density plot, or heatmap, of UFO sightings going back to 1906, using the excellent <a href="http://spatstat.org/" target="_blank" rel="noopener"><code>spatstat</code></a> R package, as described in <a href="https://www.crcpress.com/Spatial-Point-Patterns-Methodology-and-Applications-with-R/Baddeley-Rubak-Turner/p/book/9781482210200" target="_blank" rel="noopener"> Baddeley, Rubak, and Turner&#8217;s <i>Spatial Point Patterns: Methodology and Applications with R</i></a>.</p>
<p>The first task is to transform the data appropriately from the weirdly <a href="http://www.hplovecraft.com/writings/texts/fiction/cc.aspx">non-Euclidean geometry</a> of longitude and latitude to a geometry that allows for consistent measurement of distance between points. Following this we can run a standard <a href="https://en.wikipedia.org/wiki/Kernel_density_estimation" target="_blank" rel="noopener">kernel density estimate</a> of sightings that, briefly, produces a probability distribution over the analysed space that estimates the likelihood of a UFO sighting at each point.</p>
<p>The output of spatstat&#8217;s density function is a pixel image, appropriate for plotting in R&#8217;s base graphics. As fanatical devotees of the cult of <a href="https://ggplot2.tidyverse.org/" target="_blank" rel="noopener"><code>ggplot2</code></a>, however, we instead convert this image to a raster suitable for plotting with ggplot&#8217;s <code>geom_raster</code>.</p>
<p>With the density plot calculated we can load the US military base data and perform a similar transform from longitude and latitude to Euclidean space. We then restrict the data to each active US Airforce installation, and plot the resulting set of points over the underlying density plot of UFO sightings. Being worthy of special attention, we highlight the location of Area 51.</p>
<p>At a first glance, there do seem to be correlations with particular clusters of airforce installations and UFO sightings. It is immediately obvious that sightings are much more common on the coasts of the US than in the centre of the continent, although the relatively sparse population density might go some way towards explaining this phenomenon.</p>
<p>The next step in this analysis, which we will carry out in a future post, will be to conduct a formal analysis of the correlation between the sightings density and the distance from airforce bases. From our initial observations, however, dark suspicions have already been raised.</p>
<p>You can keep up to date with our latest tearings of the mathematical veil on Twitter at <a href="https://twitter.com/weirddatasci" rel="noopener" target="_blank">@WeirdDataSci</a>.</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show analysis code</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
<p><strong>Data:</strong></p>
<ul>
<li>NUFORC UFO Sightings Data compiled by Timothy Renner: <a href="https://data.world/timothyrenner/ufo-sightings">https://data.world/timothyrenner/ufo-sightings</a></li>
<li>Natural Earth Small-Scale (1:100m) Physical Geographic Data: <a href="http://www.naturalearthdata.com/">http://www.naturalearthdata.com</a></li>
<li>US Data.Gov Military Bases (National): <a href="https://catalog.data.gov/dataset/military-bases-national">https://catalog.data.gov/dataset/military-bases-national</a></li>
</ul>
<p><strong>Other:</strong></p>
<ul>
<li>Tox Typewriter font: <a href="https://www.dafont.com/tox-typewriter.font">https://www.dafont.com/tox-typewriter.font</a>
</ul>
<p><strong>Code:</strong><br />
[code language=&#8221;r&#8221;]
library(spatstat)</p>
<p>library(rgdal)<br />
library(maptools)</p>
<p>library(tidyverse)<br />
library(ggplot2)<br />
library(ggthemes)<br />
library(raster)<br />
library(viridis)<br />
library(scales)</p>
<p>library(showtext)</p>
<p># Load font<br />
font.add( &amp;quot;mapfont&amp;quot;, &amp;quot;font/Tox Typewriter.ttf&amp;quot;)<br />
showtext_auto()</p>
<p># Read world shapefile data and tranform to an appropriate projection<br />
world &amp;lt;- readOGR( dsn=&#8217;data/ne/110m_cultural&#8217;, layer=&#8217;ne_110m_admin_0_countries&#8217; )<br />
world.subset &amp;lt;- world[ world$continent %in% c(&amp;quot;North America&amp;quot;), ]
world.subset &amp;lt;- spTransform(world.subset,CRS(&amp;quot;+init=epsg:4326&amp;quot;))</p>
<p># Fortify world data for plotting<br />
world.df &amp;lt;- fortify( world.subset )</p>
<p># Get list of unique countries for processing.<br />
countries.all &amp;lt;- data.frame( unique(world.df$id)[-1])<br />
colnames( countries.all ) &amp;lt;- c(&amp;quot;country&amp;quot;)</p>
<p># Get US military base data<br />
us.mil &amp;lt;- readOGR( dsn=&#8217;data/usmil&#8217;, layer=&#8217;MIRTA_Points&#8217; )<br />
us.mil &amp;lt;- spTransform(us.mil,CRS(&amp;quot;+init=epsg:4326&amp;quot;))</p>
<p># UFO Sightings Data<br />
ufo &amp;lt;- read.csv(&amp;quot;data/scrubbed.csv&amp;quot;, stringsAsFactors=FALSE)</p>
<p># Convert latitude and longitude to numeric, and omit result NA values.<br />
ufo$latitude &amp;lt;- as.numeric(ufo$latitude)<br />
ufo$longitude &amp;lt;- as.numeric(ufo$longitude)<br />
ufo &amp;lt;- na.omit( ufo )</p>
<p># Convert the ufo dataframe to a spatial dataframe that contains explicit longitude and latitude projected appropriately for plotting.<br />
coordinates( ufo ) &amp;lt;- ~longitude+latitude<br />
proj4string( ufo )&amp;lt;-CRS(&amp;quot;+init=epsg:4326&amp;quot;)<br />
ufo &amp;lt;- spTransform(ufo,CRS(proj4string(ufo)))</p>
<p># Create window for spatial analysis<br />
ufo.owin &amp;lt;- as.owin.SpatialPolygons(world.subset)<br />
ufo.ppp &amp;lt;- ppp( x=coordinates(ufo)[,1], y=coordinates(ufo)[,2], window = ufo.owin, marks = ufo$shape )</p>
<p># This discards &#8216;illegal&#8217; points outside of the window<br />
ufo.ppp &amp;lt;- as.ppp(ufo.ppp)</p>
<p># Highlight Area 51<br />
roswell.coords = cbind(-115.806999, 37.237 )<br />
roswell.sp = SpatialPoints(roswell.coords)</p>
<p>proj4string( roswell.sp )&amp;lt;-CRS(&amp;quot;+proj=longlat&amp;quot;)<br />
roswell.sp &amp;lt;- spTransform(roswell.sp,CRS(&amp;quot;+init=epsg:4326&amp;quot;))<br />
roswell.sp.df &amp;lt;- as.data.frame( coordinates( roswell.sp ) )<br />
roswell.sp.df$text.label &amp;lt;- &#8216;Area 51&#8217;</p>
<p># Get only active US airforce bases.<br />
us.mil.airforce &amp;lt;- us.mil[ us.mil$COMPONENT == &amp;quot;AF Active&amp;quot;, ]
us.mil.ppp &amp;lt;- ppp( x=coordinates(us.mil.airforce)[,1], y=coordinates(us.mil.airforce)[,2], window = ufo.owin )<br />
us.mil.ppp &amp;lt;- as.ppp( us.mil.ppp )<br />
us.mil.sp &amp;lt;- as( us.mil.ppp, &amp;quot;SpatialPoints&amp;quot; )</p>
<p># Calculate density of UFO sightings<br />
ufo.density &amp;lt;- density( ufo.ppp, diggle=T, sigma=1.4, dimyx=c(2048,2048) )</p>
<p># Make density image object usable by ggplot as a raster<br />
ufo.density.raster &amp;lt;- raster(ufo.density)<br />
raster.df &amp;lt;- as.data.frame( rasterToPoints( ufo.density.raster))</p>
<p># Plot<br />
gp &amp;lt;- ggplot() +</p>
<p># Underlying map<br />
geom_map( data = world.df, aes( map_id=id ), colour = &amp;quot;grey20&amp;quot;, size = 0.5, map = world.df, show.legend = FALSE ) +</p>
<p># Theming<br />
theme_map() +<br />
theme(<br />
plot.background = element_rect(fill = &amp;quot;#444444&amp;quot;),<br />
panel.border = element_blank(),<br />
plot.title = element_text( size=24, colour=&amp;quot;#cccccc&amp;quot;, family=&amp;quot;mapfont&amp;quot; ),<br />
text = element_text( size=14, color=&amp;quot;#cccccc&amp;quot;, family=&amp;quot;mapfont&amp;quot; ),<br />
) +</p>
<p>theme(<br />
legend.background = element_rect( colour =&amp;quot;#444444&amp;quot;, fill = &amp;quot;#444444&amp;quot; ),<br />
legend.key = element_rect(fill = &amp;quot;#ffffff&amp;quot;, colour=&amp;quot;#444444&amp;quot;),<br />
legend.position = c(1,0),<br />
legend.justification = c(1,0)<br />
) +</p>
<p>guides( fill = guide_colourbar( title.position=&amp;quot;top&amp;quot;, direction=&amp;quot;horizontal&amp;quot;, barwidth=16 ) ) +</p>
<p>   # Add density of sightings as raster.<br />
   geom_raster( data = raster.df, alpha=1, aes( x=x, y=y, fill=layer), show.legend=TRUE ) +</p>
<p># Add density of sightings as raster.<br />
geom_raster( data = raster.df, alpha=1, aes( x=x, y=y, fill=layer), show.legend=FALSE) +</p>
<p># Colour using Viridis<br />
scale_fill_viridis( option=&amp;quot;magma&amp;quot; )</p>
<p># Overlay US Airforce locations<br />
dot.size &amp;lt;- 1.2<br />
stroke.size &amp;lt;- 0.4</p>
<p>gp &amp;lt;- gp +<br />
geom_point( data = as.data.frame( coordinates(us.mil.sp) ), aes( x=mx, y=my ), size=dot.size, stroke=stroke.size, shape=21, fill=&amp;quot;#eeeeee&amp;quot;, color=&amp;quot;#222222&amp;quot; ) +</p>
<p># Special case for Area 51<br />
# Due to ggplot only supporting a single colour scale for the entire plot, there&#8217;s some awkwardness here in using &#8216;colour&#8217; rather than &#8216;fill&#8217; for the Area 51 dot and manually adding an outline. This lets us add an easy legend to the map, though, highlighting that location.<br />
geom_point( data = roswell.sp.df, aes( x=coords.x1, y=coords.x2, colour=text.label ), size=1, stroke=0, show.legend=TRUE ) +<br />
geom_point( data = roswell.sp.df, aes( x=coords.x1, y=coords.x2 ), size=1, stroke=stroke.size, shape=21, color=&amp;quot;#222222&amp;quot; ) +<br />
scale_colour_manual(values = c(&amp;quot;red&amp;quot;)) +<br />
theme( legend.title = element_blank(), legend.background = element_rect( fill = &amp;quot;#444444&amp;quot; ), legend.key = element_rect(fill = &amp;quot;#444444&amp;quot;) ) +</p>
<p># Acknowledge data sources<br />
labs( caption = &amp;quot;Data: http://www.nuforc.org | https://catalog.data.gov/dataset/military-bases-national&amp;quot; ) +</p>
<p># Add our title<br />
ggtitle(&amp;quot;Density of UFO Sightings against Active US Airforce Installations&amp;quot;, subtitle=&amp;quot;http://www.weirddatascience.net | @WeirdDataSci&amp;quot;)</p>
<p># Output<br />
ggsave( &amp;quot;output/base-density.pdf&amp;quot;, width=16, height=9 )<br />
[/code]
</div></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2018/02/27/are-ufos-more-commonly-seen-near-us-military-bases/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">174</post-id>	</item>
		<item>
		<title>Unveiling the Global UFO Inquirer</title>
		<link>https://www.weirddatascience.net/2018/02/22/unveiling-the-global-ufo-inquirer/</link>
					<comments>https://www.weirddatascience.net/2018/02/22/unveiling-the-global-ufo-inquirer/#respond</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Thu, 22 Feb 2018 07:52:54 +0000</pubDate>
				<category><![CDATA[interactive]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[ufo]]></category>
		<guid isPermaLink="false">http://www.weirddatascience.net/blog/?p=152</guid>

					<description><![CDATA[<div class="mh-excerpt">Our previous post showed an interactive map of UFO sightings drawn from the NUFORC dataset. Whilst this did allow us to see UFO sightings over time, it remained a relatively crude tool that created a static visualisation for each year. In delving deeper into the NUFORC data, it <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2018/02/22/unveiling-the-global-ufo-inquirer/" title="Unveiling the Global UFO Inquirer">[...]</a></div>]]></description>
										<content:encoded><![CDATA[<p>Our <a href="http://www.weirddatascience.net/index.php/2018/02/18/interactive-map-of-ufo-sightings-by-year/" rel="noopener noreferrer" target="_blank">previous post</a> showed an interactive map of UFO sightings drawn from the <a href="http://www.nuforc.org/" rel="noopener noreferrer" target="_blank">NUFORC</a> dataset. Whilst this did allow us to see UFO sightings over time, it remained a relatively crude tool that created a static visualisation for each year.</p>
<p>In delving deeper into the NUFORC data, it has become useful to create a more interactive tool. As we believe in providing potentially dangerous knowledge to the woefully unprepared mind, the Weird Data Science laboratory trepidatiously unveils the <a href="https://trapezohedron.weirddatascience.net/weirddatascience.net/global-ufo-inquirer" rel="noopener noreferrer" target="_blank">Global UFO Inquirer</a>.</p>
<p><iframe src="https://trapezohedron.weirddatascience.net/weirddatascience.net/global-ufo-inquirer/" 
        style="width: 100%; height: 800px" allowfullscreen="true"><br />
Apologies, it seems that your browser doesn&#8217;t support iframes.<br />
</iframe></p>
<p>You can visit the Global UFO Inquirer directly <a href="https://trapezohedron.weirddatascience.net/weirddatascience.net/global-ufo-inquirer/">here</a>.</p>
<p>This is a <a href="http://leafletjs.com/" rel="noopener noreferrer" target="_blank">Leaflet</a>-based map, built on <a href="https://www.r-project.org/" rel="noopener noreferrer" target="_blank">R</a> and <a href="https://shiny.rstudio.com" rel="noopener noreferrer" target="_blank">Shiny</a>. The map can be explored at will, restricted to any range of dates, with each data point from the NUFORC dataset labelled. Clicking on the icon for a report will unveil the location, date, and details of that report.</p>
<p>This has highlighted that our initial dataset is sadly incomplete. Firstly, NUFORC reports are frequently updated and the dataset we have ends in 2014. Of greater importance, however, is that the dataset to which we have access contains only the summary details of each report, which is restricted to the first line of text. The NUFORC website contains the full details, but these are not currently in our dataset.</p>
<p>We will therefore be developing a scraper to extract the full data from the NUFORC website as it is updated and feed it into the Inquirer. There is existing code floating around the net to carry out part of this task, but more work is needed. As an initial step we will link each report in the Global UFO Inquirer to the full online NUFORC report, but full data in the tool is the ultimate goal.</p>
<p>You can keep up to date with our latest collating of statistical horror on Twitter at <a href="https://twitter.com/weirddatasci" rel="noopener noreferrer" target="_blank">@WeirdDataSci</a>.</p>
<p>Every day, the horror deepens.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2018/02/22/unveiling-the-global-ufo-inquirer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">152</post-id>	</item>
		<item>
		<title>Interactive Map of UFO Sightings by Year</title>
		<link>https://www.weirddatascience.net/2018/02/18/interactive-map-of-ufo-sightings-by-year/</link>
					<comments>https://www.weirddatascience.net/2018/02/18/interactive-map-of-ufo-sightings-by-year/#comments</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Sun, 18 Feb 2018 02:39:44 +0000</pubDate>
				<category><![CDATA[interactive]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[ufo]]></category>
		<guid isPermaLink="false">http://www.weirddatascience.net/blog/?p=128</guid>

					<description><![CDATA[<div class="mh-excerpt">Whilst an overview of a century of UFO sightings reveals a broad overall feature of the data, it is far more useful to be able to see how sightings change over time. The interactive plot below shows all sightings for a given year. We can clearly see that <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2018/02/18/interactive-map-of-ufo-sightings-by-year/" title="Interactive Map of UFO Sightings by Year">[...]</a></div>]]></description>
										<content:encoded><![CDATA[<p>Whilst an overview of a century of UFO sightings reveals a broad overall feature of the data, it is far more useful to be able to see how sightings change over time.</p>
<p>The interactive plot below shows all sightings for a given year. We can clearly see that the number of reported UFO sightings greatly increases from the middle of the 1960s onward.</p>
<p><iframe src="https://trapezohedron.weirddatascience.net/weirddatascience.net/ufo-timeline/" 
        style="width: 100%; height: 800px"><br />
Apologies, it seems that your browser doesn&#8217;t support iframes.<br />
</iframe></p>
<p>You can visit this map directly <a href="https://trapezohedron.weirddatascience.net/weirddatascience.net/ufo-timeline/">here</a>.</p>
<p>You can keep up to date with our latest presentations of the beyond on Twitter at <a href="https://twitter.com/weirddatasci" rel="noopener noreferrer" target="_blank">@WeirdDataSci</a>.</p>
<p>Happy hunting.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2018/02/18/interactive-map-of-ufo-sightings-by-year/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">128</post-id>	</item>
		<item>
		<title>Global Distribution of UFO Sightings 1910-2013</title>
		<link>https://www.weirddatascience.net/2018/02/16/global-distribution-of-ufo-sightings-1910-2013/</link>
					<comments>https://www.weirddatascience.net/2018/02/16/global-distribution-of-ufo-sightings-1910-2013/#respond</comments>
		
		<dc:creator><![CDATA[moth]]></dc:creator>
		<pubDate>Fri, 16 Feb 2018 23:48:45 +0000</pubDate>
				<category><![CDATA[maps]]></category>
		<category><![CDATA[ufo]]></category>
		<guid isPermaLink="false">http://www.weirddatascience.net/blog/?p=74</guid>

					<description><![CDATA[<div class="mh-excerpt">Where are you most likely to see a UFO? More importantly, where are they most likely to see you? Thankfully, the National UFO Reporting Centre (NUFORC) have diligently compiled and curated a dataset of over a century of global UFO sightings. The data has been processed, cleaned, and <a class="mh-excerpt-more" href="https://www.weirddatascience.net/2018/02/16/global-distribution-of-ufo-sightings-1910-2013/" title="Global Distribution of UFO Sightings 1910-2013">[...]</a></div>]]></description>
										<content:encoded><![CDATA[<p>Where are you most likely to see a UFO? More importantly, where are they most likely to see you?</p>
<p>Thankfully, the <a href="http://www.nuforc.org/">National UFO Reporting Centre (NUFORC)</a> have diligently compiled and curated a dataset of over a century of global UFO sightings. The <a href="https://data.world/timothyrenner/ufo-sightings">data</a> has been processed, cleaned, and uploaded by timothyrenner at <a href="https://data.world/">data.world</a>.</p>
<p>The full dataset is extremely detailed, with type of sighting, duration, latitude and longitude, and many other features included; there are many questions to ask of the data. As an initial offering for Weird Data Science, though, we will feed this dataset into R and get a feel for the global distribution of sightings in the dataset. The full code is at the bottom of this post, but here is the outcome:</p>
<p><a href="http://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings.png"><img loading="lazy" decoding="async" data-attachment-id="75" data-permalink="https://www.weirddatascience.net/2018/02/16/global-distribution-of-ufo-sightings-1910-2013/ufo-sightings/" data-orig-file="https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings.png" data-orig-size="2400,1350" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="UFO Sightings 1910-2013" data-image-description="" data-image-caption="" data-large-file="https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings-1024x576.png" src="http://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings.png" alt="" width="2400" height="1350" class="alignnone size-full wp-image-75" srcset="https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings.png 2400w, https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings-640x360.png 640w, https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings-300x169.png 300w, https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings-768x432.png 768w, https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings-1024x576.png 1024w, https://www.weirddatascience.net/wp-content/uploads/2018/02/ufo-sightings-64x36.png 64w" sizes="auto, (max-width: 2400px) 100vw, 2400px" /></a></p>
<p>What can we tell immediately? Firstly, there is a clear preference amongst UFO&#8217;s to descend on the United States, although Europe and in particular the United Kingdom receive their fair share of extraterrestrial visitations. The rest of the world is far from ignored, but our best hope of making contact would definitely seem to be in those two countries.</p>
<p>We will be analysing this dataset in much greater detail in the future. How have these sightings changed over time? Are there patterns to be discovered in when and where UFOs choose to reveal themselves? Are these events predictable? As always, the answers lie in the data.</p>
<p>You can keep up to date with our latest tinkerings with statistical reality on Twitter at <a href="https://twitter.com/weirddatasci" rel="noopener" target="_blank">@WeirdDataSci</a>.</p>
<div class="su-accordion su-u-trim">
<div class="su-spoiler su-spoiler-style-fancy su-spoiler-icon-chevron su-spoiler-closed" data-scroll-offset="0" data-anchor-in-url="no"><div class="su-spoiler-title" tabindex="0" role="button"><span class="su-spoiler-icon"></span>Show analysis code</div><div class="su-spoiler-content su-u-clearfix su-u-trim">
<p><strong>Data:</strong></p>
<ul>
<li>NUFORC UFO Sightings Data compiled by Timothy Renner: <a href="https://data.world/timothyrenner/ufo-sightings">https://data.world/timothyrenner/ufo-sightings</a></li>
<li>Natural Earth Small-Scale (1:100m) Physical Geographic Data: <a href="http://www.naturalearthdata.com/">http://www.naturalearthdata.com/</a></li>
</ul>
<p><strong>Other:</strong></p>
<ul>
<li>Stake Through the Heart BB Regular font: <a href="http://www.blambot.com/font_stth.shtml">http://www.blambot.com/font_stth.shtml</a></li>
</ul>
<p><strong>Code:</strong></p>
[code language=&#8221;r&#8221;]
library(ggplot2)<br />
library(ggthemes)<br />
library(maptools)<br />
library(rgdal)<br />
library(rgeos)<br />
library(showtext)</p>
<p># UFO Sightings Data<br />
ufo &lt;- read.csv(&quot;data/scrubbed.csv&quot;, stringsAsFactors=FALSE)</p>
<p># Read world shapefile data and tranform to an appropriate projection<br />
world &lt;- readOGR( dsn=&#8217;data/ne/110m_cultural&#8217;, layer=&#8217;ne_110m_admin_0_countries&#8217; )<br />
world &lt;- spTransform(world,CRS(&quot;+proj=longlat&quot;))</p>
<p># Fortify world data, using iso_a2 country codes<br />
world.df &lt;- fortify( world, region = &quot;iso_a2&quot; )</p>
<p># Get list of unique countries for processing.<br />
countries.all &lt;- data.frame( unique(world.df$id)[-1])<br />
colnames( countries.all ) &lt;- c(&quot;country&quot;)</p>
<p># Convert latitude and longitude to numeric, and omit result NA values.<br />
ufo$latitude &lt;- as.numeric(ufo$latitude)<br />
ufo$longitude &lt;- as.numeric(ufo$longitude)<br />
ufo &lt;- na.omit( ufo )</p>
<p># Convert the ufo dataframe to a spatial dataframe that contains explicit longitude and latitude projected appropriately for plotting.<br />
coordinates( ufo ) &lt;- ~longitude+latitude<br />
proj4string( ufo )&lt;-CRS(&quot;+proj=longlat&quot;)<br />
ufo &lt;- spTransform(ufo,CRS(proj4string(ufo)))</p>
<p># With the data appropriate projected for display, convert back to a data frame for ggplot2.<br />
ufo&lt;-data.frame(ufo)</p>
<p># Show the map<br />
gp &lt;- ggplot() +<br />
	geom_map( data = countries.all, aes( map_id = country), colour = &quot;grey20&quot;, size = 0.2, map = world.df ) +<br />
	expand_limits(x = world.df$long, y = world.df$lat)  </p>
<p># Display each sighting as geom_point. Use a level of transparency to highlight more common areas.<br />
gp &lt;- gp + geom_point(data=ufo, aes(x=longitude, y=latitude), color=&quot;#0b6788&quot;, size=0.1, alpha=0.1)</p>
<p># Load font<br />
font.add( &quot;mapfont&quot;, &quot;/usr/share/fonts/TTF/weird/StakeThroughtheHeartBB_reg.otf&quot;)<br />
showtext.auto()</p>
<p># Provide some overall theming of the map<br />
gp &lt;- gp +<br />
	theme_map() +<br />
	theme(<br />
			plot.background = element_rect(fill = &quot;#444444&quot;),<br />
			panel.border = element_blank(),<br />
			text = element_text( size=32, color=&quot;white&quot;, family=&quot;mapfont&quot; ),<br />
			plot.title = element_text( size=48, colour=&quot;white&quot;, family=&quot;mapfont&quot; )<br />
			)</p>
<p>gp &lt;- gp + labs( caption = &quot;Data from: http://www.nuforc.org available at https://data.world/timothyrenner/ufo-sightings&quot; )</p>
<p># Add our title<br />
gp &lt;- gp + ggtitle(&quot;Global Distribution of UFO Sightings 1910-2013&quot;, subtitle=&quot;http://www.weirddatascience.net&quot;)</p>
<p># Save<br />
ggsave(&quot;ufo-sightings.png&quot;, width=8, height=4.5)<br />
[/code]
</div></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.weirddatascience.net/2018/02/16/global-distribution-of-ufo-sightings-1910-2013/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">74</post-id>	</item>
	</channel>
</rss>
