forsys-sp / patchmax

A spatial selection optimization algorithm in ForSysR
GNU General Public License v3.0
3 stars 0 forks source link

Patchmax does not run with polygon shapefile (hexnet) #17

Closed michelledayusfs closed 1 year ago

michelledayusfs commented 1 year ago

I get this error (see attached shapefile):

create new patchmax object

pm <- patchmax_generator$new( geom = shp, id_field = 'CELL_ID', objective_field = 'HUSUM_SPM', area_field = 'AREA_HA', area_max = 2000)

Error in bind_cols(): ! Can't recycle name (size 6703) to match ..4 (size 6716). Run rlang::last_error() to see where the error occurred. Warning messages: 1: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length 2: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length Hexnet_Stanislaus.zip

codyevers commented 1 year ago

Great, I see more or less where the error is occurring and why. Basically an issue of patchmax encountering data in the wild… On Dec 21, 2022 at 2:18 PM -0600, Michelle Day @.***>, wrote:

I get this error (see attached shapefile):

create new patchmax object pm <- patchmax_generator$new(

• geom = shp, • id_field = 'CELL_ID', • objective_field = 'HUSUM_SPM', • area_field = 'AREA_HA', • area_max = 2000)

Error in bind_cols(): ! Can't recycle name (size 6703) to match ..4 (size 6716). Run rlang::last_error() to see where the error occurred. Warning messages: 1: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length 2: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length Hexnet_Stanislaus.zip — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.***>

michelledayusfs commented 1 year ago

Is it easy to fix? I can't test patchmax outside of the test_forest dataset without it reading other data. :)

codyevers commented 1 year ago

Yes, working on it right now. The issue is related to keeping the adjacency network and geometry aligned. Your dataset had some features that don’t touch other features (maybe invalid geometries?) and were therefore dropped from the adjacency network (they weren’t adjacent to anything). I’m adding some extra code to make sure they speak to each other even if there’s a different number of nodes compared to features... On Dec 21, 2022 at 6:41 PM -0600, Cody Evers @.***>, wrote:

Great, I see more or less where the error is occurring and why. Basically an issue of patchmax encountering data in the wild… On Dec 21, 2022 at 2:18 PM -0600, Michelle Day @.***>, wrote:

I get this error (see attached shapefile):

create new patchmax object pm <- patchmax_generator$new(

• geom = shp, • id_field = 'CELL_ID', • objective_field = 'HUSUM_SPM', • area_field = 'AREA_HA', • area_max = 2000)

Error in bind_cols(): ! Can't recycle name (size 6703) to match ..4 (size 6716). Run rlang::last_error() to see where the error occurred. Warning messages: 1: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length 2: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length Hexnet_Stanislaus.zip — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.***>

codyevers commented 1 year ago

Should be fixed now. ‘Run_example.R’ has some code near the top that is already set up that I used for testing. On Dec 22, 2022 at 9:31 AM -0600, Cody Evers @.***>, wrote:

Yes, working on it right now. The issue is related to keeping the adjacency network and geometry aligned. Your dataset had some features that don’t touch other features (maybe invalid geometries?) and were therefore dropped from the adjacency network (they weren’t adjacent to anything). I’m adding some extra code to make sure they speak to each other even if there’s a different number of nodes compared to features... On Dec 21, 2022 at 6:41 PM -0600, Cody Evers @.***>, wrote:

Great, I see more or less where the error is occurring and why. Basically an issue of patchmax encountering data in the wild… On Dec 21, 2022 at 2:18 PM -0600, Michelle Day @.***>, wrote:

I get this error (see attached shapefile):

create new patchmax object pm <- patchmax_generator$new(

• geom = shp, • id_field = 'CELL_ID', • objective_field = 'HUSUM_SPM', • area_field = 'AREA_HA', • area_max = 2000)

Error in bind_cols(): ! Can't recycle name (size 6703) to match ..4 (size 6716). Run rlang::last_error() to see where the error occurred. Warning messages: 1: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length 2: In vattrs[[name]][index] <- value : number of items to replace is not a multiple of replacement length Hexnet_Stanislaus.zip — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.***>

michelledayusfs commented 1 year ago

I get this error when I run patchmax on a test hexnet shapefile:

create new patchmax object pm <- patchmax_generator$new(

geom = shp, id_field = 'CELL_ID', objective_field = 'HUSUM_SPM', area_field = 'AREA_HA', area_max = 2000) Error: object 'patchmax_generator' not found