On Fri, 23 Jul 2010, Henk Sierdsema wrote:
Hi Roger, You're right of course: replacing the library with an older version works, but it's definitely not chique. So I looked into the problem a little bit deeper, following up on the remarks of Agus. It turns out, that the latest version of rgdal works fine with variable-names up to 10 characters, but crashes on longer variable-names. The problem appears apparently both on a Linux- (Ubuntu 9) and Windows-platforms (XP, Win7).
There are no "crashes". What it does depends on the GDAL version and the OGR driver chosen:
library(rgdal)
Loading required package: sp Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23 Path to GDAL shared files: /usr/local/share/gdal Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009 Path to PROJ.4 shared files: (autodetected)
names(cities)
[1] "NAME" "COUNTRY" "POPULATION" "CAPITAL"
cities$ABCDEFGHIJKLMNOPQRSTUVWXYZ <- NA names(cities)
[1] "NAME" "COUNTRY" [3] "POPULATION" "CAPITAL" [5] "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
writeOGR(cities, tempdir(), "cities", driver="ESRI Shapefile")
Warning message:
In writeOGR(cities, tempdir(), "cities", driver = "ESRI Shapefile") :
Non-fatal GDAL Error 6: Normalized/laundered field name:
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' to 'ABCDEFGHIJ'
ogrInfo(tempdir(), "cities")
Source: "/tmp/Rtmp2NjEC9", layer: "cities"
Driver: ESRI Shapefile number of rows 606
Feature type: wkbPoint with 2 dimensions
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
Number of fields: 5
name type length typeName
1 NAME 4 80 String
2 COUNTRY 4 80 String
3 POPULATION 2 24 Real
4 CAPITAL 4 80 String
5 ABCDEFGHIJ 2 11 Real
This OGR driver does not permit longer names (as the base DBF III
unwritten spec. does not either, this is not unexpected); however other
drivers may:
tf <- tempfile() writeOGR(cities, tf, "cities", driver="GML") ogrInfo(tf, "cities")
Source: "/tmp/Rtmp2NjEC9/file66334873", layer: "cities"
Driver: GML number of rows 606
Feature type: wkbPoint with 2 dimensions
NA
Number of fields: 5
name type length typeName
1 NAME 4 0 String
2 COUNTRY 4 0 String
3 POPULATION 2 33 Real
4 CAPITAL 4 0 String
5 ABCDEFGHIJKLMNOPQRSTUVWXYZ 0 16 Integer
tf <- tempfile() writeOGR(cities, tf, "cities", driver="MapInfo File") ogrInfo(tf, "cities")
Source: "/tmp/Rtmp2NjEC9/file19495cff", layer: "cities"
Driver: MapInfo File number of rows 606
Feature type: wkbPoint with 2 dimensions
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
Number of fields: 5
name type length typeName
1 NAME 4 254 String
2 COUNTRY 4 254 String
3 POPULATION 2 0 Real
4 CAPITAL 4 254 String
5 ABCDEFGHIJKLMNOPQRSTUVWXYZ 0 0 Integer
OK?
Roger
Henk
________________________________
Van: Roger Bivand [mailto:Roger.Bivand at nhh.no]
Verzonden: wo 21-7-2010 23:17
Aan: Henk Sierdsema; Agustin Lobo; r-sig-geo at stat.math.ethz.ch
Onderwerp: SV: [R-sig-Geo] writeOGR error: problem with GDAL (libgdal1- 1.7.0)
Success is of course in the eye of the beholder. You are free to change your own installation in arguably bad ways, but please do not advise others to do so on the list. Lots of peoiple may be misled by your suggestion. It would be possible to rebuild (guessing that you are using Windows) to rebuild an older source rgdal for newer R in order to retain previous behaviour, but messing with an installed library of R packages is always a questionable idea.
Roger
PS. Since the original posting was made (two months ago), rgdal has been revised, including IIRC changed messages in this case.
--- Roger Bivand, NHH, Helleveien 30, N-5045 Bergen, Roger.Bivand at nhh.no
________________________________
Fra: r-sig-geo-bounces at stat.math.ethz.ch p? vegne av Henk Sierdsema
Sendt: on 2010-07-21 13:17
Til: Agustin Lobo; r-sig-geo at stat.math.ethz.ch
Emne: Re: [R-sig-Geo] writeOGR error: problem with GDAL (libgdal1- 1.7.0)
Hi Augustin,
I've encountered the same problem after an update of the rgdal-package. I have resolved the problem by removing the rgal-folder in the library and replacing it by an older version of November 2009. You can download that version of www.sovon.nl/temp/rgdal_nov_2009.zip
Success!
Henk
-----Oorspronkelijk bericht-----
Van: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch]Namens Agustin Lobo
Verzonden: vrijdag 21 mei 2010 7:39
Aan: r-sig-geo at stat.math.ethz.ch
Onderwerp: [R-sig-Geo] writeOGR error: problem with GDAL (libgdal1-
1.7.0)
I'm getting this error using a command and an object that
used to work few months ago
writeOGR(Montseny20090409shtotspols, dsn="Montseny20090409tots2",
layer="Montseny20090409shtots2",driver="ESRI Shapefile")
Error in writeOGR(Montseny20090409shtotspols, dsn = "Montseny20090409tots2",
:
GDAL Error 1: Invalid index : -1
Calls: writeOGR -> .Call
In addition: Warning messages:
1: In writeOGR(Montseny20090409shtotspols, dsn = "Montseny20090409tots2", :
Non-fatal GDAL Error 6: Normalized/laundered field name: 'coords.x1.1' to
'coords.x1.'
2: In writeOGR(Montseny20090409shtotspols, dsn = "Montseny20090409tots2", :
Non-fatal GDAL Error 6: Normalized/laundered field name: 'coords.x2.1' to
'coords.x2.'
Both the Error and Warnings are new, and are actually related: if I do:
names(Montseny20090409shtotspols at data)[31]<-"UTMX"
names(Montseny20090409shtotspols at data)[32]<-"UTMY"
writeOGR() works fine.
Could a more explicit error message, linking the error to the problem with
the names, be issued by writeOGR() ? Initially I even thought I could have a
disk problem!
I recently upgraded from ubuntu 9.04 to 9.10 and to libgdal1-1.7.0.
R version 2.11.0 (2010-04-22)
Package: rgdal
Version: 0.6-27
Date: 2010-05-11
Thanks
Agus
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/writeOGR-error-problem-with-GDAL-libgdal1-1-7-0-tp5082811p5082811.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no