Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Star path finder on a Raster Tiff file#535

Unanswered
mirmoazam asked this question inQ&A
Discussion options

I'm unable to run the AStar finder algorithm on a TIF cost raster file.
My aim is to find the least cost path between two points in a raster file. I'm getting a "ValueError: start location outside the surface graph." every time i run it
`url_raster2 = r'xrspatial-examples\data/LC80030172015001LGN00_B1.tiff'

img_arr = xa.open_rasterio(url_raster2).squeeze().drop("band")`

`start = img_arr[20][10]
start_y = int(start.coords['y'].data)
start_x = int(start.coords['x'].data)

end = img_arr[2000][2000]
end_y = int(end.coords['y'].data)
end_x = int(end.coords['x'].data)

path_agg = a_star_search(img_arr, start = (start_y, start_x), goal = (end_y, end_x))`

What can be the possible issue ?. I am trying to run xarray-spatial in the hope that i get some performance improvements in by using Dask and Numba. Will this be achievable with the current development and if not are there any plans to deploy the same in the future?

You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

Thanks for reaching out on this. I've looked into the code and found an issue ina_star_search function. For the starting and ending points, the order of the x and y coordinates is being reversed. We'll get this fixed soon. In the meanwhile, could you try reversing the order of x and y as a temporary workaround?

start=img_arr[20][10]start_y=int(start.coords['y'].data)start_x=int(start.coords['x'].data)end=img_arr[2000][2000]end_y=int(end.coords['y'].data)end_x=int(end.coords['x'].data)path_agg=a_star_search(img_arr,start= (start_x,start_y),goal= (end_x,end_y))`

Currently, xarray-spatial pathfindind a star already supports Numba. We plan to support Dask for all the tools in the library (proximity is in progress at the moment).

You must be logged in to vote
3 replies
@mirmoazam
Comment options

I've tried reversing the order of x & y but that doesn't really help. I still get the same error. An example of pathfinding implementation is shown using a shape file along with Geopandas but not with rasterio and a raster file. I'm glad to know that A star path finder already supports Numba but it will do a great deal of help if it's able to process data from a raster

@thuydotm
Comment options

The start and end locations should map to the exact pixels on the image by default. Can you setsnap_start andsnap_goal to True?, i.e

path_agg=a_star_search(img_arr,start= (start_x,start_y),goal= (end_x,end_y)),snap_start=True,snap_goal=True

It would snap the start and goal location to the nearest valid value before beginning pathfinding. Current implementation supports 2D xarray DataArray raster I believe.

Can you post the full error messages if it doesn't work?

@thuydotm
Comment options

Okay, just tried the same data and run the function myself. It seems the function to check whether a location is inside the raster does not work well at the moment. I'll create a pull request to fix this. Thanks again!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@mirmoazam@thuydotm

[8]ページ先頭

©2009-2025 Movatter.jp