[FWTools] OGR2OGR QUOTES ISSUE

Matt Wilkie matt.wilkie at gov.yk.ca
Thu Oct 7 12:31:57 EST 2010


  Hi Susana,

You're missing the beginning single quote (') before C:/Archivos.... and 
I don't think you need to escape the inner double quote ("), so instead of

    '\"LAYER= \'line\'\"'

try

    '"LAYER=\'line\'"'

Also it would be easier to read the code if you did something like:

ogr2ogr = 'C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr'
inshape = line + '.shp'
outshape = b + '.shp'
query = '-where "LAYER=\'line\'" '

p = subprocess.Popen([ogr2ogr, inshape, query,  outshape])

hope that helps,

matt wilkie
--------------------------------------------
Geomatics Analyst
Information Management and Technology
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------


On 07/10/2010 9:19 AM, Susana Iraiis Delgado Rodriguez wrote:
> Hello members!
> I'm running a python script to execute an ogr2ogr command. The process 
> has been sucessful, but now I want to create a shp for each layer a 
> shp has. I now I must use the command :
> ogr2ogr newX.shp -where "LAYER = 'layerValueX'" original.shp
> The code for the subprocess is as follows:
> for line in open("unico.txt", "r").readlines():
>   p = subprocess.Popen([C:/Archivos de 
> programa/FWTools2.4.7/bin/ogr2ogr', line+'.shp',
> ' -where', '\"LAYER= \'line\'\"', b+'.shp'])unfortuanely wtih this 
> code the module reads the variable line, which as the value of the 
> layer has a string "line": The problem is located after the word 
> LAYER, I don't have idea about the properly way to write the quotes.
> Hope you can help, regards!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20101007/23c9aea4/attachment.htm 


More information about the FWTools mailing list