[R-sig-Geo] RPyGeo Query -- probably easy

Maarten van Strien maarten at vstrien.nl
Thu Dec 17 22:06:17 CET 2009

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

# 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.

More information about the R-sig-Geo mailing list