6

I have a shapefile containing streets that have to be counted.

But these streets in each case consist of several polylines.

Maybe I should buffer these polylines and union the generated polygons that have the same name as well as they overlap.

Is there a tool or do I have to write a VBA script or something?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Muschter
  • 173
  • 2
  • 5

3 Answers3

5

You don't need to worry about buffers or Polygons.

I think the tool you are looking for is called "Dissolve" in the Data Management/Generalization Toolbox. You have to decide whether to use the parameter DISSOLVE_LINE or UNSPLIT_LINES - the latter will only create a single line for contiguous features - i.e. lines that share an endpoint.

Dissolve and its usage, in Arcpy, is thus:

Dissolve Data Management

It effectively aggregates your geographies on specified attributes i.e. in your case, it's name.

The Unsplit lines parameter with two options, DISSOLVE_LINES and UNSPLIT_LINES, only applies to line input. When the default DISSOLVE_LINES option is specified, lines are dissolved into a single feature. When UNSPLIT_LINES is specified, only two lines that have a common endpoint (known as pseudonode) are merged into one continuous line.

I should add that it is very simple to use, either as a standalone script, or as a command in the python window in 10.

EDIT: You might want to have a look at the answer here if you're prepared to use another software package. From what you've told us it looks like arc may not be the best tool to work with your particular dataset.

Stev_k
  • 6,689
  • 2
  • 34
  • 46
  • First: Thank you for the quick answer! But the problem with this method is (I should have already mentioned that) that there are several streets (which consist of several lines in each case) of the same name in this area. So if they are dissolved with allowed multipart features some streets get lost. Without multipart features it doesn't work in all cases (e.g. when streets are formed like a 'Y'). That's why I mentioned the method with the overlapping buffers. – Muschter Dec 01 '11 at 14:13
  • 4
    Can't you just use the UNSPLIT_LINES paramater, as detailed above? Then, so long as two different roads with the same name are not next to each other (unlikely), then it should work, with multipart features – Stev_k Dec 01 '11 at 15:09
  • 2
    Muschter, that problem stems from an inherent flaw in the data: your streets have no unique identifier. Or maybe they do? If you can find a way to disambiguate names, perhaps by means of an additional field (like a zip code perhaps), you're free and clear with Stev_k's solution. If not, then you can still post-process this solution to "explode" each multipart street into its connected components. If the GIS works correctly, that should keep the "Y" branches together but create separate features for separate streets of the same name. – whuber Dec 01 '11 at 16:30
  • 1
    If you use the UNSPLIT_LINES option, ArcGIS won't connect two streets with the same name unless they share an endpoint. I think this is what you want. The only places this might break down are a) if the ends of the lines don't quite meet or b) if the is an intersection where two streets of the same name cross each other. – mattwigway Dec 01 '11 at 17:43
  • @ whuber: Firstly: I'm totally with you. You're right with the missing common indentifier. Then it would be very easy. But there's no way to get any. But secondly: The explode tool has the same effect as the dissolve tool without the creating multiparts option. – Muschter Dec 02 '11 at 10:39
  • @ Stev_k and mattwigway: If a street is shaped like 'x' or 'T' the polylines don't share endpoints, but they intersect. DISSOLVE or UNSPLIT don't work correctly in this case, do they? Furthermore you cannot choose in the DISSOLVE tool between DISSOLVE and UNSPLIT parameter in ArcGIS 9.2 (my version), can you? – Muschter Dec 02 '11 at 10:48
  • I think one way around this is to split all lines into their constituent segments (retaining name attributes) then running the dissolve tool. The only place I have come across such a tool is is Manifold (http://www.georeference.org/doc/transform_explode.htm) but there may be a function in ArcGIS. Alternatively you could use arcpy and Python to disagregate all lines into individual segments, although 10 is much better for arcpy. – Stev_k Dec 02 '11 at 11:30
  • There is a tool in ArcGIS called SPLIT LINES AT VERTICES dividing lines in their segments. Running this and then the DISSOLVE tool brings the same effect as just the DISSOLVE tool on the original data. – Muschter Dec 02 '11 at 13:13
  • In that case I'm afraid you will either have to refactor your data, or use another tool. Alternatively, you could probably do it in Python, but I suggest you ask another question if you want to go down that route – Stev_k Dec 05 '11 at 10:24
1

i might be misunderstanding what you need. but if all you need is a count of unique street names, you could maybe use vanilla SQL GROUP BY to aggregate by street name.

like:

select s.street_name, count(*) from streets s group by s.street_name;

of course you'll need a tool that can do SQL against a shapefile/dbf, or put the shapefile/dbf into a DBMS that can do SQL.

Or maybe try Excel - it probably has a function to give you a list of unique values from a column, and a function to count them. You could operate on the shapefile's DBF directly in Excel.

mark
  • 11
  • 1
  • Thank you very much but unfortunately you misunderstand my problem. There are e.g. 2 streets of the same name with the first consisting of 3 and the second of 4 polylines. The conclusion should be 2 counted streets, not 1 or 7. – Muschter Dec 02 '11 at 10:53
0

To do this I would first use the Summary Statistics tool with the street name field as the case item:

Calculates summary statistics for field(s) in a table.

This will give you one row for each unique street name. If some streets can have the same name when not part of the same street then use (an) additional case field(s) to establish their uniqueness.

Then I would use the Get Count tool on the table output by Summary Statistics:

Returns the total number of rows for a feature class, table, layer, or raster.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338