Skip to content

Commit

Permalink
Enhance geocode() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Pechnikov committed Jun 12, 2024
1 parent 8ac0fe2 commit e86a7b7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pygmtsar/pygmtsar/Stack_geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ def coords_transform(coords):
else:
z = z_offset
coords_ll = np.column_stack([coords[:,0], coords[:,1], ele.values + z])
#print (coords_ll)
coords_ra = prm.SAT_llt2rat(coords_ll)
coords_ra = coords_ra[:,:2] if len(coords_ll)>1 else [coords_ra[:2]]
#print (coords_ra)
#print ('coords_ll', coords_ll)
coords_ra = prm.SAT_llt2rat(coords_ll).reshape(-1, 5)
#print ('coords_ra1', coords_ra)
#coords_ra = coords_ra[:,:2] if len(coords_ll)>1 else [coords_ra[:2]]
coords_ra = coords_ra[:,:2]
#print ('coords_ra2', coords_ra)
return coords_ra

geoms = []
Expand All @@ -111,7 +113,11 @@ def coords_transform(coords):
geom_type = geom.type
if geom_type == 'LineString':
coords = np.asarray(geom.coords[:])
geom = LineString(coords_transform(coords))
coords = coords_transform(coords)
if coords.shape[0] <= 1:
geom = LineString([])
else:
geom = LineString(coords)
elif geom_type == 'Point':
coords = np.asarray(geom.coords[:])
geom = Point(coords_transform(coords))
Expand Down

0 comments on commit e86a7b7

Please sign in to comment.