On Fri, 26 Aug 2011, Roger Bivand wrote:
On Thu, 25 Aug 2011, Karl Ove Hufthammer wrote:
Dear list members,
Is it possible to define which FID values should be used when saving a
SpatialPointsDataFrame to a GML files using writeOGR (rgdal package)?
The FID values are stored as <ogr:layername fid="F0"> (and F1, F2, …). If I
insert a new row in the SPDF, most features change their FID, which creates
much unneccessary noise in our VCS,
so I would like to use an already existing ID as the FID.
I have tried change both the row.names and adding columns named
‘fid’ and ‘gml_id’, the writeOGR still only uses F0, F1, … as the FIDs.
No FID is set in writeOGR() in the underlying C++ function writeOGR(). One
could be set, but only as unique integers >= 0, not as the row.names() which
are strings. The result is that default FID are written. It would be possible
to modify the function to add integer FID, I think, but they would have to be
valid unique integers. I think that what gets written from there depends on
the driver internals, which the function does not reach. Would this help?
Patches welcome!
Indeed, the driver internals are a possible solution, see:
http://www.gdal.org/ogr/drv_gml.html
which suggests that some reading is possible in OGR >= 1.8.0, but that
writing will first come with OGR >= 1.9.0, that is the development
version, I believe. If this really matters for you, please look carefully
at commits on the GDAL trunk in the GML driver. I think that there have
been recent developments, with increased speed claimed. Consequently,
there isn't much that can be done from the R side, you'll need an rgdal
built against a future version of GDAL/OGR.
Roger
Best wishes,
Roger
--
Karl Ove Hufthammer
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo