Jump to content

 
Photo

Using Python to Modify ArcGIS Select By Location Tool

- - - - -

  • Please log in to reply
3 replies to this topic

#1
AlexOult0n1985

AlexOult0n1985

    Newbie

  • Validated Member
  • Pip
  • 2 posts
  • Australia

Hi, thanks for reading.

I am fairly new to the world of programming and have been asked to produce a tool which can:

1) Read in a comma delimited text file containing n point features
2) Compare the x y coordinates of each point feature to see whether they intersect a known polygon
3) Write the results to an output a text file to say which points intersect the polygon

I need to add functionality, so that I define a buffer for the polygon.

I am considdering the possibility of using python to modify the select by location tool? Would this be possible? If so, couldd you please point me in the right direcxtion as to how i might accomplish this, or any code libraries if this kind of thing has already been done

Thanks,

Alex.

Environmental GIS Officer, Department of Conservation
alexoulton@live.co.uk

#2
frax

frax

    Hall of Fame

  • Associate Admin
  • PipPipPipPipPipPipPip
  • 2,312 posts
  • Gender:Male
  • Location:Stockholm, Sweden
  • Interests:music, hiking, friends, nature, photography, traveling. and maps!
  • Sweden

What software do you have handy? ArcGIS I suspect, since you bring up Python...
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/
Twitter

#3
AlexOult0n1985

AlexOult0n1985

    Newbie

  • Validated Member
  • Pip
  • 2 posts
  • Australia

What software do you have handy? ArcGIS I suspect, since you bring up Python...


Yes Im running ArcGIS 9.3, should have mentioned that earlier sorry...

#4
dsl

dsl

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 225 posts
  • Gender:Male
  • Location:Denver
  • United States

You can do this in several ways, but building onto the select by location tool is probably not the way to do it. What you are interested in is the spatial relationship functions available in ArcGIS (or you could do this using opensource). You can accomplish this using Python, VBA or .NET. Since VBA is going the way of the dodo, then really concentrate on either .NET or Python. Since you mention python, I will give links for that language. The steps needed are to parse the text file, for each line split it by comma. You need to create a point geometry based on these coordinates. Or manually create a shapefile from the text file, and skip the first two steps. Next you need to get the polygon feature class, and loop through each point creating a spatial relationship between the geometries and test for an intersection or touches relationship. Write out the results to a text file. This presentation gives some more advanced examples, and this blog entry.

Good luck. I didn't really like python at first, but have come to enjoy using it.

Cheers,
David




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->