 <?xml-stylesheet type="text/css" href="https://www.esdm.co.uk/Data/style/rss1.css" ?> <?xml-stylesheet type="text/xsl" href="https://www.esdm.co.uk/Data/style/rss1.xsl" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
  <channel>
    <title>The knowledge base blog</title>
    <link>https://www.esdm.co.uk/knowledge</link>
    <description />
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>mojoPortal Blog Module</generator>
    <language>en-GB</language>
    <ttl>120</ttl>
    <atom:link href="https://www.esdm.co.uk/Blog/RSS.aspx?p=138~108~63" rel="self" type="application/rss+xml" />
    <itunes:owner />
    <itunes:explicit>no</itunes:explicit>
    <item>
      <title>Using R with spatial data</title>
      <description><![CDATA[<p>&nbsp;</p> <p>R is a cross platform statistical package which is becoming extremely widely used.&nbsp; It is modular and so there are all sorts of add ins available, including a number of sophisticated tools for spatial analysis some of which run considerably faster than Arc / MapInfo.&nbsp; Organisations are also starting to move to this for spatial analysis as its cheaper but more relevantly doesn’t suffer from the endless version changes that ArcGIS is particular forces on people.</p> <p>R is generally used for a wide range of statistics – but also has the option to generate publication quality graphs (pdfs or images)</p> <h1>Getting started</h1> <p>R can be downloaded here: <a href="http://www.r-project.org/">http://www.r-project.org/</a></p> <p>Its also suggested (on Windows) to use r studio - <a href="http://www.rstudio.com/">http://www.rstudio.com/</a> which gives a more friendly IDE</p> <p>R is a scripted tool – so it can be a steep learning curve but there are endless examples on the web to help get started.</p> <h1>Spatial example using OGR</h1> <p>This syntax is a little obscure – but potentially of considerable use for a wide range of spatial data.&nbsp; Reading from shapefiles (or any other OGR supported datasource is easy / possible)</p> <h2>Read data from SQL server</h2> <p>#download and load rgdal libraries<br>install.packages("rgdal")<br>library(rgdal)</p> <p>#Use ogrinfo to get information about a shape file called stations<br>ogrInfo("C:/ToFile/RNLI/data", "Stations")</p> <p>#List the spatial layers available in a SQL server database<br>#Note you must have the standard OGR tables geometry_columns and spatial_ref_sys present and populated in your database<br>#Some people say you need a DSN as well – not sure you do …<br>ogrListLayers("MSSQL:server=SQL2008;database=CMSI-NE;trusted_connection=yes") </p> <p>#Read a table of polygon objects into a new sitesPoly object<br>#Then plot them on a map<br>#N.B.&nbsp; You can’t have binary data in your table – so if you do create a view or somesuch<br>sitesPoly &lt;- readOGR(dsn='MSSQL:server=SQL2008;database=CMSI-NE;trusted_connection=true', layer='SitesGeom') <br>plot(sitesPoly) </p> <p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_84.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_70.png" width="244" height="171"></a></p> <p>#Select just one record from the layer<br>oneSite = subset(sitesPoly, sitesPoly$MI_PRINX == 420)</p> <p>#Make sure the layer is assigned the correct projection<br>proj4string(oneSite) = CRS("+init=epsg:27700")</p> <p>#Transform the layer to another projection<br>oneSite_latlong = spTransform(oneSite, CRS("+init=epsg:4326"))</p> <p>#Load another library which contains some world boundaries<br>#Load up coast and countries outlines<br>library(rworldmap)<br>data(coastsCoarse)<br>data(countriesLow)</p><pre>&nbsp;</pre>
<p>#plot countries outline limiting extent to Europe<br>plot(countriesLow, xlim = c(-10, 10), ylim = c(45, 60), legend = F)</p>
<p>#Add sites onto existing map setting colours</p>
<p>proj4string(sitesPoly_ll) = CRS("+init=epsg:27700")<br>sitesPoly_ll = spTransform(sitesPoly, CRS("+init=epsg:4326"))<br>plot(sitesPoly_ll, col = "red", border="red", Add=T)</p>
<p>&nbsp;</p>
<h2>Use a different library to do some plotting</h2>
<p>install.packages("maps")<br>install.packages("mapdata")<br>library(maps)<br>library(mapsdata)</p>
<p>#Select polygons making up UK and plot<br>#Then plot a point on top<br>map('worldHires',<br>&nbsp;&nbsp;&nbsp; c('UK', 'Ireland', 'Isle of Man','Isle of Wight','Wales:Anglesey'),<br>&nbsp;&nbsp;&nbsp; xlim=c(-11,3), ylim=c(49,60.9))<br>points(-1.615672,54.977768,col=2,pch=18)</p>
<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_85.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_71.png" width="244" height="170"></a></p><br /><a href='https://www.esdm.co.uk/using-r-with-spatial-data'></a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/using-r-with-spatial-data'>...</a>]]></description>
      <link>https://www.esdm.co.uk/using-r-with-spatial-data</link>
      <author>()</author>
      <comments>https://www.esdm.co.uk/using-r-with-spatial-data</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/using-r-with-spatial-data</guid>
      <pubDate>Sat, 28 Dec 2013 12:53:39 GMT</pubDate>
    </item>
    <item>
      <title>British National Grid in MapInfo</title>
      <description><![CDATA[<p>
	A problem frequently encountered with sharing data between MapInfo and ArcGIS is that the British National Grid projection used by ArcGIS is accurate to 1 mm, whilst the standard projection used by MapInfo is not. This can be an issue, as boundary data that matches Ordnance Survey MasterMap data in MapInfo will appear to be poorly mapped (albeit by a just a few cm) when compared with MasterMap data in ArcGIS.</p>
<p>
	In order to resolve this, MapInfo introduced a 1 mm accuracy projection, which can be found under <em>Projection... </em>when you create a table or save a copy of an existing table. However, this is not a default option, so even when saving a copy of data already in the 1 mm precision projection MapInfo will automatically default to the standard projection. This makes it very easy to accidentally reduce the quality of your data if you forget to actively select the 1 mm precision projection.</p>
<p>
	Fortunately there is a relatively simple way to ensure that MapInfo always defaults to the 1 mm projection:</p>
<ul>
	<li>
		Navigate to the MapInfo folder under program files (e.g. C:\Program Files (x86)\MapInfo\Professional).</li>
	<li>
		Locate the MAPINFOW.PRJ file.<img alt="The MapInfo Choose Projection dialogue, altered so that the British National Grid projection defaults to 1 mm accuracy" src="https://www.esdm.co.uk/Data/Sites/1/media/knowledgebase/gisknowledge/alteredchooseprojectiondialogue.png" style="width: 447px; height: 365px; float: right;" title="Altered MapInfo Choose Projection dialogue" /></li>
	<li>
		Backup the MAPINFOW.PRJ file, in case you make a mistake.</li>
	<li>
		Open the MAPINFOW.PRJ file in a text editor (e.g. notepad).</li>
	<li>
		Search for ‘British’, which will find a section of text that looks like this:</li>
</ul>
<p style="margin-left: 80px;">
	"--- British Coordinate Systems ---"<br />
	"British National Grid\p27700", 8, 79, 7, -2, 49, 0.9996012717, 400000, -100000<br />
	"British National Grid (1 mm accuracy)", 2008, 79, 7, -2, 49,0.9996012717, 400000, -100000, 0, 0, 2000000, 2000000<br />
	"British OSGRS80 Grid", 8, 33, 7, -2, 49, 0.9996012717, 400000, -100000</p>
<ul>
	<li>
		Move the third line of this text up one so that it becomes the second:</li>
</ul>
<p style="margin-left: 80px;">
	"--- British Coordinate Systems ---"<br />
	"British National Grid (1 mm accuracy)", 2008, 79, 7, -2, 49,0.9996012717, 400000, -100000, 0, 0, 2000000, 2000000<br />
	"British National Grid\p27700", 8, 79, 7, -2, 49, 0.9996012717, 400000, -100000<br />
	"British OSGRS80 Grid", 8, 33, 7, -2, 49, 0.9996012717, 400000, -100000</p>
<p>
	This change moves the 1 mm accuracy projection to the top of the <em>Category Members </em>selector under the British Coordinate Systems <em>Category </em>in the <em>Choose Projection </em>dialogue box of MapInfo, automatically making it the default option (as shown in the picture). If you want to use the standard projection then you just need to select 'British National Grid [EPSG: 27700]' from the dialogue instead.</p>
<p>
	&nbsp;</p>
<br /><a href='https://www.esdm.co.uk/british-national-grid-in-mapinfo'>Mike Lush</a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/british-national-grid-in-mapinfo'>...</a>]]></description>
      <link>https://www.esdm.co.uk/british-national-grid-in-mapinfo</link>
      <author>mike.lush@idoxgroup.com (Mike Lush)</author>
      <comments>https://www.esdm.co.uk/british-national-grid-in-mapinfo</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/british-national-grid-in-mapinfo</guid>
      <pubDate>Wed, 28 Nov 2012 11:36:00 GMT</pubDate>
    </item>
  </channel>
</rss>