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

Alexander Brenning brenning at uwaterloo.ca
Tue Apr 14 02:09:55 CEST 2009

well, these are two separate Python commands:

> gp.makefeaturelayer("abc.shp", "walk")
> gp.SelectLayerByAttribute('walk','NEW_SELECTION','\"hrwk05\" <> 0')

but this...

 > rpygeo.geoprocessor(
 > "makefeaturelayer('abc.shp','walk')",
 > "SelectLayerByAttribute('walk','NEW_SELECTION','\"hrwk05\" <> 0')",
 > env=myenv)
 > File "x:\projects\rpygeo.py", line 10
 > gp.makefeaturelayer('abc.shp','walk')(
 > "SelectLayerByAttribute('walk','NEW_SELECTION','"hrwk05" <> 0')" )

...apparently creates a Python function call 
gp.makefeaturelayer('abc.shp','walk') that is then considered to be a 
function that itself is able to make sense of the argument 
"SelectLayerByAttribute('walk','NEW_SELECTION','"hrwk05" <> 0')"

This is not what you want. The problem is that in

 > rpygeo.geoprocessor(
 > "makefeaturelayer('abc.shp','walk')",
 > "SelectLayerByAttribute('walk','NEW_SELECTION','\"hrwk05\" <> 0')",
 > env=myenv)

the "Select...." thing is considered to be an argument to the function 
defined by the first argument of the geoprocessor (please have a look at 
?rpygeo.geoprocessor - I am a bit in a hurry now because I am on a trip 
to Chile and ready for a delicious dinner ;-)

So try using c( ) (after having a closer look at the rpygeo.geoprocessor 
help / command syntax), or use separate rpygeo.geoprocessor calls for 
the two gp. commands...

> rpygeo.geoprocessor(
> c("makefeaturelayer('abc.shp', 'walk')",
> "SelectLayerByAttribute('walk','NEW_SELECTION','')"),
> env=myenv)

I hope this helps...

p.s.: will be without email for the rest of the week

Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1

More information about the R-sig-Geo mailing list