<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Did the earth move for you too?</title>
	<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too/</link>
	<description>Comments on Ask MetaFilter post Did the earth move for you too?</description>
	<pubDate>Sat, 10 Jan 2009 12:33:35 -0800</pubDate>
	<lastBuildDate>Sat, 10 Jan 2009 12:33:35 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Did the earth move for you too?</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too</link>	
		<description>GISfilter -- I have a PostGIS table containing spatial data in the form of a few thousand shapefiles.  Anybody know a quick way I can move *all* of them by about 40 metres? &lt;br /&gt;&lt;br /&gt; Due to a bizarre set of circumstances I need to work with a data set of things contructed from GPS in Ireland.  Because of a systemic error, every multipolygon I have is out of whack slightly.  Boo!&lt;br&gt;
&lt;br&gt;
Yet, because the country I live in is small enough for this to work, I can have a bunch of stuff accurate to within 2m if I globally move every multipolygon 50m to the North and 23.4m to the West.  Yay!&lt;br&gt;
&lt;br&gt;
But I&apos;m too unfamiliar with both Postgres and Python (I&apos;m working with Geodjango for the first time) to figure out which 10-line loop script will do that lateral translation for me.  Boo!&lt;br&gt;
&lt;br&gt;
So... um...  can anybody lend me a hand here?  I don&apos;t really care which language the one-use-ever script I need is written in.  And my multipolygons are strings of co-ords using WGS84, where each X&amp;amp;Y value is separated by a space, and each pair separated by a comma.&lt;br&gt;
&lt;br&gt;
The application of your collective genius is warmly appreciated.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2009:site.111309</guid>
		<pubDate>Sat, 10 Jan 2009 12:24:08 -0800</pubDate>
		<dc:creator>genghis</dc:creator>
		
			<category>gis</category>
		
			<category>postgis</category>
		
			<category>postgres</category>
		
			<category>translation</category>
		
			<category>math</category>
		
			<category>maths</category>
		
			<category>resolved</category>
		
	</item> <item>
		<title>By: mecran01</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601045</link>	
		<description>are the numbers being added to X and Y the same?  i.e. are you adding 5 to X and 7 to Y, repeated 10,000 times?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601045</guid>
		<pubDate>Sat, 10 Jan 2009 12:33:35 -0800</pubDate>
		<dc:creator>mecran01</dc:creator>
	</item><item>
		<title>By: mecran01</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601047</link>	
		<description>Also, can you post one sample record here?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601047</guid>
		<pubDate>Sat, 10 Jan 2009 12:33:54 -0800</pubDate>
		<dc:creator>mecran01</dc:creator>
	</item><item>
		<title>By: genghis</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601054</link>	
		<description>a)  Yes, that&apos;s exactly it, and&lt;br&gt;
b)  Not usefully - asking Postgres for one row of the DB shows the multipolygon as one gigantic string of hex values</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601054</guid>
		<pubDate>Sat, 10 Jan 2009 12:40:28 -0800</pubDate>
		<dc:creator>genghis</dc:creator>
	</item><item>
		<title>By: genghis</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601056</link>	
		<description>...and yes, that definitely contradicts my memory of how those values were originally fed to the database.  My apologies.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601056</guid>
		<pubDate>Sat, 10 Jan 2009 12:41:30 -0800</pubDate>
		<dc:creator>genghis</dc:creator>
	</item><item>
		<title>By: hattifattener</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601068</link>	
		<description>In SQL it works to have a query like &quot;UPDATE sometable SET blah = blah + 72&quot; &#8212;&#160;it will compute the new values for each record based on the previous values. It&apos;s been a while since I used the Postgres GIS extensions, but I bet there&apos;s a function which takes a polygon and translates it, in which case the answer is a SQL oneliner.&lt;br&gt;
