
Contents
ogr2ogr の準備
昨日は、Windows 32bitZIP
解凍先 ┗ bin ┣ gdal111.dll など ┣ … ┗ gdal ┗ apps ┣ ogr2ogr.exe ┗ …
$cd R:\release-1500-gdal-1-11-1-mapserver-6-4-1\bin $"gdal/apps/ogr2ogr" --version GDAL 1.11.1, released 2014/09/24 $"gdal/apps/ogr2ogr" --help Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update] [-select field_list] [-where restricted_where] [-progress] [-sql] [-dialect dialect] [-preserve_fid] [-fid FID] [-spat xmin ymin xmax ymax] [-geomfield field] [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def] [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...] dst_datasource_name src_datasource_name [-lco NAME=VALUE] [-nln name] [-nlt type] [-dim 2|3|layer_dim] [layer [layer ...]] Advanced options : [-gt n] [-clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent] [-clipsrcsql sql_statement] [-clipsrclayer layer] [-clipsrcwhere expression] [-clipdst [xmin ymin xmax ymax]|WKT|datasource] [-clipdstsql sql_statement] [-clipdstlayer layer] [-clipdstwhere expression] [-wrapdateline][-datelineoffset val] [[-simplify tolerance] | [-segmentize max_dist]] [-addfields] [-relaxedFieldNameMatch] [-fieldTypeToString All|(type1[,type2]*)] [-unsetFieldWidth] [-fieldmap identity | index1[,index2]*] [-splitlistfields] [-maxsubfields val] [-explodecollections] [-zfield field_name] [-gcp pixel line easting northing [elevation]]* [-order n | -tps] Note: ogr2ogr --long-usage for full help.

ようやく ogr2ogr でインポート
一応$cd R:\release-1500-gdal-1-11-1-mapserver-6-4-1\bin $gdal\apps\ogr2ogr -overwrite -progress -f "MySQL" MYSQL:zcta,user=root R:\zip\tl_2013_us_zcta510.shp # just one line actually ERROR 1: MySQL connect failed for: zcta,user=root Access denied for user 'root'@'localhost' (using password: NO) ERROR 1: MySQL connect failed for: zcta,user=root Access denied for user 'root'@'localhost' (using password: NO) ERROR 1: MySQL connect failed for: zcta,user=root Access denied for user 'root'@'localhost' (using password: NO) ERROR 1: MySQL driver doesn't currently support database creation. Please create database before using. MySQL driver failed to create MYSQL:zcta,user=root

いきなりエラー。メッセージを見るとユーザ認証の問題らしく、PostGIS
When opening a database, it's name should be specified in the form "MYSQL:dbname[,options]" where the options can include comma seperated items like "user=*userid*", "password=*password*", "host=*host*" and "port=*port*".
先ほどの引数のうち「user-root」の後に「,password=*****」を付ければ良さそう。要するにデータベース接続文字列の中に含めるという。で再度やってみます。ただし先に、インポート先のデータベースを作成。先ほどのエラーメッセージの最後の方に
mysql> CREATE DATABASE zcta; Query OK, 1 row affected (0.00 sec)
$cd R:\release-1500-gdal-1-11-1-mapserver-6-4-1\bin $gdal\apps\ogr2ogr -overwrite -progress -f "MySQL" MYSQL:zcta,user=root,password=******** R:\zip\tl_2013_us_zcta510.shp # just one line actually

やっとできました
一度投入して、-overwrite
$gdal\apps\ogr2ogr -progress -f "MySQL" MYSQL:zcta,user=root,password=******** R:\zip\tl_2013_us_zcta510.shp # just one line actually FAILED: Layer tl_2013_us_zcta510 already exists, and -append not specified. Consider using -append, or -overwrite. ERROR 1: Terminating translation prematurely after failed translation of layer tl_2013_us_zcta510 (use -skipfailures to skip errors)

結果の確認は明日します。一つ気になるのは、psql
MySQL
PostGIS
それはさておき、シェープファイルを