Friday, August 6, 2010

My favourite thing about MyISAM MySQL tables!

One important feature that distinguish MyISAM from InnoDB is that MyISAM tables are generally binary portable. If you need to move a table from one MySQL server to the other, just copy the files from first server to the second server and you are ready to go. In some instances it’s a lot handier than using say mysqldump.
I found out my recent MYSQL backups were currupted... Only after our server had been compromised!  So I spent half a day reading up on how to try and recover data from an old MySQL  Data Folder.  Untill I stumbled across this quote hidden in one of the comments on this page: MySQL: the Pros and Cons of MyISAM Tables.

So for MyISAM tables it is possible to copy the folder containing the database table files (by default found in your MYSQL data directory eg. MySQL\MySQL Server 5.0\data\nameofschema) and paste it into the equivilent data folder of a different MtSQL installation.  of course this will work best if the installation is a similar version to the original.

Very useful to know if like me your MySQL dumps were currupted or you are foolish enough not to back up your data with a sqldump in the first place.

Thursday, August 5, 2010

How to import a Mapinfo Interchange Format .MIF to a shapefile

I downloaded some species distributions from AgroAtlas earlier which were in MapInfo MIF/MID format.  It had been years since I had to import this format to .shp to view in ESRI ArcGIS and it took a little digging to figure out how.  So I thought I would blog it so I would have it documented for next time.

First of all I checked ArcGIS for a quick win, and was disapointed.  Apparently there are two options.

  1. The first is to use the MIF to shapefile utility found in the ArcGIS8.x toolbar as documented here.  However this didn't work for me.  I got an error stating "Unable to finish conversion" and the tool only created a .shp and a .shx, with no .dbf or .prj for that matter.
  2. The second ESRI method was to buy the ArcGIS Data Interoperability Extension which seemed a little xtreme just to check out a couple of small datasets.
So I got onto google and found a third non-ESRI solution using the GDAL/OGR Simple Feature Library in FWToolsFWTools is a set of Open Source GIS binaries for windows or linux including the GDAL/OGR command line libraries.  FWTools is the easiest way to install the GDAL libraries onto windows and can be done via an installer .exe file downloadable here. Simply double click the exe file and follow the on screen installation instructions.  Once installed open up the FWTools Shell from either the start menu>programs or the desktop short cut then enter the following command:


ogr2ogr -f "ESRI Shapefile" c:\output-path-to-shapefile\mydata.shp c:\path-to-mif-mid-files\mydata.mif

That was the simple how-to example,ogr2ogr has many other parameters that can be specified click here for full ogr2ogr usage documentation.

Ogr supports multiple data formats including: ESRI Shapefile, MapInfo Tab file, TIGER, s57, DGN, CSV, DBF, GML, KML, Interlis, SQLite, ODBC, ESRI GeoDatabase (MDB format), PostGIS/PostgreSQL, MySQL.

Other references used in researching this article:

http://osgeo-org.1803224.n2.nabble.com/Fwd-FWrools-OGR-utilities-mif-to-shape-conversion-ogr2ogr-not-recognizing-mif-file-td5313127.html


http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet