I have a geopandas dataframe, where each record's geometry field is made up of a LineString. Each LineString represents the points which make up a road. I'd like to find the locations of all road intersections from this data. Currently, I have nested for-loops which take each record and pairwise compute the intersection of the two LineString objects. My questions are:

  1. Is this the best way to go about doing this? Even 10 pair-wise computations is yielding ~78000 intersection points. Perhaps I need to store in a spatial database like rtree if there are indeed that many intersections, but this seems inefficient...
  2. My ultimate goal is, I have spatial points, for which I'd like to find the closest intersection point. If there is a better or more efficient method than first finding all intersections and then finding the closest point, I'd love to hear suggestions.

closed as too broad by Fezter Aug 22 '17 at 1:19

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You can likely change your approach to calculate the Cartesian product of your dataframe. From there you can generate a new column that is the intersection of your two spatial columns. That would then allow a quick nearest neighbor query. Doing this in PostGIS with a proper spatial index would also work very well. – BryceH Aug 23 '17 at 3:25