Jump to content

 
Photo

ArcView automated script or macro to select and export features

- - - - -

  • Please log in to reply
9 replies to this topic

#1
benbakelaar

benbakelaar

    Ultimate Contributor

  • Associate Admin
  • PipPipPipPipPipPip
  • 658 posts
  • Gender:Male
  • Location:North Brunswick, NJ
  • Interests:maps, information, technology, scripting, computers
  • United States

What I'm looking for here are the right words and terms to use to define what I am trying to do.

Example:
Load county shapefile for NJ. Load census tracts shapefile for NJ. Export 21 shapefiles, 1 per county, containing all census tracts inside each county.

I can do this manually, but of course there must be a way to automate it, without resorting to actual VB.NET or Python scripting. Either through a macro, an existing plug-in, or a script on the user-submitted scripts page.

I've been poking around the arcscripts.esri.com page, but apparently the terms I am entering are not what people use to describe this process.

#2
benbakelaar

benbakelaar

    Ultimate Contributor

  • Associate Admin
  • PipPipPipPipPipPip
  • 658 posts
  • Gender:Male
  • Location:North Brunswick, NJ
  • Interests:maps, information, technology, scripting, computers
  • United States

It doesn't seem like "expand" or "explode" are the terms I am looking for. At least not in relation to how they are being used in the scripts I am finding.

#3
benbakelaar

benbakelaar

    Ultimate Contributor

  • Associate Admin
  • PipPipPipPipPipPip
  • 658 posts
  • Gender:Male
  • Location:North Brunswick, NJ
  • Interests:maps, information, technology, scripting, computers
  • United States

Ah hah, maybe its "split". It's been too long since I was in school for this stuff!

Split Layer By Attributes
http://arcscripts.es....asp?dbid=14127

#4
Rob

Rob

    Legendary Contributor

  • Moderator
  • PipPipPipPipPip
  • 418 posts
  • Gender:Male
  • Location:Kailua, Hawaii
  • Interests:anything outside.
  • United States

it seems like you could do with with a model if you can figure out how to have it do a definition query for each county that would then run a select by location function, then export. Maybe number the counties and have it step through the full sequence for the queries.

#5
benbakelaar

benbakelaar

    Ultimate Contributor

  • Associate Admin
  • PipPipPipPipPipPip
  • 658 posts
  • Gender:Male
  • Location:North Brunswick, NJ
  • Interests:maps, information, technology, scripting, computers
  • United States

it seems like you could do with with a model if you can figure out how to have it do a definition query for each county that would then run a select by location function, then export. Maybe number the counties and have it step through the full sequence for the queries.


Rob, where can I learn more about modeling in ArcGIS? I looked in the help file, so I see that this task might be called a "process model" which is fairly obvious, and that I might use a "Series value" to identify each feature (e.g. county). But I don't see much about how to create a model. I'll keep looking.

BTW, that script I found above, that just explodes a single shapefile into its constituent features, which is great, but still one step away from doing what I want (take those individual features, clip another layer, and then export that).

#6
DaveB

DaveB

    Hall of Fame

  • Validated Member
  • PipPipPipPipPipPipPip
  • 1,057 posts
  • Gender:Not Telling
  • Location:Redlands, CA
  • United States

Not sure if this is what you are looking for, but you might take a look at the Analysis Tools in Arc Toolbox, under Extract. There are a couple that may apply to your case: Split or Select (may need to do a little model-building to perform your full scenario).
Dave Barnes
Esri
Product Engineer
Map Geek

#7
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,900 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

It's been a while since I last mentioned FME, so here goes... ;)

This is a perfect scenario for FME's fanout capabilities. After doing an overlay of counties on census tracts, you can automagically write out the census tracts to seperate files based on the county they're in.

If you can send me some sample data, I'd be more than happy to run a test for you.
Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#8
benbakelaar

benbakelaar

    Ultimate Contributor

  • Associate Admin
  • PipPipPipPipPipPip
  • 658 posts
  • Gender:Male
  • Location:North Brunswick, NJ
  • Interests:maps, information, technology, scripting, computers
  • United States

It's been a while since I last mentioned FME, so here goes... ;)

This is a perfect scenario for FME's fanout capabilities. After doing an overlay of counties on census tracts, you can automagically write out the census tracts to seperate files based on the county they're in.

If you can send me some sample data, I'd be more than happy to run a test for you.


OK Hans, you're on. I'm downloading the 14-day trial now.

EDIT: Very cool! I downloaded the trial, got the license, figured out what to use (WorkBench), read the help file, and ran a fanout process all in about 30 minutes! I didn't get it quite right. My result was just counties, but obviously I just "applied" the fanout to the wrong thing or missed a setting somewhere. So, what's the deal on pricing, I can't find anything on the official website?

#9
pfyfield

pfyfield

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 100 posts
  • Gender:Male
  • Location:Portland, Oregon
  • United States

I don't have access to ArcMap at the moment, and I can't remember exactly how to access it, but Model Builder is the tool for what you want to do. Basically it's a visual way to build a macro- quite easy to figure out.
Paul Fyfield
Cartographer, Bureau of Land Management
Oregon State Office
Portland, Oregon
pfyfield@blm.gov

#10
peanut

peanut

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 138 posts
  • Location:Austin, TX
  • United States

What I'm looking for here are the right words and terms to use to define what I am trying to do.

Example:
Load county shapefile for NJ. Load census tracts shapefile for NJ. Export 21 shapefiles, 1 per county, containing all census tracts inside each county.

I can do this manually, but of course there must be a way to automate it, without resorting to actual VB.NET or Python scripting. Either through a macro, an existing plug-in, or a script on the user-submitted scripts page.

I've been poking around the arcscripts.esri.com page, but apparently the terms I am entering are not what people use to describe this process.


In most cases splitting out something like this into separate shapefiles just complicates things and make stuff hard to manage. I would look into adding a field for county name to your census tract shapefile, populate this field and then do a definition query on this field. This way you only have to manage one dataset for whatever you are doing.

There is probably a script to do this but since you only have 21 counties it will probably take you longer to find the script than to just do it manually... It would take just a few minutes... For each county first select the county then go to Selection>>Select by Location. In this dialog choose select features from your census tracts that have their centroid in the county boundaries (Use selected county boundaries.) With this selection set you can either populate a county field in your census tracts dataset or export out to a new shapefile.

Hope this helps.

Rich




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->