[Qgis-user] Using templates in QGIS when importing GPS-data to PostGIS

Pekka Hurskainen pekka.hurskainen at gmail.com
Mon Jul 4 06:43:33 PDT 2011


Hi Micha,

thanks for the tip! I managed to do it with the following command from
FWTools shell:

ogr2ogr -update -append -f "PostgreSQL" PG:"host=localhost user=postgres
dbname=db password=xxx"
my_gps_points.gpx waypoints -sql "SELECT name AS gps_nimi, time AS gps_aika
FROM waypoints" -t_srs EPSG:3067 -nln
my_table_name

I selected the fields I wanted, and cast them to different field names in my
db table. I only wanted waypoints, and also did a coordinate transformation
from wgs84 -> ETRS-TM35FIN. Very handy, once you get the syntax right. Now
the only manual thing left is to change the input gpx file name every time,
if all other parameters stay constant.

Pekka

On Mon, Jul 4, 2011 at 11:42 AM, Micha Silver <micha at arava.co.il> wrote:

> **
>
> On 04/07/2011 11:29, Pekka Hurskainen wrote:
>
> Hello list,
>
> Let's say I have a bunch of waypoints collected with a GPS device, and
> uploaded to QGIS with GPSBabel in GPX-format. I have only four fields
> in the GPX file which I want to keep (lat, lon, time, name).
>
> Then I have an empty template shapefile, which has more fields
> defined. Some of them has to be filled interactively in QGIS, some of
> them will be filled by trigger functions in PostGIS. The point is that
> the template shapefile has to match exactly the table definitions in
> my PostGIS database, so that it is possible to append GPS datasets to
> the database using PostGIS Manager plugin. I can't just spit the GPX
> files straight to PostGIS.
>
> The problem is how to "combine" the GPX points with the template. I've
> tried to merge these two with fTools and mmqgis plugins, but these
> both add all fields from both layers, which I don't want (there isn't
> an option to choose fields). Also I haven't found any "append" tool
> similar to ArcGIS in QGIS.
>
> I know it's possible to overcome this with manually deleting the
> unwanted fields, but I want to automate the process since this part
> will be repeated hundreds of times.
>
> Any ideas?
>
>
>
> Can you skip the shapefile step altogether and use ogr2ogr to go straight
> from gpx to PostGIS ?
> ogr2ogr has an -append option to add new features to an existing layer, and
> a -select option to list which fields you want to insert into the target
> layer.
> Then, with the new features already in PostGIS do your interactive editing
> as needed from QGIS.
>
>
>  Pekka Hurskainen
> _______________________________________________
> Qgis-user mailing listQgis-user at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-user
>
> This mail was received via Mail-SeCure System.
>
>
>
>
>
> --
>
> [image: Hevra Logo]
>
> Micha Silver
>
> Arava Development Co
>
> 052-3665918
>
> http://www.surfaces.co.il
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20110704/f732a738/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Logo_Hevra.gif
Type: image/gif
Size: 9069 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20110704/f732a738/attachment.gif>


More information about the Qgis-user mailing list