Hi

I'm trying to create a simple model that calculates the total length of polylines (pipes) within a set of polygons, the number of points (leakage incidents) within the polygons and also the number of points per kilometre of polylines. I've done this process 'manually' a few times and it consists of:

- Collect Events on the points.

- An intersect of the pipes and polygons so that pipes that cross over polygon boundaries are split at the boundaries.

- A spatial join of the intersected pipes to the polygons, with the field mapping set to sum the shape_length field. The other fields from the pipes feature class are not included. This gives the total length of pipes in each polygon.

- Another spatial join of the collected leakage points to the output of the previous spatial join, with the field map set to sum the icount for each point. This gives the total number of leaks for each polygon.

- Finally a new field is added and a field calculation run to calculate the number of leaks / total length of pipes in metres * 1000 = leaks per km.

I'm having some difficulty working out how to build this into a model. The attachment shows what I've got so far.

How do I deal with the field mapping for the spatial joins? The first spatial join (that gets the length of pipe per polygon) should always only include the name of the polygon and the summed length of pipe, but because the input feature classes are model parameters the spatial join doesn't yet 'know' in model builder what fields to expect. I can add a field mapping variable and expose it as a parameter but I'd rather the user not have to set up the mapping every time. Can I instead get the user to specify the field to use for the length in the pipes feature class, and somehow use that to set up the mapping?

Similarly with the other spatial joins used to sum the counts of the points in the polygons...

Is there a better tool for this than a spatial join? Unfortunately I only have an ArcView license...

I'm also a bit unclear as to how to use the Calculate Field tool - I have used the field calculator in the attribute tables lots but not the tool version. Is the VB that this tool uses the same as the VBA I have used in the other field calculator? What do I need to include in the expression box - do I need to put the field name =...? How do I make sure the calculator calculates into the new field I've just added?

Also, the leakage points have a date field - eventually I want to be able to split the leakage by year and have columns for the number of leaks for each year as well as a total number of leaks... So I guess I'd do this by performing selections by year on the leakage data before passing each year selection to separate Collect Events tools and then I need a spatial join for each one... At the moment the data goes back to 2006 but is there a way to generalise this to be able to cope with any range of years?

Any help is much appreciated!

Thanks

Dan

I'm trying to create a simple model that calculates the total length of polylines (pipes) within a set of polygons, the number of points (leakage incidents) within the polygons and also the number of points per kilometre of polylines. I've done this process 'manually' a few times and it consists of:

- Collect Events on the points.

- An intersect of the pipes and polygons so that pipes that cross over polygon boundaries are split at the boundaries.

- A spatial join of the intersected pipes to the polygons, with the field mapping set to sum the shape_length field. The other fields from the pipes feature class are not included. This gives the total length of pipes in each polygon.

- Another spatial join of the collected leakage points to the output of the previous spatial join, with the field map set to sum the icount for each point. This gives the total number of leaks for each polygon.

- Finally a new field is added and a field calculation run to calculate the number of leaks / total length of pipes in metres * 1000 = leaks per km.

I'm having some difficulty working out how to build this into a model. The attachment shows what I've got so far.

How do I deal with the field mapping for the spatial joins? The first spatial join (that gets the length of pipe per polygon) should always only include the name of the polygon and the summed length of pipe, but because the input feature classes are model parameters the spatial join doesn't yet 'know' in model builder what fields to expect. I can add a field mapping variable and expose it as a parameter but I'd rather the user not have to set up the mapping every time. Can I instead get the user to specify the field to use for the length in the pipes feature class, and somehow use that to set up the mapping?

Similarly with the other spatial joins used to sum the counts of the points in the polygons...

Is there a better tool for this than a spatial join? Unfortunately I only have an ArcView license...

I'm also a bit unclear as to how to use the Calculate Field tool - I have used the field calculator in the attribute tables lots but not the tool version. Is the VB that this tool uses the same as the VBA I have used in the other field calculator? What do I need to include in the expression box - do I need to put the field name =...? How do I make sure the calculator calculates into the new field I've just added?

Also, the leakage points have a date field - eventually I want to be able to split the leakage by year and have columns for the number of leaks for each year as well as a total number of leaks... So I guess I'd do this by performing selections by year on the leakage data before passing each year selection to separate Collect Events tools and then I need a spatial join for each one... At the moment the data goes back to 2006 but is there a way to generalise this to be able to cope with any range of years?

Any help is much appreciated!

Thanks

Dan

I am currently working on a model similar to what your working on. I too am working with a set of pipes within a regulator area and doing analysis on leak repairs. The main thing that I would do is instead using Spatial Join I would use Identity. That way your taking away an extra step from your model because the identity does an intersect and then names it by the intersecting features, and then just run a Summary Stats on the Length for the pipes. Then for your Leaks you can run an identity again and either get a frequency or select by attributes of regulator area name and then get count. Also one thing you can look for if your not using arc info and have a lot of data is the Split Layer by Attributes Tool, its somewhere around on these forums. Its essentially the Split tool used in ArcInfo. Once you download that tool and add it use the output from your identity to split your features. This tool is cool cause you can make your model faster and not have to select by location or attribute, just make sure you dont have them as layers in arcmap you the add data button and use it that way.

Hopefully that helped

Bcraddick