<?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>mobile and gis dev notes &#187; mapinfo</title>
	<atom:link href="http:///wordpress/tag/mapinfo/feed/" rel="self" type="application/rss+xml" />
	<link>/wordpress</link>
	<description>by rupert</description>
	<lastBuildDate>Wed, 08 Feb 2012 22:26:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Exporting from Postgres to Mapinfo</title>
		<link>/wordpress/2007/08/exporting-from-postgres-to-mapinfo/</link>
		<comments>/wordpress/2007/08/exporting-from-postgres-to-mapinfo/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 12:00:36 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[ogr2ogr]]></category>

		<guid isPermaLink="false">/wordpress/?p=108</guid>
		<description><![CDATA[I had a problem when using ogr2ogr and converting a postgres table to a road table. My postgres table containa a utf-8 road name which is all in chinese. The mapinfo road table created by ogr2ogr seems to contain the correct geometry and other fields that is in utf-8. However, all my chinese characters is [...]]]></description>
			<content:encoded><![CDATA[<p>I had a problem when using ogr2ogr and converting a postgres table to a road table. My postgres table containa a utf-8 road name which is all in chinese. The mapinfo road table created by ogr2ogr seems to contain the correct geometry and other fields that is in utf-8. However, all my chinese characters is all messed up. So, I have to export the file and open it to mapinfo.</p>
<p>1. In Postgres, to export to a file..<br />
<code><br />
cybersoftbjv1=# set client_encoding = gbk;<br />
SET<br />
cybersoftbjv1=# \o road.txt;<br />
cybersoftbjv1=# select rd_id, cn_name from roads where cn_name &lt;&gt; '';<br />
cybersoftbjv1=# \q<br />
</code></p>
<p>2. Open the file in vim, and do a &#8220;%s/ //g&#8221;. This would replace all &#8221; &#8221; to &#8220;&#8221;.<br />
Note: This is reasonable for chinese since chinese dont have spaces. However english prases and sentences differ.</p>
<p>3. Open the file in mapinfo and replace the other columns using Table -&gt; Update.</p>
<p>If anybody has any other way to specify the client encoding in ogr2ogr that would be perfect&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/08/exporting-from-postgres-to-mapinfo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OGR Quick Reference</title>
		<link>/wordpress/2007/07/ogr2ogr-quick-reference/</link>
		<comments>/wordpress/2007/07/ogr2ogr-quick-reference/#comments</comments>
		<pubDate>Mon, 09 Jul 2007 18:22:19 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[GDAL/OGR]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[ogr2ogr]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=73</guid>
		<description><![CDATA[Here is a list of the most widely used OGR commands I use.. OGR2OGR 1. POSTGRES -&#62; MAPINFO $ ogr2ogr -f &#34;Mapinfo File&#34; busline_buffer10m.tab PG:&#34;host=localhost user=postgres dbname=cybersoftbj&#34; -sql &#34;select * from table_name&#34; -a_srs WGS84 -nln layer_name -nlt MULTIPOLYGON 2. MAPINFO -&#62; POSTGRES ogr2ogr -f &#34;PostgreSQL&#34; PG:&#34;host=127.0.0.1 user=rupert dbname=australia password=*****&#34; AUS_ROAD.TAB -nln AUS_ROAD -a_srs EPSG:4269 -t_srs [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a list of the most widely used OGR commands I use..</p>
<p><strong>OGR2OGR</strong><br />
<strong>1. POSTGRES -&gt; MAPINFO</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;Mapinfo File&quot;</span> busline_buffer10m.tab PG:<span style="color: #ff0000;">&quot;host=localhost user=postgres dbname=cybersoftbj&quot;</span> <span style="color: #660033;">-sql</span> <span style="color: #ff0000;">&quot;select * from table_name&quot;</span> -a_srs WGS84 <span style="color: #660033;">-nln</span> layer_name <span style="color: #660033;">-nlt</span> MULTIPOLYGON</pre></div></div>

<p><strong>2. MAPINFO -&gt; POSTGRES</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;PostgreSQL&quot;</span> PG:<span style="color: #ff0000;">&quot;host=127.0.0.1 user=rupert dbname=australia password=*****&quot;</span> AUS_ROAD.TAB <span style="color: #660033;">-nln</span> AUS_ROAD -a_srs EPSG:<span style="color: #000000;">4269</span> -t_srs EPSG:<span style="color: #000000;">3857</span> <span style="color: #660033;">-skip-failures</span>
&nbsp;
ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;PostgreSQL&quot;</span> PG:<span style="color: #ff0000;">&quot;host=myhost user=myloginname dbname=mydbname password=mypassword&quot;</span> mytabfile.tab <span style="color: #660033;">-nln</span> newtablename <span style="color: #660033;">-select</span> columnName</pre></div></div>

<p>Note: If you have Chinese characters, might as well do MAPINFO -&gt; SHAPE -&gt; POSTGRES<br />
<a href="http://222.128.19.19/wordpress/?p=108">http://222.128.19.19/wordpress/?p=108</a></p>
<p><strong>3. SHAPE -&gt; POSTGRES</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">shp2pgsql <span style="color: #660033;">-W</span> <span style="color: #ff0000;">&quot;gbk&quot;</span> <span style="color: #660033;">-s</span> <span style="color: #000000;">4326</span> lbjrdnt_small_polyline roads <span style="color: #000000; font-weight: bold;">&amp;</span>gt; roads.sql</pre></div></div>

<p><strong>4. POSTGRES -&gt; SHAPE</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pgsql2shp <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-u</span> lbs <span style="color: #660033;">-P</span> tracking <span style="color: #660033;">-f</span> roads.shp databasename tablename</pre></div></div>

<p><strong>4. MAPINFO TO ORACLE</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ogr2ogr <span style="color: #660033;">-f</span> OCI OCI:username<span style="color: #000000; font-weight: bold;">/</span>password<span style="color: #000000; font-weight: bold;">@</span>orcl C:\path_to_tabfile\EMPLOYEES.TAB <span style="color: #660033;">-nln</span> employees</pre></div></div>

<p>Note: This assumes you already have Oracle 10g Client installed and &#8220;orcl&#8221; is defined as an instance in tnsnames.ora. OGR2OGR automatically updates USER_SDO_GEOM_METADATA and creates a spatial index.</p>
<p><strong>5. MAPINFO to MAPINFO but different projection. From EPSG:4326 to EPSG:3857</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;MapInfo File&quot;</span> BaseMaps_3857<span style="color: #000000; font-weight: bold;">/</span>AUS_CITIES_3857.TAB BaseMaps<span style="color: #000000; font-weight: bold;">/</span>AUS_CITIES.TAB -a_srs <span style="color: #ff0000;">&quot;EPSG:4326&quot;</span> -t_srs <span style="color: #ff0000;">&quot;EPSG:3857&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/07/ogr2ogr-quick-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapinfo Utility for gdal_translate.</title>
		<link>/wordpress/2007/06/mapinfo-utility-for-gdal_translate/</link>
		<comments>/wordpress/2007/06/mapinfo-utility-for-gdal_translate/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 17:44:36 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[GDAL/OGR]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[raster]]></category>

		<guid isPermaLink="false">/wordpress/?p=61</guid>
		<description><![CDATA[I made a small perl utility to automate the gcp&#8217;s from Mapinfo Raster TABS to gdal_translate command line. Currently your tabfile would have: !table !version 300 !charset WindowsLatin1 &#160; Definition Table File &#34;beijing_6th_1.jpg&#34; Type &#34;RASTER&#34; (116.522865,40.016316) (347,184) Label &#34;Pt 1&#34;, (116.681215,40.015286) (7729,243) Label &#34;Pt 2&#34;, (116.679777,39.777904) (7666,14674) Label &#34;Pt 3&#34;, (116.523827,39.779108) (397,14606) Label &#34;Pt 4&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>I made a small perl utility to automate the gcp&#8217;s from Mapinfo Raster TABS to gdal_translate command line.  Currently your tabfile would have:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">!table
!version 300
!charset WindowsLatin1
&nbsp;
Definition Table
  File &quot;beijing_6th_1.jpg&quot;
  Type &quot;RASTER&quot;
  (116.522865,40.016316) (347,184) Label &quot;Pt 1&quot;,
  (116.681215,40.015286) (7729,243) Label &quot;Pt 2&quot;,
  (116.679777,39.777904) (7666,14674) Label &quot;Pt 3&quot;,
  (116.523827,39.779108) (397,14606) Label &quot;Pt 4&quot;
  CoordSys Earth Projection 1, 104
  Units &quot;degree&quot;
  RasterStyle 4 1
  RasterStyle 7 1677695</pre></div></div>

<p>How to use<br />
<a href='/wordpress/wp-content/uploads/2008/08/gdal_mapinfo.pl'>gdal_mapinfo</a></p>
<p>1. ls *.TAB &gt; init.sh</p>
<p>2. vi init.sh to reflect the ff:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">perl gdal_mapinfo.pl Beijing_6th_1.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_10.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_11.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_12.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_13.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_2.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_3.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_4.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_5.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_6.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_7.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_8.TAB &amp;gt;&amp;gt; final.bat
perl gdal_mapinfo.pl Beijing_6th_9.TAB &amp;gt;&amp;gt; final.bat</pre></div></div>

<p>3. The resulting final.bat should have the ff:<br />
gdal_translate  -gcp 347 184 116.522865 40.016316 -gcp 7729 243 116.681215 40.015286 -gcp 7666 14674 116.679777 39.777904 -gcp 397 14606 116.523827 39.779108 -of GTiff Beijing_6th_1.jpg I:\\satimages\translated\Beijing_6th_1_translated.tif</p>
<p>gdalwarp -s_srs epsg:4326 -t_srs epsg:4326 I:\\satimages\translated\Beijing_6th_1_translated.tif<br />
I:\\satimages\warped\Beijing_6th_1.tif
</pre>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/06/mapinfo-utility-for-gdal_translate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing Mapinfo Raster JPEG Images using GDAL</title>
		<link>/wordpress/2007/06/processing-mapinfo-raster-jpeg-images-using-gdal/</link>
		<comments>/wordpress/2007/06/processing-mapinfo-raster-jpeg-images-using-gdal/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 12:25:30 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[GDAL/OGR]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[raster]]></category>

		<guid isPermaLink="false">/wordpress/?p=59</guid>
		<description><![CDATA[I have a couple of sat images (raw jpegs) from Google that I want to use with Openlayers/Mapserver. The raw jpegs were registered using Mapinfo via GCP (Ground Control Points). Mapinfo Raster JPEG Images example: rupert@rupert-winxp /e/home/map/beijing/new/satimages$ ll -rw-r&#8211;r&#8211; 1 rupert None 358 Jan 30 03:23 2NE1.TAB -rw-r&#8211;r&#8211; 1 rupert None 7.1M Jan 30 02:38 [...]]]></description>
			<content:encoded><![CDATA[<p>I have a couple of sat images (raw jpegs) from Google that I want to use with Openlayers/Mapserver.  The raw jpegs were registered using Mapinfo via GCP (Ground Control Points).</p>
<p>Mapinfo Raster JPEG Images example:</p>
<p>rupert@rupert-winxp /e/home/map/beijing/new/satimages$ ll<br />
-rw-r&#8211;r&#8211; 1 rupert None  358 Jan 30 03:23 2NE1.TAB<br />
-rw-r&#8211;r&#8211; 1 rupert None 7.1M Jan 30 02:38 2NE1.jpg<br />
-rw-r&#8211;r&#8211; 1 rupert None  356 Feb  1 18:56 2NE2a.TAB<br />
-rw-r&#8211;r&#8211; 1 rupert None 3.8M Feb  1 08:57 2NE2a.jpg</p>
<p>You cannot fully reference 2NE1.TAB as a Mapserver Layer. I tried to use 2NE1.jpg, but the problem its not georeferenced.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">rupert@rupert-winxp /e/home/map/beijing/new/satimages
$ gdalinfo 2NE1.jpg
Driver: JPEG/JPEG JFIF
Size is 8650, 6744
Coordinate System is `'
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 6744.0)
Upper Right ( 8650.0,    0.0)
Lower Right ( 8650.0, 6744.0)
Center      ( 4325.0, 3372.0)
Band 1 Block=8650x1 Type=Byte, ColorInterp=Red
Band 2 Block=8650x1 Type=Byte, ColorInterp=Green
Band 3 Block=8650x1 Type=Byte, ColorInterp=Blue</pre></div></div>

<p>The georeference coordinates of 2NE1.jpg, just like an ESRI World File, is found in 2NE1.TAB&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">rupert@rupert-winxp /e/home/map/beijing/new/satimages
$ cat 2NE1.TAB
!table
!version 300
!charset WindowsLatin1
&nbsp;
Definition Table
  File &quot;2ne1.jpg&quot;
  Type &quot;RASTER&quot;
  (116.38575,39.906105) (349,6619) Label &quot;Pt 1&quot;,
  (116.390072,39.93201) (1160,317) Label &quot;Pt 2&quot;,
  (116.42786,39.932296) (8210,253) Label &quot;Pt 3&quot;,
  (116.4295878,39.90722318) (8522,6358) Label &quot;Pt 4&quot;
  CoordSys Earth Projection 1, 0
  Units &quot;degree&quot;</pre></div></div>

<p>I found hurting myself in trying to create an ESRI world file from the current MAPINFO Raster TABS. So, I decided to go for GeoTIFF since its native in Mapserver. Using GDAL utilities my only problem is how to put a coordinate system and reference to the raster.</p>
<p>On windows, you could use <a href="http://fwtools.maptools.org">Frank&#8217;s FWTools.</a> For Linux, compile GDAL by source with python would be extremely helpful later on.  For installation of GDAL on Linux, we can use <a href="http://mapserver.gis.umn.edu/docs/howto/verboselinuxinstall/">Mapserver&#8217;s Verbose Installation in Linux Guide.</a></p>
<p><strong><a href="http://www.gdal.org/">GDAL</a> &#8211; the saviour!</strong>.</p>
<p><a href="http://www.gdal.org/gdal_utilities.html">GDAL utilities</a> is extremely helpful in reprojection, scaling, image mosaics, etc.  For now, we will use <a href="http://www.gdal.org/gdal_translate.html">gdal_translate</a> and <a href="http://www.gdal.org/gdalwarp.html">gdal_warp</a>.  Please RTFM the utilities.</p>
<p>1. Using gdal_translate to specify the gcp&#8217;s registered in Mapinfo.</p>
<blockquote><p>     <strong>gdal_translate -gcp pixel line easting northing</strong><br />
Add the indicated ground control point to the output dataset. This option may be provided multiple times to provide a set of GCPs.</p></blockquote>
<p><code><br />
<strong><br />
$ gdal_translate -gcp 349 6619 116.38575 39.906105 -gcp 1160 317 116.390072 39.93201 -gcp 8210 253 116.42786 39.932296 -gcp 8522 6358 116.4295878 39.90722318 -of GTiff 2NE1.jpg 2NE1translated.tif<br />
</strong><br />
Input file size is 8650, 6744<br />
0...10...20...30...40...50...60...70...80...90...100 - done.<br />
</code></p>
<p>Note: even if we specify the gcp&#8217;s, gdal_translate would not specify the corner coordinates of the tiff.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">rupert@rupert-winxp /e/home/map/beijing/new/satimages
$ gdalinfo 2NE1translated.tif
Driver: GTiff/GeoTIFF
Size is 8650, 6744
Coordinate System is `'
GCP Projection =
GCP[  0]: Id=1, Info=
          (349,6619) -&amp;gt; (116.38575,39.906105,0)
GCP[  1]: Id=2, Info=
          (1160,317) -&amp;gt; (116.390072,39.93201,0)
GCP[  2]: Id=3, Info=
          (8210,253) -&amp;gt; (116.42786,39.932296,0)
GCP[  3]: Id=4, Info=
          (8522,6358) -&amp;gt; (116.4295878,39.90722318,0)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 6744.0)
Upper Right ( 8650.0,    0.0)
Lower Right ( 8650.0, 6744.0)
Center      ( 4325.0, 3372.0)
Band 1 Block=8650x1 Type=Byte, ColorInterp=Red
Band 2 Block=8650x1 Type=Byte, ColorInterp=Green
Band 3 Block=8650x1 Type=Byte, ColorInterp=Blue</pre></div></div>

<p>2. Use gdalwarp to reproject using the gcp and specify the coordinates.</p>
<blockquote><p>The gdalwarp utility is an image mosaicing, reprojection and warping utility. The program can reproject to any supported projection, and can also apply GCPs stored with the image if the image is &#8220;raw&#8221; with control information.</p></blockquote>
<p><code><br />
<strong>$ gdalwarp -s_srs epsg:4326 -t_srs epsg:4326 2NE1translated.tif warped.tif</strong><br />
Creating output file that is 9422P x 5631L.<br />
Processing input file 2NE1translated.tif.<br />
:0...10...20...30...40...5050...60...70...80...90...<br />
</code></p>
<p>Let&#8217;s check after gdalwarp using gdalinfo&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ gdalinfo warped.tif
Driver: GTiff/GeoTIFF
Size is 9422, 5631
Coordinate System is:
GEOGCS[&quot;WGS 84&quot;,
    DATUM[&quot;WGS_1984&quot;,
        SPHEROID[&quot;WGS 84&quot;,6378137,298.2572235630016,
            AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],
        AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],
    PRIMEM[&quot;Greenwich&quot;,0],
    UNIT[&quot;degree&quot;,0.0174532925199433],
    AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]
Origin = (116.383841930499160,39.933342296341991)
Pixel Size = (0.000004927579869,-0.000004927579869)
Metadata:
  AREA_OR_POINT=Area
Corner Coordinates:
Upper Left  ( 116.3838419,  39.9333423) (116d23'1.83&quot;E, 39d56'0.03&quot;N)
Lower Left  ( 116.3838419,  39.9055951) (116d23'1.83&quot;E, 39d54'20.14&quot;N)
Upper Right ( 116.4302696,  39.9333423) (116d25'48.97&quot;E, 39d56'0.03&quot;N)
Lower Right ( 116.4302696,  39.9055951) (116d25'48.97&quot;E, 39d54'20.14&quot;N)
Center      ( 116.4070558,  39.9194687) (116d24'25.40&quot;E, 39d55'10.09&quot;N)
Band 1 Block=9422x1 Type=Byte, ColorInterp=Red
Band 2 Block=9422x1 Type=Byte, ColorInterp=Green
Band 3 Block=9422x1 Type=Byte, ColorInterp=Blue</pre></div></div>

<p>Sweet. Now, all we need to do is display the raster images in Mapserver/OpenLayers.</p>
<p><a href="http://mapserver.gis.umn.edu/docs/howto/raster_data">Specifying a raster image in Mapserver</a></p>
<blockquote><p> LAYER<br />
NAME &#8220;2NE1&#8243;<br />
DATA &#8220;satimages/2NE1.tif&#8221;<br />
TYPE RASTER<br />
STATUS DEFAULT<br />
END</p>
<p>LAYER<br />
NAME &#8220;2NE2&#8243;<br />
DATA &#8220;satimages/2NE2a.tif&#8221;<br />
TYPE RASTER<br />
STATUS DEFAULT<br />
END</p></blockquote>
<p>Here is the end result&#8230;<br />
<img src="/wordpress/images/gdal_warp.jpg" />.</p>
<p>Lessons learned, I tried to specify coordinate extents using gdal_translate -a_ullr ulx uly lrx lry.  Specifying the coordinates was subjective by just looking at the cursor location of the registered image in Mapinfo. <em>It is still best to use the GCP&#8217;s. Simply put, we need to be accurate in specifying corner coordinates in raster images to project them accurately.</em></p>
<p><img src="/wordpress/images/gdal_merge.jpg" />.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/06/processing-mapinfo-raster-jpeg-images-using-gdal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preparing routing data for pgRouting</title>
		<link>/wordpress/2007/04/preparing-routing-data-for-pgrouting/</link>
		<comments>/wordpress/2007/04/preparing-routing-data-for-pgrouting/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 09:23:35 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[pgRouting]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">/wordpress/?p=49</guid>
		<description><![CDATA[1. It is important that you already have postgres, postgis, pgRouting installed in your machine. A. The schema. Below is the sample schema that is a derivative of the kanagawa sample data from pgRouting. Take note of the source and target nodes, as well as the length and the node coordinates (x1,y1; x2,y2) of the [...]]]></description>
			<content:encoded><![CDATA[<p>1. It is important that you already have <a href="/wordpress/?p=45">postgres, postgis, pgRouting installed in your machine.</a></p>
<p>A. The schema. Below is the sample schema that is a derivative of the <a href="http://www.postlbs.org/postlbs-cms/files/downloads/pgRouting-sampleapp.tar.bz">kanagawa sample data from pgRouting</a>. Take note of the <em>source and target nodes</em>, as well as the length and the node coordinates (x1,y1; x2,y2) of the line.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">cybersoftbj<span style="color: #66cc66;">=</span><span style="color: #808080; font-style: italic;"># \dt</span>
List of relations
 Schema <span style="color: #66cc66;">|</span>       Name       <span style="color: #66cc66;">|</span> Type  <span style="color: #66cc66;">|</span>  Owner
<span style="color: #808080; font-style: italic;">--------+------------------+-------+----------</span>
 public <span style="color: #66cc66;">|</span> geometry_columns <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> postgres
 public <span style="color: #66cc66;">|</span> roads            <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> postgres
 public <span style="color: #66cc66;">|</span> spatial_ref_sys  <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> postgres
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span> rows<span style="color: #66cc66;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">cybersoftbj<span style="color: #66cc66;">=</span><span style="color: #808080; font-style: italic;"># \d roads</span>
<span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;public.roads&quot;</span>
<span style="color: #993333; font-weight: bold;">COLUMN</span>   <span style="color: #66cc66;">|</span>          Type          <span style="color: #66cc66;">|</span>                      Modifiers
<span style="color: #808080; font-style: italic;">------------+------------------------+-----------------------------------------------------</span>
gid        <span style="color: #66cc66;">|</span> integer                <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NEXTVAL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'roads_gid_seq'</span>::regclass<span style="color: #66cc66;">&#41;</span>
rd_id      <span style="color: #66cc66;">|</span> bigint
yutu_id    <span style="color: #66cc66;">|</span> integer
block_id   <span style="color: #66cc66;">|</span> bigint
heirarchy  <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>
cn_name    <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">75</span><span style="color: #66cc66;">&#41;</span>
py_name    <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
source     <span style="color: #66cc66;">|</span> bigint
target     <span style="color: #66cc66;">|</span> bigint
x1         <span style="color: #66cc66;">|</span> numeric
y1         <span style="color: #66cc66;">|</span> numeric
x2         <span style="color: #66cc66;">|</span> numeric
y2         <span style="color: #66cc66;">|</span> numeric
costlength <span style="color: #66cc66;">|</span> numeric
the_geom   <span style="color: #66cc66;">|</span> geometry</pre></div></div>

<p>A. Extracting the coordinates of the line segments from Mapinfo.</p>
<p>1. I have to format the data structure as follows&#8230;</p>
<p>&#8230;here is the roads table after weeding out some unnecessary columns&#8230;<br />
<img src="/wordpress/images/routing_mapinfo_1.png" /></p>
<p>&#8230; adding the source,target,x1,y1,x2,y2,costlength&#8230;<br />
<img src="/wordpress/images/routing_mapinfo_2.png" /></p>
<p>2. Using ObjectGeography. <a href="http://reference.mapinfo.com/software/mapbasic/english/8.5/MB_Ref.pdf">Download the MapBasic Reference</a></p>
<p>ObjectGeography( object, attribute )</p>
<p>ObjectGeography( object, &#8220;1&#8243; ) &lt;&#8211; gives you the beginning x coord of the point</p>
<p><img src="/wordpress/images/routing_mapinfo_3.png" /></p>
<p>3. Export the tab file to a shape file for ArchMap.</p>
<p><img src="/wordpress/images/routing_mapinfo_4.png" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/04/preparing-routing-data-for-pgrouting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading Mapinfo table to PostGis</title>
		<link>/wordpress/2007/04/loading-mapinfo-table-to-postgis/</link>
		<comments>/wordpress/2007/04/loading-mapinfo-table-to-postgis/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 21:25:06 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[GDAL/OGR]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[ogr2ogr]]></category>

		<guid isPermaLink="false">/wordpress/?p=47</guid>
		<description><![CDATA[AFAIK, there are only two ways to load data to PostGIS: 1. Using Insert statements 2. Using Utilities. Utilities include shp2pgsql which is found in &#8220;C:\Program Files\PostgreSQL\8.2\bin\&#8221; or &#8220;/usr/local/pgsql/bin&#8221;. To load Mapinfo table, I have used the OGR utilities from FWTools for Windows. and used gdal1.3.2 (since it contains ogr) for Unix. OGR2OGR CheatSheet should [...]]]></description>
			<content:encoded><![CDATA[<p>AFAIK, there are only two ways to load data to PostGIS:<br />
1. Using Insert statements<br />
2. Using Utilities.</p>
<p>Utilities include shp2pgsql which is found in &#8220;C:\Program Files\PostgreSQL\8.2\bin\&#8221; or &#8220;/usr/local/pgsql/bin&#8221;. To load Mapinfo table, I have used the OGR utilities from <a href="http://fwtools.maptools.org/">FWTools for Windows.</a> and used <a href="www.gdal.org">gdal1.3.2</a> (since it contains ogr) for Unix.</p>
<p><a href="http://www.bostongis.com/?content_name=ogr_cheatsheet">OGR2OGR CheatSheet</a> should be a good kickstart for basic understanding. For the impatient..</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;PostGreSQL&quot;</span> <span style="color: #660033;">-nlt</span> LINESTRING -a_srs <span style="color: #ff0000;">&quot;EPSG:4326&quot;</span> PG:<span style="color: #ff0000;">&quot;host=localhost user=username password=mypassword dbname=mydb mytab.TAB -select columnName</span></pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;PostgreSQL&quot;</span> PG:<span style="color: #ff0000;">&quot;host=myhost user=myloginname dbname=mydbname password=mypassword&quot;</span> mytabfile.tab <span style="color: #660033;">-nln</span> newtablename <span style="color: #660033;">-select</span> columnName</pre></div></div>

<p>Bear in mind that you should select out the columns from your mapfile (mine is chinese) especially if you have a diffent encoding in your column which matches your database (postgres). You might get a &#8220;Terminating translation prematurely after failed translation of layer [layername]&#8221; error.  Since Mapinfo stores the text to ASCII, my workaround is to export the tabfile to a UTF-8 textfile then upload it to PostGres. Hoping the primary ids would match to make the necessary updates&#8230;</p>
<p>An alternative to load Chinese text from Mapinfo to PostGIS is the ff:<br />
1. In Mapinfo use the Universal Translator to export the table into a shape file.<br />
2. Once you have the shape file, you can directly use the <strong>shp2pgsql</strong><em>.</em></p>
<p><em>shp2pgsql -W &#8220;gbk&#8221; -s 4326 lbjrdnt_small_polyline roads &gt; roads.sql</em></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/04/loading-mapinfo-table-to-postgis/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mapinfo8 MySQL5 Connection</title>
		<link>/wordpress/2007/02/linking-mysql5-with-mapinfo8/</link>
		<comments>/wordpress/2007/02/linking-mysql5-with-mapinfo8/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 09:03:14 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">/wordpress/?p=37</guid>
		<description><![CDATA[I only tried this using point objects. 1. Download and install MyODBC3.5.1 2. Create database mapinfotest 3. Create the mapinfo_mapcatalog table as follows: CREATE TABLE `mapinfo_mapcatalog` ( `SpatialType` float NOT NULL default '0', `TableName` char(32) NOT NULL default '', `OwnerName` char(32) NOT NULL default '', `SpatialColumn` char(32) NOT NULL default '', `DB_X_LL` float NOT NULL [...]]]></description>
			<content:encoded><![CDATA[<p>I only tried this using point objects.</p>
<p>1. Download and install <a href="http://dev.mysql.com/downloads/connector/odbc/3.51.html">MyODBC3.5.1</a></p>
<p>2. Create database mapinfotest</p>
<p>3. Create the mapinfo_mapcatalog table as follows:<br />
<code><br />
CREATE TABLE `mapinfo_mapcatalog` (<br />
`SpatialType` float NOT NULL default '0',<br />
`TableName` char(32) NOT NULL default '',<br />
`OwnerName` char(32) NOT NULL default '',<br />
`SpatialColumn` char(32) NOT NULL default '',<br />
`DB_X_LL` float NOT NULL default '0',<br />
`DB_Y_LL` float NOT NULL default '0',<br />
`DB_X_UR` float NOT NULL default '0',<br />
`DB_Y_UR` float NOT NULL default '0',<br />
`CoordinateSystem` char(254) NOT NULL,<br />
`Symbol` char(254) NOT NULL default '',<br />
`XColumnName` char(32) NOT NULL default '',<br />
`YColumnName` char(32) NOT NULL default '',<br />
PRIMARY KEY  (`TableName`,`OwnerName`)<br />
) ENGINE=MyISAM DEFAULT CHARSET=latin1;<br />
</code></p>
<p>4. create a sample table with two (2) decimal columns for the latitude and longitude.<br />
<code><br />
CREATE TABLE `poi_orig2` (<br />
`poiid` decimal(10,0) unsigned NOT NULL default '0',<br />
`id` char(10) NOT NULL default '',<br />
`py_name` char(255) character set utf8 default NULL,<br />
`latitude` decimal(20,8) default '0.00000000',<br />
`longitude` decimal(20,8) default '0.00000000',<br />
PRIMARY KEY  (`poiid`,`id`)<br />
)<br />
</code></p>
<p>5. Open Mapinfo 8<br />
6. File -&gt; Open DBMS Connection<br />
<img src="/wordpress/images/mapinfo_odbc.png" /></p>
<p>7. Table &gt; Maintenance &gt; Make DBMS Table Mappable<br />
<img src="/wordpress/images/mapinfo_mappable_window.png" /></p>
<p>Fill up the necessary values for the x,y and the index column.<br />
<img src="/wordpress/images/mapinfo_mappable_window_2.png" /></p>
<p>You need to choose an index column so Mapinfo could update the record/s in MySQL, normally it would be an ID. Once successful you should be able to see the success window&#8230;</p>
<p><img src="/wordpress/images/mapinfo_mappable_window_3.png" /></p>
<p>8. Open the table<br />
<img src="/wordpress/images/mapinfo_mappable_window_4.png" /></p>
<p>Click on the upper right corner to open a dbms connection. After selecting the datasource (mine is system) then it would give you a list of tables to choose from.</p>
<p><img src="/wordpress/images/mapinfo_mappable_window_5.png" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/02/linking-mysql5-with-mapinfo8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

