jujara

I need a hand with this .aml file

Discussion created by jujara on Jul 18, 2012
Latest reply on Jul 19, 2012 by kimo
Hello everybody, i have an old .aml file i i`m trying to transform it to a Modelbuilder script or a Phyton script, but i dont know how. The main problem is how to identify the inputs for the script.... specially these mouse interface inputs

and also transform the entire script, but identifiyng the inputs i think could be easy convert the rest of the script. Here is the script in ,aml format:


&args target swath width bin
/* Opens grid in ArcEdit for the purpose of extracting
/* the upper left and lower right limits of the desired point data with
/* two mouse clicks.

&if %swath% eq '' &then &do
&type swathprofile <target grid> <short swath name> <width in map units> <bin size in map units>
&return
&end

ae
disp 9999
mape %target%
image %target%
draw

/* Get Selection box corner points

&type 'Click two corners in display window to define swath endpoints'
&format 0
&getpoint
&type [format '%1% %2%' %pnt$x% %pnt$y%]
&sv x1 [format '%1%' %pnt$x%]
&sv y1 [format '%1%' %pnt$y%]

&format 0
&getpoint
&type [format '%1% %2%' %pnt$x% %pnt$y%]
&sv x2 [format '%1%' %pnt$x%]
&sv y2 [format '%1%' %pnt$y%]

&type Swath End Points are (%x1%,%y1%) to (%x2%,%y2%)
quit

&sv dx     [calc %x2% - %x1%]
&sv dy     [calc %y2% - %y1%]
&sv hypot  [sqrt [calc [calc %dx% * %dx%] + [calc %dy% * %dy%]]]
&sv cosine [calc %dy% / %hypot%]
&sv sine   [calc %dx% / %hypot%]
&sv xo     [calc [calc %width% / 2] * %cosine%]
&sv yo     [calc [calc %width% / 2] * %sine%]

echo offsets: (%xo%, %yo%)

/* generate a coverage of swath boundary

generate %swath%box
lines
1
[calc %x1% + %xo%], [calc %y1% - %yo%]
[calc %x1% - %xo%], [calc %y1% + %yo%]
[calc %x2% - %xo%], [calc %y2% + %yo%]
[calc %x2% + %xo%], [calc %y2% - %yo%]
[calc %x1% + %xo%], [calc %y1% - %yo%]
end
end
quit
build %swath%box

/* generate center line of swath

generate %swath%line
lines
1
%x1%, %y1%
%x2%, %y2%
end
end
quit

/* create a new zone grid of distances

grid
gridclip %target% %swath%targ cover %swath%box
setcell %swath%targ
setwindow %swath%targ
docell
%swath%temp = int ( ( ( $$ymap - %y1%) * %cosine% + ($$xmap - %x1%) * %sine% ) / %bin% )
end

/* chop out swath zone grid

gridclip %swath%temp %swath%zone cover %swath%box
kill %swath%temp
quit

/* Show scatterplot and ask for approval, extract statistics

grid
display 9999
scattergram %swath%zone %swath%targ 1 autoscale
kill %swath%targ

&if [query 'Results Look OK?'] &then &do
%swath%profile = zonalstats(%swath%zone, %target%)
quit
tables
select %swath%profile
unload %swath%.txt
quit
&type NOTE: To extract more data on this profile use these commands:
&type Grid: <table> = zonalstate(%swath%zone, <target grid>)
&type Tables: select <table>
&type Tables: unload <table>.txt
&end
&else &do
kill %swath%zone
kill %swath%line
kill %swath%box
quit
&end

Outcomes