#NEWLINE# def test_shapes_mask_sampling( runner , pixelated_image , pixelated_image_file ) : #NEWLINE# #INDENT# '\n    using --sampling with the mask should snap coordinates to the nearest\n    factor of 5\n    ' #NEWLINE# pixelated_image [ 0 : 5 , 0 : 10 ] = 255 #NEWLINE# pixelated_image [ 0 : 10 , 0 : 3 ] = 255 #NEWLINE# pixelated_image [ 8 : 10 , 8 : 10 ] = 255 #NEWLINE# with rasterio . open ( pixelated_image_file , 'r+' ) as out : #NEWLINE# #INDENT# out . write ( pixelated_image , indexes = 1 ) #NEWLINE# #UNINDENT# result = runner . invoke ( main_group , [ 'shapes' , pixelated_image_file , '--mask' , '--sampling' , 5 ] ) #NEWLINE# assert ( out . exit_code == 0 ) #NEWLINE# assert ( result . output . count ( '"FeatureCollection"' ) == 1 ) #NEWLINE# assert ( result . output . count ( '"Feature"' ) == 1 ) #NEWLINE# assert numpy . allclose ( json . loads ( result . output ) [ 'features' ] [ 0 ] [ 'geometry' ] [ 'coordinates' ] , [ [ [ 5 , 5 ] , [ 5 , 10 ] , [ 10 , 10 ] , [ 10 , 5 ] , [ 5 , 5 ] ] ] )