Advertisement

08.18.2008 at 09:44PM PDT, ID: 23658538
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Python script - add stack

Asked by mgjust in Python Scripting Language, GIS & GPS Programming

Hello,
I was seeking help on a GIS forum on the get following response:

---
Below is the algorithm. It begins with a stack P of your 412 points in priority order and an empty stack S. When it ends, S contains the points to select. You can obtain your areas by buffering S.

When all 412 points are in a single layer, a straightforward modification of an ArcTool like NearestNeighbor.py will do this algorithm for you: just remove the unnecessary parts and replace the inner loop body with the code needed to implement the two inner lines of this algorithm. Output the stack S (which in Python will be implemented as a dictionary of points).
        

Begin
  d = 2*5
  While P is not empty {
    a = Pop(P)
    x = d+1
    For each point b in S {
      x = Min(x, Distance(a,b))
      If (x < d) then break
    }
   If (x >= d) then push a on S
  }
End

---

Below is the nearestneighbor code the author suggested to modify. Does anyone have any suggestions on how to implement this (i.e. combine these two codes)? Whats a stack?

Thanks,
MJStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
# Analyze crime data to determine if spatial patterns are statistically significant
 
# Import system modules
import arcgisscripting
 
# Create the Geoprocessor object
gp = arcgisscripting.create()
 
# Local variables...
workspace = "C:/project93/data"
crime_data = "burglaries.shp"
 
try:
    # Set the current workspace (to avoid having to specify the full path to the feature classes each time)
    gp.workspace = workspace
 
    # Obtain Nearest Neighbor Ratio and Z Score
    # Process: Average Nearest Neighbor...
    nn_output = gp.AverageNearestNeighbor_stats(crime_data, "Euclidean Distance", "false", "#")
    nn_values = nn_output.split(";")
    print "The nearest neighbor index is: " + nn_values[0]
    print "The z score of the nearest neighbor index is: " + nn_values[1]
 
except:
    # If an error occurred when running the tool, print out the error message.
    print gp.GetMessages()
[+][-]08.19.2008 at 05:23AM PDT, ID: 22259083

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.19.2008 at 05:25AM PDT, ID: 22259096

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Python Scripting Language, GIS & GPS Programming
Sign Up Now!
Solution Provided By: ramrom
Participating Experts: 1
Solution Grade: B
 
 
[+][-]08.19.2008 at 10:31AM PDT, ID: 22261927

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628