Question part 1 - how do you create combined buffers, or convert existing buffers into one?
I don't know what version of QGIS you are using, or whether this feature is missing in older versions, but the Buffer tool has an option to "Dissolve buffer results". Note the pointer position in the following image:
Note that because my data are different, I've set the buffer distance to 200 m. You should set yours to 1609 m = 1 mile.
Question part 2 - How would I then find the number of ponds (onsite and offsite, not counting the pond being queried) within 1 km of each on-site pond (individually).
While you may want to dissolve buffers for visual display, you cannot use dissolved buffers to answer this question, since it sounds like you want a count for each pond separately. So even though the buffers overlap, that is OK, since a pond could fall in the search radius of more than one onsite pond, and you want it to count for each. Use Vector→Analysis Tools→Points in polygon
:
Since each buffer was constructed from a point, to get the count of ponds not including the central pond, use the Field Calculator tool to update the pond_count field to pond_count less one. Open the attribute table and click the "Toggle editing mode" button in the upper left. Then click the "Open Field Calculator" button in the upper right. Check "Update existing field", set the field to pond_count, and in the Expression box enter pond_count - 1
:
Hit OK once only, and close the dialog. Save your edits and toggle editing off.
If the ponds have some kind of unique identifier, it should propagate through each step of the process to your final shapefile, which will be a polygon layer of buffers with the count of all ponds within a 1 mile radius.
Sub-question - if one of the buffers dissects a symbol for a pond will it count the pond, or only if the centre point falls within the buffer? (i.e. could the size of the symbol affect the result?)
QGIS and other GISes treat points as a mathematical point (i.e., infinitesimally small). The size of the symbol you use to visualize your data is irrelevant to the calculation. Some spatial query operations may have different results depending on whether a point falls exactly on a polygon boundary (in general GIS terminology, the difference between "contains" and "contains completely"), but I'm pretty sure the QGIS Points-in-Polygon tool will count a point on the edge as being within the polygon. I haven't tested it though. It's unlikely to make a difference in this dataset. It's more likely to be important in a situation where points and polygons are constructed on some common base, such as a street grid, and you need to decide what to do with points that fall at the exact boundary between two neighboring polygons.
This sounds like a use case for Overlay Route Events from the Linear Referencing toolbox:
Overlays two event tables to create an output event table that
represents the union or intersection of the input.
...
- Line-on-line, line-on-point, point-on-line, and point-on-point event overlays can be performed.
- The input and overlay events should be based on the same route reference.
The "same route reference" sounds like your "identical shoreline" that can be easily turned into a route ready for dynamic segmentation.
You are trying to "intersect overlapping polylines" which sounds like a "line-on-line ... event overlay" to me.
Best Answer
There are a number of ways to approach this and several different ready-to-go python modules at your disposal. However I cannot directly comment on the Qgis calls but am confident most if not all of these processes are available and documents in the API: http://docs.qgis.org/1.8/html/en/docs/user_manual/index.html
Going in order of your requests:
> splitting all lines at intersections
You can first test to see which lines intersect and then find the intersecting points between any two lines.
There is an excellent example of how to do this in python on compiledreams.com:
Part 1) Testing for line intersection Part 2) Finding the point of intersection
Alternatively you can use the python module Shapely that offers a robust set of geometric relationship methods including intersection. Fiona was also written to work very nicely with shapely and can provide a means of data-structure translation (assuming you will be using a friendly GDAL/ORG format)
Qgis does offer similar capabilities but depending on the size of the dataset could be rather time consuming.
> deleting identical segments (with some spatial tolerance)
I am not sure where you would be getting identical segments from because you are essentially breaking a line feature at the point and making what was one two separate line features.
> create points at the end of each new line segment
So if we break a line
a = [(2,0),(2,1),(2,2),(2,3)]
at the intersection point of lineb = [(0,2),(1,2),(2,2),(3,2)]
we would geta1 = [(2,0),(2,1),(2,2)]
anda2 = [(2,2),(2,3)]
as the return. There is no duplicated geometries and the endpoints of the lines would be the first and last vertices's in the array. So for a1 it would have endpoints e1 = (2,0) and e2 = (2,2).>buffer the line ends, and count the number of points near/at each line
So again shapely offers a very easy method to do this by any number of units you choose (same units as the input data is in).
Alternatively, you would define a radius around each point and create a separate polygon feature that acts as the buffer. [I am going to forgo writing out the algorithm here because I doubt that this is what you really want to do].
Then you would test to see which points fall within the buffer polygon while keeping a simple count.
Similar to the testing if lines intersect example above you can test if a point is within a polygon using an algorithm like the one defined here: http://www.ariel.com.au/a/python-point-int-poly.html
You can however just find all of the intersection points within a certain distance of any given intersection with some threshold distance. This would also save the need to create buffer polygons and performing various tests.
Without knowing much about your specific end goal you can also treat the network of polylines just as that by treating it as a network graph. This could simplify the whole process by using Networkx, which also lets you read in shapefiles. Although the topological relationships between the line features must be accurate already (meaning having already broke lines at intersection points). The counting of intersections is then just a matter of calculating the network statistic of "degree", which again is a simple method call in Networkx.