Metainformationen zur Seite
  •  

Import GEO-shapes to mysql

Download data from https://www.naturalearthdata.com/downloads/ e. g. http://naciscdn.org/naturalearth/packages/natural_earth_vector.zip. Data are in the public domain

Unzip the file, the shape files for country borders are in the folders natural_earth_vector/XXXm_cultural, where the XXXm defines the resolution of the shapes.

Create a mysql database and grant access to a user

CREATE DATABASE geo_test;
GRANT ALL ON DATABASE geo_test.* TO USER@localhost;

Change to the directory with the resolution, you want to use:

cd natural_earth_vector/50m_cultural

Import the data with the ogr2ogr script (part of package gdal-bin in Ubuntu)

ogr2ogr -f MySQL MySQL:geo_test,user=******,password=******* ne_50m_admin_0_sovereignty.shp -nln borders2 -update -overwrite -lco GEOMETRY_NAME=SHAPE2