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

Commitbe6d14f

Browse files
author
Vincent Landau
committed
add Band dim to generated GeoArrays
1 parent7942efb commitbe6d14f

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

‎src/graphs.jl‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ end
1616
functionconstruct_nodemap(cost_surface::GeoData.GeoArray)
1717
# Handle dimensions, get them so the order matches the input
1818
lat_lon_dims=get_lat_lon_dims(cost_surface)
19+
cost_surface_band1= cost_surface[Band(Between(1,1))]
20+
21+
# Make an array of unique node identifiers
22+
nodemap=zeros(Int64,size(cost_surface_band1.data))
23+
is_node= (cost_surface_band1.data.!= cost_surface.missingval).&
24+
((!).(isnan.(cost_surface_band1.data)))
1925

20-
# Make an resistance of unique node identifiers
21-
nodemap=zeros(Int64,size(cost_surface.data[:, :,1]))
22-
is_node= (cost_surface.data[:, :,1].!= cost_surface.missingval).&
23-
((!).(isnan.(cost_surface.data[:, :,1])))
2426
nodemap[is_node]=1:sum(is_node)
2527

2628
nodemap= GeoData.GeoArray(nodemap, dims= lat_lon_dims)

‎src/internals.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ function get_lat_lon_dims(A::GeoData.GeoArray)
1313
first_dim_type= lat_first? Lat: Lon
1414
second_dim_type= lat_first? Lon: Lat
1515

16-
(dims(A, first_dim_type),dims(A, second_dim_type))
16+
(dims(A, first_dim_type),dims(A, second_dim_type),Band(1:1,Categorical(order=Ordered())))
1717
end

‎src/paths.jl‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function pathstate_to_geoarray(cdist::LightGraphs.AbstractPathState,
3434
cost_threshold= cost_threshold)
3535
lat_lon_dims=get_lat_lon_dims(nodemap)
3636

37-
cd_geoarray= GeoData.GeoArray(cd_array,
37+
cd_geoarray= GeoData.GeoArray(reshape(cd_array,size(nodemap)),
3838
dims= lat_lon_dims,
3939
missingval=-1)
4040
cd_geoarray
@@ -190,7 +190,8 @@ end
190190

191191
functionpath_to_geoarray(path::Vector{Int},
192192
nodemap::GeoData.GeoArray)
193-
path_array=path_to_array(path, nodemap.data[:, :,1])
193+
path_array=reshape(path_to_array(path, nodemap.data[:, :,1]),
194+
size(nodemap.data))
194195
lat_lon_dims=get_lat_lon_dims(nodemap)
195196

196197
return GeoData.GeoArray(path_array, dims= lat_lon_dims)

‎test/runtests.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ garray = GeoArray(GDALarray("nlcd_2016_frederick_md.tif", missingval = -9))
5454
old_data=deepcopy(garray.data[:, :,1])
5555
nodemap=construct_nodemap(garray)
5656

57-
@testsize(nodemap)==size(garray.data[:, :,1])
57+
@testsize(nodemap)==size(garray[Band(Between(1,1))])
5858
g=construct_graph(garray, nodemap,
5959
cost_layer_is_conductance=true,
6060
connect_four_neighbors_only=true,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp