Maarten
 
I'm not sure about the single quotes but possibly you could add an extra 
special character break (the \ ) to indicate to python that the double quotes 
surrounding your field name are not the end of a string.  You could try the 
following code:
 
rpygeo.geoprocessor("select_analysis", c("nfroads.shp", "paved.shp", '
\\"ROAD_CLASS\\" = \'PAVED\' '), py.file= "rpygeo.py", working.directory =
 wrkspc, env = myenv, clean.up = FALSE)

 
Best Regards
 
Andrew
 
Dr Andrew Crowe
 
Lancaster Environment Centre
Lancaster University
Lancaster    LA1 4YQ
UK

________________________________

From: r-sig-geo-boun...@stat.math.ethz.ch on behalf of Maarten van Strien
Sent: Thu 17/12/2009 9:06 PM
To: r-sig-geo@stat.math.ethz.ch
Subject: Re: [R-sig-Geo] RPyGeo Query -- probably easy




Hi All,

I was wondering if anyone has found a solution to the mentioned problem, as
I have a similar problem with a query function in RPyGeo.
I am trying to use the 'select_analysis' ArcGIS function that uses an sql
expression to select certain values/names from a field in an attribute
table. This is what the ArcGIS help mentions about the Python code for this
function:

# For shapefile expression, fields are double quoted (") and text values are
single quoted (')
gp.select_analysis("nfroads.shp", "paved.shp", ' "ROAD_CLASS" = \'PAVED\' ')

To create this Python output I type the following in R:

> rpygeo.geoprocessor("select_analysis", c("nfroads.shp", "paved.shp", '
> "ROAD_CLASS" = \'PAVED\' '), py.file= "rpygeo.py", working.directory =
> wrkspc, env = myenv, clean.up = FALSE)

However, the rpygeo.py file that is created contains the following line:

gp.select_analysis( "nfroads.shp", "paved.shp", " "ROAD_CLASS" = 'PAVED' " )

This code doesn't work, because "ROAD_CLASS" = 'PAVED' is surrounded by "
(double quotation marks). The code would work fine if "ROAD_CLASS" = 'PAVED'
would be surrounded by ' (single quotation mark). I have tried this by
manually editing the rpygeo.py file.

My question is if anyone knows how to get RPyGeo to output single quotation
marks (') around the select query? Thank you in advance!

Best, Maarten

-----------
Maarten van Strien
PhD Student
Swiss Federal Institute for Forest, Snow and Landscape Research WSL
Landscape Modelling
Zürcherstrasse 111
8903 Birmensdorf, Switzerland
--
View this message in context: 
http://n2.nabble.com/RPyGeo-Query-probably-easy-tp2766675p4183466.html
Sent from the R-sig-geo mailing list archive at Nabble.com.

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to