I want to import a few .gpx files to postgresql using ogr2ogr. The data in each .gpx looks like this:
<trkpt lat="41.842607000" lon="12.490628000"><ele>40.5</ele><time>2010-05-31T14:12:11Z</time> </trkpt>
Firstly, I create a new table in postgresql
CREATE TABLE test (
fid serial NOT NULL, --
geom geometry(Point,4326),
ele double precision,
"time" timestamp with time zone,
CONSTRAINT activities_pk PRIMARY KEY (fid)
);
Then when I run the ogr2ogr script:
ogr2ogr -update -append -f "PostgreSQL" PG:"host="xx" user="xx" dbname="xx" password="xx"" 1st.gpx -nln test
However, the script failed due to geometry type mismatch.
Warning 1: Geometry to be inserted is of type Multi Line String, whereas the layer geometry type is Point. Insertion is likely to fail ERROR 1: ERROR: Geometry type (MultiLineString) does not match column type (Point)
ERROR 1: INSERT command for new feature failed. ERROR: Geometry type (MultiLineString) does not match column type (Point)
Can anyone help with this?
ogrinfo -so 1st.gpx
give you? I expect1: waypoints (Point), 2: routes (Line String), 3: tracks (Multi Line String), 4: route_points (Point), 5: track_points (Point)
1st.gpx track_points...
in your ogr2ogr, for example I use the following to add gpx points to a GeoPackageogr2ogr -f GPKG /home/hxxxx/gidataL/GPS/gpsmap64_tracker.gpkg /home/hxxxx/testing/TRACKS/Tracks-toMay7th.gpx track_points -t_srs epsg:27700 -nln Tracks-toMay7th_PTS -update