[Proj] quoting +nadgrids ?

Glynn Clements glynn at gclements.plus.com
Sat Jul 31 05:40:32 PDT 2010


Frank Warmerdam wrote:

> My understanding is that this thread is really about weaknesses in the
> DOS cmd.exe shell interpreter, right?

No.

The problem is that gdalwarp's -t_srs option expects a proj argument
*list* as a single string, which it then splits into individual proj
arguments using spaces as a seperator. That is problematic because
some of those arguments may be filenames, which can contain spaces
(particularly on Windows, where it's often impossible to create a file
without spaces in its pathname unless you have Administrator
privilege).

It may be possible to workaround this by using the 8.3 filename, i.e. 
"c:\progra~1\..." instead of "C:\Program Files". However, that fails
if the filename is being chosen via a GUI file selection dialog, which
will only offer the full name for a directory. Also, it's possible to
inhibit the creation of 8.3 filenames, and some security software
flags use of 8.3 filenames as suspicious behaviour (it's a common
tactic for bypassing filename-based access controls).

As far as actual solutions go:

One option is to provide a switch, e.g. -srs_sep, to allow a custom
separator to be specified, e.g.:

gdalwarp -srs_sep "|" -t_srs "+proj=longlat|+datum=nad83|+nadgrids=c:\Program Files\GRASS\etc\nad\conus"

Another option is to implement shell-style quoting and/or escaping
rules, similar to Python's shlex.split() function.

Yet another option is to provide alternative options which accept one
argument at a time, bypassing the splitting step altogether, e.g.:

gdalwarp -t_srs1 +proj=longlat -t_srs1 +datum=nad83 -t_srs1 "+nadgrids=c:\Program Files\GRASS\etc\nad\conus"

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the Proj mailing list