@@ -380,10 +380,8 @@ def compute(
380380 for _ , row in basal_contact .iterrows ():
381381 # find the shortest line between the basal contact points and top contact points
382382 short_line = shapely .shortest_line (row .geometry , top_contact_geometry )
383- _lines .append (short_line [0 ])
384-
385383 # check if the short line is
386- if self .max_line_length is not None and short_line .length > self .max_line_length :
384+ if self .max_line_length is not None and short_line [ 0 ] .length > self .max_line_length :
387385 continue
388386 if self .dtm_data is not None :
389387 inv_geotransform = gdal .InvGeoTransform (self .dtm_data .GetGeoTransform ())
@@ -408,12 +406,14 @@ def compute(
408406 # find the indices of the points that are within 5% of the length of the shortest line
409407 try :
410408 # GEOS 3.10.0+
411- indices = shapely .dwithin (short_line , interp_points , line_length * 0.25 )
409+ indices = shapely .dwithin (short_line [ 0 ] , interp_points , line_length * 0.25 )
412410 except UnsupportedGEOSVersionError :
413411 indices = numpy .array ([shapely .distance (short_line [0 ],point )<= (line_length * 0.25 ) for point in interp_points ])
414412 # get the dip of the points that are within
415413 _dip = numpy .deg2rad (dip [indices ])
416- _dips .append (_dip )
414+ if len (_dip ) > 0 :
415+ _lines .extend ([short_line [0 ]]* len (_dip ))
416+ _dips .extend (_dip )
417417 # calculate the true thickness t = L * sin(dip)
418418 thickness = line_length * numpy .sin (_dip )
419419
@@ -475,6 +475,7 @@ def compute(
475475 else :
476476 self .location_tracking = geopandas .GeoDataFrame (columns = ['p1_x' , 'p1_y' , 'p1_z' , 'p2_x' , 'p2_y' , 'p2_z' , 'thickness' , 'unit' , 'geometry' ], crs = basal_contacts .crs )
477477 # Create GeoDataFrame for lines
478+
478479 self .lines = geopandas .GeoDataFrame (geometry = _lines , crs = basal_contacts .crs )
479480 self .lines ['dip' ] = _dips
480481
0 commit comments