Dear Gianni,
ArcGIS is not that flexible; it does not allow you to directly create an
ASCII raster as an output of a geoprocessing tool. Try this to create an
ESRI raster "SLOPE" and then convert the result to ASCII:
setwd("C:/work")
env = rpygeo.build.env(overwriteoutput = 1,
workspace = getwd())
rpygeo.geoprocessor(fun = "ASCIIToRaster_conversion",
args = list("DEM.asc","DEM"), env=env)
rpygeo.Slope.sa("DEM","SLOPE",unit="PERCENT_RISE", env=env)
rpygeo.geoprocessor(fun = "RasterToASCII_conversion",
args = list("SLOPE","SLOPE.asc"), env=env)
rpygeo.Delete.management("DEM", env=env)
rpygeo.Delete.management("SLOPE", env=env)
Regarding the (much faster) RSAGA solution, try this:
setwd("C:/work")
rsaga.esri.to.sgrd("DEM")
rsaga.slope("DEM","SLOPErad")
# convert to slope in percent:
rsaga.grid.calculus("SLOPErad","SLOPE", formula="100*tan(a)")
rsaga.sgrd.to.esri("SLOPE", prec = 4)
unlink(c("SLOPErad.*", "SLOPE.?grd", "SLOPE.sdat",
"DEM.?grd", "DEM.sdat"))
I hope this helps...
cheers
Alex
P.S.: You could also you the following call for converting ESRI raster
to ASCII...
rpygeo.RasterToASCII.conversion("C:/work/SLOPE","C:/work/SLOPE.asc")
using the following function that is included in the next release of
RPyGeo (to be available in the next days):
rpygeo.RasterToASCII.conversion = function(in.raster,
out.ascii.file, ...)
{
out.ascii.file = default.file.extension(out.ascii.file, ".asc")
if (!(tolower(get.file.extension(out.ascii.file)) %in% c(".asc",
".txt")))
stop("'out.ascii.file' must have extension '.asc' or '.txt'.\n")
args = list(in.raster, out.ascii.file)
rpygeo.geoprocessor(fun = "RasterToASCII_conversion", args = args,
...)
}
gianni lavaredo wrote:
Hi All,
I am using Alexander Brenning RPyGeo. I have a DEM.asc (ASCII File format)
and I wish to obtaion SLOPE (possible always in ascii formta) in percent.
But I have this problem:
rpygeo.Slope.sa("C:/work/DEM.asc","C:/work/SLOPE.asc",unit=c("PERCENT_RISE"),
z.factor = 1)
[1] "Executing: Slope C:/work/DEM.asc C:\\work\\SLOPE.asc PERCENT_RISE
1"
[2] "Start Time: Mon Mar 02 19:03:30
2009"
[3] "Failed to execute. Parameters are not
valid."
[4] "Parameter : C:\\work\\SLOPE.asc's extension is invalid for the output
raster format."
[5] "Failed to execute
(Slope)."
[6] "End Time: Mon Mar 02 19:03:30 2009 (Elapsed Time: 0.00
seconds)"
I tryed several solutions but nothing. I tryed also with RSAGA but I don't
understand the right code to have in "percent".
Thanks
Gianni.
PS: for Prof. Alexander Brenning. this geoprocessing expression runs in
RpyGEO
rpygeo.geoprocessing("Intersect_analysis"
c("C:/work/plots.shp;C:/work/sample.shp", "C:/work/right_sample.shp",
"ALL"))
but I need to load the datas from the work folder
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Alexander Brenning
brenn...@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
http://www.fes.uwaterloo.ca/geography/faculty/brenning/
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo