[R-sig-Geo] st_write and gpx file
Ahmadou Dicko
d|cko@@hm@dou @end|ng |rom gm@||@com
Sun Mar 6 12:38:52 CET 2022
I'm glad you found a solution, and indeed GPX need a track_fid and
track_seg_id for track points.
Regarding the driver issue, it's just because it was not added to the
list of extension automatically recognized by sf::st_write.
You can look at it here:
https://github.com/r-spatial/sf/blob/ddc79d0e9b7f7500a6d6020964b180cd4064bc83/R/read.R#L670-L695
You can raise an issue on the repository and make a case for it to be added.
Best,
Ahmadou
On Sun, Mar 6, 2022 at 6:44 AM Patrick Giraudoux <
patrick.giraudoux using univ-fcomte.fr> wrote:
> I have made some additionnal trials, with the argument 'driver'
> explicit. It appears that the sf object 'walk' must compulsory have two
> fields names "track_fid" and "track_seg_id" respectively. Once created :
>
> > walk Simple feature collection with 2095 features and 3 fields Geometry
> type: POINT Dimension: XY Bounding box: xmin: 5.951268 ymin: 47.29238
> xmax: 5.974512 ymax: 47.3015 Geodetic CRS: WGS 84 First 10 features:
> track_fid ele geometry track_seg_id 1 1 243 POINT (5.95348 47.29709) 1 2
> 1 243 POINT (5.953438 47.29704) 1 3 1 244 POINT (5.953219 47.29702) 1 4
> 1 243 POINT (5.952884 47.29713) 1 5 1 243 POINT (5.952492 47.2972) 1 6 1
> 243 POINT (5.952335 47.29743) 1 7 1 242 POINT (5.951881 47.29732) 1 8 1
> 242 POINT (5.951495 47.29724) 1 9 1 293 POINT (5.951333 47.29719) 1 10 1
> 294 POINT (5.951388 47.29706) 1
>
>
> Then,
>
> st_write(walk,dsn="walk.gpx",layer="track_points",driver="GPX")
>
> is written with no error
>
> However, st_write(walk,dsn="walk.gpx",layer="track_points") still gets
> 'Error: Could not guess driver for walk.gpx'
>
>
>
>
> Le 05/03/2022 à 20:24, Ahmadou Dicko a écrit :
> > Hi Patrick,
> >
> > You can add the driver manually.
> >
> > st_write(walk, dsn = "walk.gpx", layer = "track_points", driver = "GPX")
> >
> > Hope it helps,
> > Ahmadou
> >
> >
> > On Sat, Mar 5, 2022 at 6:53 PM Patrick Giraudoux
> > <patrick.giraudoux using univ-fcomte.fr> wrote:
> >
> > Dear listers,
> >
> > I am making trials with the sf package trying to write point
> > geometries
> > into afile. Here is the sf object:
> >
> > > walk Simple feature collection with 2095 features and 2 fields
> > Geometry
> > type: POINT Dimension: XY Bounding box: xmin: 5.951268 ymin: 47.29238
> > xmax: 5.974512 ymax: 47.3015 Geodetic CRS: WGS 84 First 10 features:
> > track_seg_point_id ele geometry 1 0 243 POINT (5.95348 47.29709) 2
> > 1 243
> > POINT (5.953438 47.29704) 3 2 244 POINT (5.953219 47.29702) 4 3 243
> > POINT (5.952884 47.29713) 5 4 243 POINT (5.952492 47.2972) 6 5 243
> > POINT
> > (5.952335 47.29743) 7 6 242 POINT (5.951881 47.29732) 8 7 242 POINT
> > (5.951495 47.29724) 9 8 293 POINT (5.951333 47.29719) 10 9 294 POINT
> > (5.951388 47.29706)
> >
> > Writing a shapefile as well as a kml is no problem:
> >
> > st_write(walk,"walk.shp")
> >
> > st_write(walk,"walk.kml")
> >
> > But I cannot go through writing a gpx file, e.g.
> >
> > > st_write(walk,dsn="walk.gpx",layer="track_points") Error: Could
> > not guess driver for walk.gpx
> >
> > I have tried several other combinations all unsuccessful.
> >
> > Have someone an idea about what goes wrong ?
> >
> > Best,
> >
> > Patrick
> >
> >
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> >
> >
> > --
> > Ahmadou H. DICKO, PhD
> >
> > Statistical consultant
> > Mobile: (+221) 77 123 81 69
> > Skype: dicko.ahmadou.h
> > Twitter : @dickoah
> > Gitlab: gitlab/dickoa
> > Github: github/dickoa
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Ahmadou H. DICKO, PhD
Statistical consultant
Mobile: (+221) 77 123 81 69
Skype: dicko.ahmadou.h
Twitter : @dickoah
Gitlab: gitlab/dickoa
Github: github/dickoa
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list