Select to view content in your preferred language

beginner command/scripting/python help, 9.3

03-22-2013 04:51 AM
New Contributor III
hi guys, long time lurker occasional poster...

if the information I'm after is already elsewhere, please point me in the right direction if it's faster.

I've just started using arcgis 9.3 + arcinfo after years of using mapinfo. what I'd like to do is just type my commands in arc much like the command line in mapinfo; sql commands for one would be amazing. this doesn't seem apparent in arcgis 9.3 but I could be wrong. I see the command line window but I'm not familiar with the syntax or functions found therein yet. what I used to do in mapinfo was write code in mapbasic, then run those mapbasic programs in mapinfo; can something similar be done here? if python is what I need to learn I don't mind, it's the linking of a working python script (and validation/compilation of that script) to arcmap9.3 that concerns me.

perhaps my first task can give you some insight into where I should post this, quickly...

point layer1 has say 10 points
point layer2 has say 100 points spread over the same area as layer1
what I want is to know the five closest points from layer2 for each point in layer1...

for each layer1.obj, i <=5, i++
find next closest layer2.obj
end loop

results would be something like:

layer1 item1 (1,2,3,4,5 closest points from layer2 and their distances)
layer1 item2 (1,2,3,4,5 closest points from layer2 and their distances)
layer1 item10 (1,2,3,4,5 closest points from layer2 and their distances)

with admittedly whimsical syntax that is what i'm picturing; if someone could translate that into an arc environment I'd be very grateful, or point me to the proper forum.  I understand that the point distance tool would be a start, but, can this be extended to include for loops/SQL, that sort of thing; I'm obviously stuck on mapinfo/mapbasic in my mind.

thanks very much for reading,

0 Kudos
2 Replies
MVP Notable Contributor

I note you specified version 9.3. You can program your task either in VBA or Python. If you wanted to write in Python (you might want to to this if you intend to use the code in newer versions of ArcGIS) then forget about the command line console and get yourself pyscripter, its free and really good.

In your example you have 10 * 100 combinations which through brute force is probably quite quick. But if your real datasets have thousands of points then you'll have millions of combinations. I guess the smarter way to do it is use a select by location tool with a maximum distance so you are only ever processing a subset.

You could run the entire script outside arcgis in pyscripter or wire it all up to a script tool interface and expose your code as geo-processing tool in arctoolbox.

0 Kudos
New Contributor III
thanks very much for your advice duncan, will give this some thought today and possibly be back...

0 Kudos