&lt;br&gt;
A quick google turns up things like ST_Affine and ST_Translate, but there might be easier ways.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601068</guid>
		<pubDate>Sat, 10 Jan 2009 12:51:04 -0800</pubDate>
		<dc:creator>hattifattener</dc:creator>
	</item><item>
		<title>By: nicwolff</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601157</link>	
		<description>Assuming the geometry is stored as meters north and east of some reference point (probably the Equator and Greenwich), try this:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;BEGIN;&lt;br&gt;
UPDATE table SET location = ST_Translate(location, 50, -23.4, 0);&lt;br&gt;
SELECT ST_AsText(location) FROM table;&lt;br&gt;
-- if the locations look OK:&lt;br&gt;
COMMIT;&lt;br&gt;
-- otherwise&lt;br&gt;
ROLLBACK;&lt;br&gt;
-- and try something else&lt;br&gt;
&lt;/code&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601157</guid>
		<pubDate>Sat, 10 Jan 2009 14:46:24 -0800</pubDate>
		<dc:creator>nicwolff</dc:creator>
	</item><item>
		<title>By: genghis</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601251</link>	
		<description>The values are stored in decimal degrees.  Unfortunately, when I tried:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;UPDATE table set mpoly = ST_Translate(mpoly, 0.00049, -0.000234, 0);&lt;/pre&gt;&lt;br&gt;
...the values, while pleasingly altered uniformly, were shifted by a half/a quarter of a degree rather than the much smaller shift we&apos;re looking for.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601251</guid>
		<pubDate>Sat, 10 Jan 2009 16:31:50 -0800</pubDate>
		<dc:creator>genghis</dc:creator>
	</item><item>
		<title>By: nicwolff</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601452</link>	
		<description>That&apos;s why we did it in a transaction :) Your numbers are a little off though: A degree of longitude is roughly 111km at the equator, so in Ireland at 53&#186;N it&apos;s cos(53/180*&#960;)*111km = 66.8km, and you want to move 23.4m west so that&apos;s -.00075&#186;. A degree&#160;of latitude is still 111km so 50m/111km = .00045&#186;. &lt;br&gt;
&lt;br&gt;
And I got longitude and latitude backward in the query - I think it&apos;s x, y, z so let&apos;s assume that it&apos;s longitude first, so it&apos;d be &lt;code&gt;ST_Translate(location, -.00075, .00045, 0)&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
No idea why your points are moving so far though - just to test the units, what happens if you &lt;code&gt;ST_Translate(location, 1, 1, 0)&lt;/code&gt;?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601452</guid>
		<pubDate>Sat, 10 Jan 2009 21:12:31 -0800</pubDate>
		<dc:creator>nicwolff</dc:creator>
	</item><item>
		<title>By: hattifattener</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601513</link>	
		<description>And what SRID are the polygons defined in? The units of the translate command depend on the SRID, afaict.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601513</guid>
		<pubDate>Sat, 10 Jan 2009 23:33:10 -0800</pubDate>
		<dc:creator>hattifattener</dc:creator>
	</item><item>
		<title>By: nicwolff</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601520</link>	
		<description>Sorry again! 23.4m / 66.8km = .00035&#186; not .00075&#186;&lt;br&gt;
&lt;br&gt;
And yeah, SRID is probably the reason for the scale error.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601520</guid>
		<pubDate>Sun, 11 Jan 2009 00:00:24 -0800</pubDate>
		<dc:creator>nicwolff</dc:creator>
	</item><item>
		<title>By: genghis</title>
		<link>http://ask.metafilter.com/111309/Did-the-earth-move-for-you-too#1601917</link>	
		<description>SRID=4326, I should have mentioned before.&lt;br&gt;
&lt;br&gt;
That more or less worked (it appears the leading zero before the decimal, which I used and you didn&apos;t, makes a difference because of a bug).  &lt;br&gt;
&lt;br&gt;
Y&apos;all rule.  AskMefi trinkets now being distributed accordingly.  Thanks!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.111309-1601917</guid>
		<pubDate>Sun, 11 Jan 2009 13:05:24 -0800</pubDate>
		<dc:creator>genghis</dc:creator>
	</item>
	</channel>
</rss>
