[postgis-users] geometry from postgis to mysql

Bayu Kurniawan R bayu at bkurniawan.com
Tue Nov 13 17:39:39 PST 2007


Try with GDAL/OGR (http://gdal.org/ogr)

This is example to convert a data ESRI Shapefile to MySQL :
ogr2ogr -f MySQL MySQL:gis,user=user,password=secret shape_file.shp -lco
GEOMETRY_NAME=the_geom

Example to convert a PostGIS to MySQL :
ogr2ogr -f MySQL MySQL:gis,user=user,password=secret
PG:"host=172.27.1.245 user=user
dbname=gis" "map_province_boundary_polygon" -lco GEOMETRY_NAME=the_geom
-a_srs EPSG:4326 -overwrite

To check your MySQL data :
ogrinfo MySQL:gis,user=root,password=root district -so

INFO: Open of `MySQL:gis,user=user,password=secret'
using driver `MySQL' successful.
Layer name: district
Geometry: Polygon
Feature Count: 6
Extent: (105.096718, -6.998588) - (106.774400, -5.875104)
Layer SRS WKT:
(unknown)
FID Column = OGR_FID
Geometry Column = the_geom
district: String (50.0)
province: String (50.0)
class: String (50.0)

On 11/12/07, Kyle.Wilcox at noaa.gov <Kyle.Wilcox at noaa.gov> wrote:
>
> Have you tried using pgsql2shp and then shp2mysql?
>
> ----- Original Message -----
> From: tashjp <tashjp at hotmail.com>
> Date: Sunday, November 11, 2007 4:38 pm
> Subject: [postgis-users] geometry from postgis to mysql
>
> >
> > I had a go posting this in the MySQL forum but with no luck...
> > I have a PostGIS database with various columns of geometry data. I
> > need to
> > import all this into a MySQL database instead (my uni won't run
> > PostGIS on
> > their servers) and have decided to create the tables from scratch
> > and then
> > just do a search and replace on the insert statements to convert from
> > Postgre to MySQL.
> >
> > I have tried both
> >
> > INSERT INTO RoadNode VALUES ('osgb4000000029762763', 3, '2005-09-14',
> > 'osgb1000001824287062',
> > 'GeomFromWKB(0101000000000000008A2B204100000000B07EF940)');
> >
> > and
> >
> > INSERT INTO RoadNode VALUES ('osgb4000000029762711', 3, '2005-09-14',
> > 'osgb1000001824287705',
> '010100000000000000082C2041000000006070F940');
> >
> > both of which return the error message:
> > >[Error] Script lines: 1-1 --------------------------
> > Data truncation: Cannot get geometry object from data you send to the
> > GEOMETRY field
> >
> > Does anyone know what I am doing wrong?
> >
> > Thanks, Natasha
> > --
> > View this message in context: http://www.nabble.com/geometry-from-
> > postgis-to-mysql-tf4787330.html#a13695426
> > Sent from the PostGIS - User mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



-- 
Bayu Kurniawan R
GIS Programmer
PT. Sigma Cipta Utama
Jl. Tekno I Blok B No:5,6,7
BSD City Tangerang 15314
Indonesia
Phone : +62 21 75871955 ext.304
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071114/c5537c83/attachment.html>


More information about the postgis-users mailing list