I need to import the spatial data in shape file into MySQL tables. I am able to import into PostGreSQL. Any pointers for MySQL. I need the data in MySQL table.
Asked
Active
Viewed 2.0k times
2 Answers
11
try this with FWtool installed
ogr2ogr -f MySQL MySQL:database_name,host=localhost,user=root,password=1234 C:\route_path\line.shp -nln datatable_name -update -overwrite -lco engine=MYISAM
try install for a better result in any process Osgeo4w
-
I tried that as well, but It didn't work because of some error regarding driver not found. – PhantomM Mar 18 '13 at 08:33
-
but the error will comes with FWTools or Osgeo4w, you could place the code you used – phipex Mar 18 '13 at 14:02
-
1The Ogre works wonders! You have to have the .shx file in the same dir as the .shp for it to work, and if you want any data to correspond with your shapes, you will need the .dbf files there as well, however it does not throw an error if it is not there: you will just end up with shapes with indexes (pretty useless to me). – user24601 Sep 29 '15 at 03:50
-
OSGeo4W is only for Windows, and I need to do this on linux. Do you know if there are any linux tools available that do this too? – cazort Mar 14 '17 at 17:05
-
1OSGeo4W is a packpage compiled for windows, the source is GDAL, GRASS, etc, find this in the documentation of de osgeo4w – phipex Mar 15 '17 at 17:06
1
I have just used the ogr2ogr command line tool to import the shape file into the mysql database. Make sure that the database server allows external connections. If doesn't, then it throws all sorts of errors.
Once you have that you can use -
Select ASTEXT(Shape) POLYGON from world to get an array of the polygon coordinates etc

user1464629
- 57
- 1
- 9