<?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>jsha/README &#187; HOWTO</title>
	<atom:link href="http://jacob.hoffman-andrews.com/README/index.php/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://jacob.hoffman-andrews.com/README</link>
	<description>a blog by Jacob Hoffman-Andrews</description>
	<lastBuildDate>Thu, 14 Apr 2011 21:49:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HOWTO Turn a shapefile into a KML file under Ubuntu</title>
		<link>http://jacob.hoffman-andrews.com/README/index.php/2008/10/29/howto-turn-a-shapefile-into-a-kml-file-under-ubuntu/</link>
		<comments>http://jacob.hoffman-andrews.com/README/index.php/2008/10/29/howto-turn-a-shapefile-into-a-kml-file-under-ubuntu/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 18:50:02 +0000</pubDate>
		<dc:creator>jsha</dc:creator>
				<category><![CDATA[HOWTO]]></category>

		<guid isPermaLink="false">http://jacob.hoffman-andrews.com/README/?p=20</guid>
		<description><![CDATA[Shapefiles and KML are two common geographic formats.  Shapefiles tend to be used by geographic databases like ESRI and PostGIS, while KML originated with Google Earth, back when it was called Keyhole.  KML files are more common for data that is intended primarily to display to users.  They are supported  both in Google Earth [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Shapefile">Shapefiles</a> and <a href="http://en.wikipedia.org/wiki/KML">KML</a> are two common geographic formats.  Shapefiles tend to be used by geographic databases like ESRI and PostGIS, while KML originated with Google Earth, back when it was called Keyhole.  KML files are more common for data that is intended primarily to display to users.  They are supported  both in Google Earth and in Google Maps, through <a href="http://local.google.com/support/bin/answer.py?hl=en&amp;answer=68480#import">importing to a My Map</a>.</p>
<p>But for all that both formats are really popular, it&#8217;s not easy to go back and forth between the two.  Further, it&#8217;s really hard to simplify a KML file that has highly detailed polygons.  This is important because, while Google Earth may be able to handle a large number of points, Google Maps has to execute in the browser and so has tight limits on how many points can be in a polygon.  This can result in a group of polygons being split by Maps across multiple pages so they can be rendered in a reasonable amount of time.</p>
<p>I had some shapefile data I wanted to simplify and display in a My Map.  My solution was to bite the bullet and install PostgreSQL and PostGIS.  Both are free software and are available as packages on Ubuntu Intrepid Ibex.  Similar directions should apply for other Linux distributions.</p>
<p>First, install PostgreSQL and the PostGIS geographic layer on top of it:</p>
<p><code><br />
$ sudo apt-get install postgresql-8.3-postgis postgis gdal-bin<br />
</code></p>
<p>Become the postgres user to create the procedural language, initialize the geographic functions, and fill the spatial_ref_sys table:</p>
<p><code><br />
$ sudo su postgres<br />
postgres$ createlang plpgsql<br />
postgres$ psql -d postgres -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql<br />
postgres$ psql -d postgres -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql<br />
postgres$ createuser username<br />
Shall the new role be a superuser? (y/n) y<br />
CREATE ROLE<br />
postgres$ exit<br />
</code></p>
<p>Import the shapefile into your database.  The -d parameter drops the table before creating it, useful if you may be reimporting the data multiple times.  If you have a large file you may want to add the -D parameter, which uses the more efficient dump format for faster ingestion.  The -s parameter specifies the SRID of your input data, and you should be able to figure it out from the .prj file that came with the shapefile.</p>
<p><code><br />
$ shp2pgsql -d -s 2877 election_precincts election_precincts_table postgres | psql -d postgres<br />
</code></p>
<p>And dump output into KML.  Note that you can put any criteria you want into the -sql param, so you could restrict the set of features you output.</p>
<p><code><br />
$ ogr2ogr -f "KML" election_precincts.kml PG:"dbname=postgres" -dsco NameField=precinct -sql "select precinct, transform(simplify(the_geom, 100), 4326) from election_precincts_table"<br />
</code></p>
<p>Note: KML explicitly supports only one SRID: 4326.  That refers to <a href="http://en.wikipedia.org/wiki/WGS84">WGS84</a>.  So in the ogr2ogr command above, you need the transform(&#8230;, 4326) call to produce valid lat/longs for KML.  Evidently Google Maps has another SRID, 900913, but I haven&#8217;t played with that one at all.  If you&#8217;re using KML as your input to Google Maps, 4326 should be fine.</p>
<p>You can increase or decrease the parameter to simplify().  Higher numbers mean more simplification, lower numbers mean less.</p>
<p>The NameField param is a KML-specific parameter to ogr2ogr which specifies which field from the query should be used as the name for a given KML feature.</p>
<p>Here are some other pages I found useful when working this all out:</p>
<p><a href="http://postgis.refractions.net/support/wiki/index.php?PostgisOnUbuntu">PostGIS Wiki : Postgis On Ubuntu</a><br />
<a href="http://www.perrygeo.net/wordpress/?p=56">PerryGeo » Converting Shapefiles (and more) to KML</a><br />
<a href="http://www.arcwebservices.com/arcwebonline/services/pcs_alpha.htm">Projected coordinates listed by name</a><a href="http://postgis.refractions.net/documentation/manual-1.3/"><br />
</a><a href="http://postgis.refractions.net/documentation/manual-1.3/">PostGIS Manual</a><br />
<a href="http://www.bostongis.com/postgis_simplify.snippet">PostGIS Simplify</a><br />
<a href="http://www.bostongis.com/postgis_quickguide.bqg">PostGIS ver. 1.3.1 Quick Guide &#8211; Cheatsheet</a><br />
<a href="http://trac.osgeo.org/gdal/ticket/2271">#2271 (Add built in reprojection support to KML driver) &#8211; GDAL &#8211; Trac</a><br />
<a href="http://postgis.refractions.net/pipermail/postgis-users/2001-September/000330.html">[postgis] SRID for LAT/LONG</a><br />
<a href="http://postgis.refractions.net/pipermail/postgis-users/2004-June/005011.html">[postgis-users] addgeometrycolumn() does not exist</a><br />
<a href="http://lists.maptools.org/pipermail/fwtools/2007-April/000750.html">[FWTools] ogr2ogr shp &#8211;&gt; kml conversion failing on some complicated polygons</a><br />
<a href="http://www.geo-news.net/index_norm.php">Generalize Vectors &#8211; GEO UTILITIES</a><br />
<a href="http://postgis.refractions.net/documentation/manual-1.3/"><br />
</a><a href="http://postgis.refractions.net/support/wiki/index.php?PostgisOnUbuntu"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jacob.hoffman-andrews.com/README/index.php/2008/10/29/howto-turn-a-shapefile-into-a-kml-file-under-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Importing Evolution addressbook contacts into GMail</title>
		<link>http://jacob.hoffman-andrews.com/README/index.php/2008/09/10/importing-evolution-addressbook-contacts-into-gmail/</link>
		<comments>http://jacob.hoffman-andrews.com/README/index.php/2008/09/10/importing-evolution-addressbook-contacts-into-gmail/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 21:48:43 +0000</pubDate>
		<dc:creator>jsha</dc:creator>
				<category><![CDATA[HOWTO]]></category>

		<guid isPermaLink="false">http://jacob.hoffman-andrews.com/README/?p=13</guid>
		<description><![CDATA[GMail&#8217;s Contacts section now has support for a full-featured set of contacts, including phone numbers, addresses, etc.  I tried importing my addressbook from Evolution, but it wasn&#8217;t easy.  Step 1: Export your addressbook in vCard format.  Step 2: Tweak the output.GMail doesn&#8217;t like plain TEL records, it wants them to always beprefixed by phone., e.g.:phone.TEL;TYPE=CELL,OTHER:(510) [...]]]></description>
			<content:encoded><![CDATA[<p>GMail&#8217;s Contacts section now has support for a full-featured set of contacts, including phone numbers, addresses, etc.  I tried importing my addressbook from Evolution, but it wasn&#8217;t easy.  Step 1: Export your addressbook in vCard format.  Step 2: Tweak the output.GMail doesn&#8217;t like plain TEL records, it wants them to always beprefixed by phone., e.g.:phone.TEL;TYPE=CELL,OTHER:(510) 334-3594
<p id=":2a" class="ArwC7c ckChnd"> Versus</p>
<p>TEL;TYPE=CELL,OTHER:(510) 555-1212Also GMail doesn&#8217;t like blank lines between vCard records.Here are a pair of vim commands to fix the above two problems::%s,^TEL,phone.TEL:v/./d
<p id=":2a" class="ArwC7c ckChnd"> </p>
<p id=":2a" class="ArwC7c ckChnd">Once you&#8217;ve edited the file appropriately you should be able to import it using the Contacts &gt; Import function within GMail.</p>
]]></content:encoded>
			<wfw:commentRss>http://jacob.hoffman-andrews.com/README/index.php/2008/09/10/importing-evolution-addressbook-contacts-into-gmail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HOWTO Tunnel an Rdesktop (RDC) connection over SSH from Linux</title>
		<link>http://jacob.hoffman-andrews.com/README/index.php/2008/08/25/howto-tunnel-an-rdesktop-rdc-connection-over-ssh-from-linux/</link>
		<comments>http://jacob.hoffman-andrews.com/README/index.php/2008/08/25/howto-tunnel-an-rdesktop-rdc-connection-over-ssh-from-linux/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 02:25:54 +0000</pubDate>
		<dc:creator>jsha</dc:creator>
				<category><![CDATA[HOWTO]]></category>

		<guid isPermaLink="false">http://jacob.hoffman-andrews.com/README/?p=12</guid>
		<description><![CDATA[I have an SSH connection into work, and wanted to be able to access a Windows machine there via rdesktop.  I tried this:
$ ssh -L 3890:windows-machine:3890
$ rdesktop localhost:3890
But the rdesktop command hung for a long time then died.  Some poking around revealed this page: http://www.bluestream.org/Networking/SSHTunnelRDP.htm, which details an occasional problem that occurs when trying to [...]]]></description>
			<content:encoded><![CDATA[<p>I have an SSH connection into work, and wanted to be able to access a Windows machine there via rdesktop.  I tried this:</p>
<p>$ ssh -L 3890:windows-machine:3890</p>
<p>$ rdesktop localhost:3890</p>
<p>But the rdesktop command hung for a long time then died.  Some poking around revealed this page: <a href="http://www.bluestream.org/Networking/SSHTunnelRDP.htm">http://www.bluestream.org/Networking/SSHTunnelRDP.htm</a>, which details an occasional problem that occurs when trying to connect to a forwarded port on localhost.  Their suggestion was to bind to a non-localhost interface.  Since their tutorial is for Putty, here&#8217;s the equivalent for OpenSSH:</p>
<p>$ ssh -L mymachinename:3890:windows-machine:3890</p>
<p>$ rdesktop mymachinename:3890</p>
<p>Where mymachinename is the actual hostname of your machine, which should in theory resolve to the IP of your ethernet adaptor.</p>
]]></content:encoded>
			<wfw:commentRss>http://jacob.hoffman-andrews.com/README/index.php/2008/08/25/howto-tunnel-an-rdesktop-rdc-connection-over-ssh-from-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO Transfer contacts from BitPim/Linux to an iPhone</title>
		<link>http://jacob.hoffman-andrews.com/README/index.php/2008/04/16/howto-transfer-contacts-from-bitpimlinux-to-an-iphone/</link>
		<comments>http://jacob.hoffman-andrews.com/README/index.php/2008/04/16/howto-transfer-contacts-from-bitpimlinux-to-an-iphone/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 23:19:24 +0000</pubDate>
		<dc:creator>jsha</dc:creator>
				<category><![CDATA[HOWTO]]></category>

		<guid isPermaLink="false">http://jacob.hoffman-andrews.com/README/?p=3</guid>
		<description><![CDATA[Bitpim is an open source tool to sync data from a variety of CDMA phones.  In particular it supports my LG VX-10, or it did until the thing got too beat up to sync.
Now I&#8217;m faced with the task of transferring my old contacts to my new phone.  Here&#8217;s how I went about [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bitpim.org/">Bitpim</a> is an open source tool to sync data from a variety of CDMA phones.  In particular it supports my LG VX-10, or it did until the thing got too beat up to sync.</p>
<p>Now I&#8217;m faced with the task of transferring my old contacts to my new phone.  Here&#8217;s how I went about doing so.</p>
<p><strong>1. <a href="http://en.wikipedia.org/wiki/Jailbreak">Jailbreak</a> your phone.</strong></p>
<p>I borrowed a Mac and ran <a href="http://ijailbreak.com/">iJailbreak</a>.  I&#8217;d be interested to hear if anyone knows of a jailbreak program for Linux.</p>
<h4>2. Export your contacts.</h4>
<p>In Bitpim, select File &gt; Export &gt; vCards&#8230; and save to the default bitpim.vcf.  The Dialect section of the export dialog should be &#8220;vCard 3.0.&#8221;</p>
<p><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/bitpim-export.png" title="bitpim-export.png"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/bitpim-export.png" alt="bitpim-export.png" /></a></p>
<p><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/bitpim-export2.png" title="bitpim-export2.png"><br />
</a></p>
<p>We have to fix up the output a little bit.  Bitpim produces output like:</p>
<pre>
TEL;TYPE=CELL,PREF:(212) 555-1212</pre>
<p>The &#8220;,PREF&#8221; here confuses Funambol.  I haven&#8217;t checked whether this is valid per the vCard spec or not, but it&#8217;s easy to fix:</p>
<pre>$ sed -i s/,PREF// ~/bitpim.vcf</pre>
<h4>3. Sign up for a free account at <a href="http://my.funambol.com/">my.funambol.com</a>.  While you&#8217;re there, download the sync app onto your iPhone.</h4>
<h4>4. Set up <a href="http://www.gnome.org/projects/evolution/">Evolution</a> and <a href="http://www.estamos.de/projects/SyncML/">SyncEvolution</a>.</h4>
<p>Evolution is most likely available as part of your distribution.  SyncEvolution, you will probably have to download separately from <a href="http://www.estamos.de/projects/SyncML/" title="estamos.de">estamos.de</a>.</p>
<p>Now use File &gt; Import&#8230; to import bitpim.vcf.</p>
<p><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import1.png" title="evolution-import1.png"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import1.thumbnail.png" alt="evolution-import1.png" /></a><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import2.png" title="evolution-import2.png"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import2.thumbnail.png" alt="evolution-import2.png" /></a><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import3.png" title="evolution-import3.png"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import3.thumbnail.png" alt="evolution-import3.png" /></a><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import4.png" title="evolution-import4.png"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import4.thumbnail.png" alt="evolution-import4.png" /></a><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import5.png" title="evolution-import5.png"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/evolution-import5.thumbnail.png" alt="evolution-import5.png" /></a></p>
<p>Neither SyncEvolution nor Funambol does a good job syncing deletions of contacts, so you&#8217;ll find that in order to delete a contact properly you&#8217;ll have to remove it from Evolution, Funambol, <em>and</em> your iPhone.  For that reason, I suggest that you go through your contacts now and remove any you don&#8217;t wish to keep.</p>
<p>Now you need to set up SynEvolution to talk to Funambol.  For this you should follow the <a href="http://www.estamos.de/projects/SyncML/GettingStarted.html">Getting Started instructions on estamos.de</a>.  It&#8217;s pretty straightforward but involves some editing of config files.  When you&#8217;re done you&#8217;ll be able to two-way sync between Evolution and Funabol with:</p>
<p><code>$ syncevolution funambol</code></p>
<h4>5. Set up the Funambol iPhone app and sync!</h4>
<p><a href="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/snap_181149.jpg" title="snap_181149.jpg"><img src="http://jacob.hoffman-andrews.com/README/wp-content/uploads/2008/04/snap_181149.jpg" alt="snap_181149.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jacob.hoffman-andrews.com/README/index.php/2008/04/16/howto-transfer-contacts-from-bitpimlinux-to-an-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

