Skip to main content
Notice removed Canonical answer required by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Canonical answer required by TheBackwardsman
Bounty Started worth 50 reputation by TheBackwardsman
edited tags
Source Link
PolyGeo
  • 65.5k
  • 29
  • 115
  • 352

How do I calculate the Calculating directionalDistanceTransform in Python?

I would like to re-create Google Earth Engine's directionalDistanceTransform function in Python, mainly for learning and understanding purposes. There seems to be no equivalent function in Python, with the closest being the Euclidian distance transform (i.e. scipy.ndimage's distance_transform_edt()). From Earth Engine's documentation, it seems the two aforementioned functions might be similar with the exception that Earth Engine's function includes the angle and max distance arguments, which you can use to calculate distances only from a certain angle. I have no clue where to begin if I want to do this in Python as well. 

Can someone help me how I could re-create Earth Engine's distanceTransform in Python, potentially using scipy's distance_transform_edt() but with the inclusion of an angle?

So let's take this simple mask as an example;

mask = np.zeros((100, 100))
mask[65:85, 50:80] = 1

How can I calculate the distance to the nearest non-zero pixels in some given direction (angle) for each 0-valued pixel in Python?

How do I calculate the directionalDistanceTransform in Python?

I would like to re-create Google Earth Engine's directionalDistanceTransform function in Python, mainly for learning and understanding purposes. There seems to be no equivalent function in Python, with the closest being the Euclidian distance transform (i.e. scipy.ndimage's distance_transform_edt()). From Earth Engine's documentation, it seems the two aforementioned functions might be similar with the exception that Earth Engine's function includes the angle and max distance arguments, which you can use to calculate distances only from a certain angle. I have no clue where to begin if I want to do this in Python as well. Can someone help me how I could re-create Earth Engine's distanceTransform in Python, potentially using scipy's distance_transform_edt() but with the inclusion of an angle?

So let's take this simple mask as an example;

mask = np.zeros((100, 100))
mask[65:85, 50:80] = 1

How can I calculate the distance to the nearest non-zero pixels in some given direction (angle) for each 0-valued pixel in Python?

Calculating directionalDistanceTransform in Python

I would like to re-create Google Earth Engine's directionalDistanceTransform function in Python, mainly for learning and understanding purposes. There seems to be no equivalent function in Python, with the closest being the Euclidian distance transform (i.e. scipy.ndimage's distance_transform_edt()). From Earth Engine's documentation, it seems the two aforementioned functions might be similar with the exception that Earth Engine's function includes the angle and max distance arguments, which you can use to calculate distances only from a certain angle. I have no clue where to begin if I want to do this in Python as well. 

Can someone help me how I could re-create Earth Engine's distanceTransform in Python, potentially using scipy's distance_transform_edt() but with the inclusion of an angle?

So let's take this simple mask as an example;

mask = np.zeros((100, 100))
mask[65:85, 50:80] = 1

How can I calculate the distance to the nearest non-zero pixels in some given direction (angle) for each 0-valued pixel in Python?

Source Link

How do I calculate the directionalDistanceTransform in Python?

I would like to re-create Google Earth Engine's directionalDistanceTransform function in Python, mainly for learning and understanding purposes. There seems to be no equivalent function in Python, with the closest being the Euclidian distance transform (i.e. scipy.ndimage's distance_transform_edt()). From Earth Engine's documentation, it seems the two aforementioned functions might be similar with the exception that Earth Engine's function includes the angle and max distance arguments, which you can use to calculate distances only from a certain angle. I have no clue where to begin if I want to do this in Python as well. Can someone help me how I could re-create Earth Engine's distanceTransform in Python, potentially using scipy's distance_transform_edt() but with the inclusion of an angle?

So let's take this simple mask as an example;

mask = np.zeros((100, 100))
mask[65:85, 50:80] = 1

How can I calculate the distance to the nearest non-zero pixels in some given direction (angle) for each 0-valued pixel in Python?